diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index b7d10de9..652eedc6 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -168,7 +168,7 @@ def mangle_docstrings(app, what, name, obj, options, lines): doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg, builder=app.builder) lines[:] = str(doc).split(u_NL) - except: + except Exception: logger.error('[numpydoc] While processing docstring for %r', name) raise diff --git a/numpydoc/tests/test_full.py b/numpydoc/tests/test_full.py index 73837759..b727cde5 100644 --- a/numpydoc/tests/test_full.py +++ b/numpydoc/tests/test_full.py @@ -1,8 +1,10 @@ +from distutils.version import LooseVersion import os.path as op import re import shutil import pytest +import sphinx from sphinx.application import Sphinx from sphinx.util.docutils import docutils_namespace @@ -25,9 +27,12 @@ def ignore(src, names): toctrees_dir = op.join(temp_dir, '_build', 'toctrees') # Avoid warnings about re-registration, see: # https://github.com/sphinx-doc/sphinx/issues/5038 + kwargs = dict() + if LooseVersion(sphinx.__version__) >= LooseVersion('1.8'): + kwargs.update(warningiserror=True, keep_going=True) with docutils_namespace(): app = Sphinx(src_dir, conf_dir, out_dir, toctrees_dir, - buildername='html') + buildername='html', **kwargs) # need to build within the context manager # for automodule and backrefs to work app.build(False, []) @@ -46,6 +51,9 @@ def test_MyClass(sphinx_app): 'numpydoc_test_module.MyClass.html') with open(class_html, 'r') as fid: html = fid.read() + # ensure that no autodoc weirdness ($) occurs + assert '$self' not in html + assert '__init__' in html # inherited # escaped * chars should no longer be preceded by \'s, # if we see a \* in the output we know it's incorrect: assert r'\*' not in html @@ -77,7 +85,7 @@ def test_reference(sphinx_app): ["generated", "numpydoc_test_module.MyClass.html"], ] - expected_lengths = [3, 1, 1] + expected_lengths = [1, 1, 1] for html_file, expected_length in zip(html_files, expected_lengths): html_file = op.join(out_dir, *html_file) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index ec2bbc9b..b7127ce2 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -1274,7 +1274,10 @@ def test_bad_generic_functions(self, capsys, func): ], ) def test_bad_docstrings(self, capsys, klass, func, msgs): - result = validate_one(self._import_path(klass=klass, func=func)) + with pytest.warns(None) as w: + result = validate_one(self._import_path(klass=klass, func=func)) + if len(w): + assert all('Unknown section' in str(ww.message) for ww in w) for msg in msgs: assert msg in " ".join(err[1] for err in result["errors"]) diff --git a/numpydoc/tests/tinybuild/Makefile b/numpydoc/tests/tinybuild/Makefile index 27af0eb3..95d39af2 100644 --- a/numpydoc/tests/tinybuild/Makefile +++ b/numpydoc/tests/tinybuild/Makefile @@ -5,7 +5,7 @@ clean: rm -rf generated/ html: - sphinx-build -b html -d _build/doctrees . _build/html + sphinx-build -nWT --keep-going -b html -d _build/doctrees . _build/html show: @python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/_build/html/index.html')" diff --git a/numpydoc/tests/tinybuild/conf.py b/numpydoc/tests/tinybuild/conf.py index 71ef6640..8b16cdd2 100644 --- a/numpydoc/tests/tinybuild/conf.py +++ b/numpydoc/tests/tinybuild/conf.py @@ -11,6 +11,7 @@ ] project = 'numpydoc_test_module' autosummary_generate = True +autodoc_default_options = {'inherited-members': None} source_suffix = '.rst' master_doc = 'index' exclude_patterns = ['_build'] @@ -19,4 +20,5 @@ } nitpicky = True highlight_language = 'python3' +numpydoc_class_members_toctree = False numpydoc_xref_param_type = True diff --git a/numpydoc/tests/tinybuild/index.rst b/numpydoc/tests/tinybuild/index.rst index 9d5c1d9c..25a32d41 100644 --- a/numpydoc/tests/tinybuild/index.rst +++ b/numpydoc/tests/tinybuild/index.rst @@ -2,4 +2,6 @@ numpydoc_test_module ==================== .. automodule:: numpydoc_test_module - :members: + :no-members: + :no-inherited-members: + :no-special-members: diff --git a/numpydoc/tests/tinybuild/numpydoc_test_module.py b/numpydoc/tests/tinybuild/numpydoc_test_module.py index 3c23dc4c..3c073dff 100644 --- a/numpydoc/tests/tinybuild/numpydoc_test_module.py +++ b/numpydoc/tests/tinybuild/numpydoc_test_module.py @@ -13,7 +13,6 @@ References ---------- .. [1] https://numpydoc.readthedocs.io - """ __all__ = ['MyClass', 'my_function'] @@ -36,12 +35,8 @@ class MyClass(object): .. [2] https://numpydoc.readthedocs.io """ - def __init__(self, *args, **kwargs): - pass - - def example(self): - """Exampel function - """ + def example(self, x): + """Example method.""" pass diff --git a/setup.cfg b/setup.cfg index 5221732a..420fc78a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,8 @@ addopts = --showlocals --doctest-modules -ra --cov-report= --cov=numpydoc --junit-xml=junit-results.xml --ignore=doc/conf.py +junit_family = xunit2 filterwarnings = ignore:'U' mode is deprecated:DeprecationWarning + ignore:.*sphinx\.util\.smartypants is deprecated.*: ignore:Using or importing the ABCs.*:DeprecationWarning