Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions numpydoc/tests/test_full.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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, [])
Expand All @@ -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 'Inherit a method' in html
# 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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
2 changes: 1 addition & 1 deletion numpydoc/tests/tinybuild/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
5 changes: 4 additions & 1 deletion numpydoc/tests/tinybuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
]
project = 'numpydoc_test_module'
autosummary_generate = True
autodoc_default_options = {'inherited-members': None}
source_suffix = '.rst'
master_doc = 'index'
exclude_patterns = ['_build']
templates_path = ['_templates']
exclude_patterns = ['_build', '_templates']
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
nitpicky = True
highlight_language = 'python3'
numpydoc_class_members_toctree = False
numpydoc_xref_param_type = True
4 changes: 3 additions & 1 deletion numpydoc/tests/tinybuild/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ numpydoc_test_module
====================

.. automodule:: numpydoc_test_module
:members:
:no-members:
:no-inherited-members:
:no-special-members:
13 changes: 9 additions & 4 deletions numpydoc/tests/tinybuild/numpydoc_test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
References
----------
.. [1] https://numpydoc.readthedocs.io

"""

__all__ = ['MyClass', 'my_function']


class MyClass(object):
class _MyBaseClass(object):

def inherited(self):
"""Inherit a method."""
pass


class MyClass(_MyBaseClass):
"""A class.

Reference [2]_
Expand All @@ -40,8 +46,7 @@ def __init__(self, *args, **kwargs):
pass

def example(self):
"""Exampel function
"""
"""Example function."""
pass


Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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