docs: tweaks to make docs build on Python 3.8

This commit is contained in:
Jake VanderPlas 2021-04-01 13:27:11 -07:00
parent 3e980a79f6
commit c473fdee63
4 changed files with 20 additions and 3 deletions

View File

@ -16,6 +16,6 @@ formats:
# Optionally set the version of Python and requirements required to build your docs # Optionally set the version of Python and requirements required to build your docs
python: python:
version: 3.7 version: 3.8
install: install:
- requirements: docs/requirements.txt - requirements: docs/requirements.txt

View File

@ -34,3 +34,13 @@ profiling features.
device_memory_profile device_memory_profile
save_device_memory_profile save_device_memory_profile
Deprecated functions
--------------------
.. autosummary::
:toctree: _autosummary
trace_function
TraceContext
StepTraceContext

View File

@ -1928,10 +1928,12 @@ def _isposneginf(infinity, x, out):
return full_like(x, False, dtype=bool_) return full_like(x, False, dtype=bool_)
isposinf = _wraps(np.isposinf, skip_params=['out'])( isposinf = _wraps(np.isposinf, skip_params=['out'])(
lambda x, out=None: _isposneginf(inf, x, out)) lambda x, out=None: _isposneginf(inf, x, out)
)
isneginf = _wraps(np.isneginf, skip_params=['out'])( isneginf = _wraps(np.isneginf, skip_params=['out'])(
lambda x, out=None: _isposneginf(-inf, x, out)) lambda x, out=None: _isposneginf(-inf, x, out)
)
@_wraps(np.isnan) @_wraps(np.isnan)
def isnan(x): def isnan(x):

View File

@ -21,6 +21,7 @@ _parameter_break = re.compile("\n(?=[A-Za-z_])")
_section_break = re.compile(r"\n(?=[^\n]{3,15}\n-{3,15})", re.MULTILINE) _section_break = re.compile(r"\n(?=[^\n]{3,15}\n-{3,15})", re.MULTILINE)
_numpy_signature_re = re.compile(r'^([\w., ]+=)?\s*[\w\.]+\([\w\W]*?\)$', re.MULTILINE) _numpy_signature_re = re.compile(r'^([\w., ]+=)?\s*[\w\.]+\([\w\W]*?\)$', re.MULTILINE)
_versionadded = re.compile(r'^\s+\.\.\s+versionadded::', re.MULTILINE) _versionadded = re.compile(r'^\s+\.\.\s+versionadded::', re.MULTILINE)
_docreference = re.compile(r':doc:`(.*?)\s*<.*?>`')
class ParsedDoc(NamedTuple): class ParsedDoc(NamedTuple):
""" """
@ -48,6 +49,10 @@ def _parse_numpydoc(docstr: Optional[str]) -> ParsedDoc:
if docstr is None or not docstr.strip(): if docstr is None or not docstr.strip():
return ParsedDoc(docstr) return ParsedDoc(docstr)
# Remove any :doc: directives in the docstring to avoid sphinx errors
docstr = _docreference.sub(
lambda match: f"{match.groups()[0]}", docstr)
signature, body = "", docstr signature, body = "", docstr
match = _numpy_signature_re.match(body) match = _numpy_signature_re.match(body)
if match: if match: