diff --git a/CHANGES b/CHANGES index 6d81408a5..2074d06ea 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,8 @@ Bugs fixed * C++, fix lookup of full template specializations with no template arguments. * #4667: C++, fix assertion on missing references in global scope when using intersphinx. Thanks to Alan M. Carroll. +* #5019: autodoc: crashed by Form Feed Character +* #5032: autodoc: loses the first staticmethod parameter for old styled classes * #5036: quickstart: Typing Ctrl-U clears the whole of line Testing diff --git a/EXAMPLES b/EXAMPLES index 98bab3987..fd2beaee4 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -218,6 +218,7 @@ Documentation using sphinx_rtd_theme * peewee: http://docs.peewee-orm.com/ * Phinx: http://docs.phinx.org/ * phpMyAdmin: https://docs.phpmyadmin.net/ +* PROS: https://pros.cs.purdue.edu/v5/ (customized) * Pweave: http://mpastell.com/pweave/ * PyPy: http://doc.pypy.org/ * python-sqlparse: https://sqlparse.readthedocs.io/ diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst index 09098f39c..dc45c6bc3 100644 --- a/doc/ext/autodoc.rst +++ b/doc/ext/autodoc.rst @@ -374,7 +374,7 @@ There are also new config values that you can set: This value contains a list of modules to be mocked up. This is useful when some external dependencies are not met at build time and break the building process. You may only specify the root package of the dependencies - themselves and ommit the sub-modules: + themselves and omit the sub-modules: .. code-block:: python diff --git a/doc/extdev/index.rst b/doc/extdev/index.rst index ace43fd71..69a1732f6 100644 --- a/doc/extdev/index.rst +++ b/doc/extdev/index.rst @@ -92,7 +92,7 @@ Deprecated APIs On developing Sphinx, we are always careful to the compatibility of our APIs. But, sometimes, the change of interface are needed for some reasons. In such -cases, we've marked thme as deprecated. And they are kept during the two +cases, we've marked them as deprecated. And they are kept during the two major versions (for more details, please see :ref:`deprecation-policy`). The following is a list of deprecated interface. diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index 5c4291d3d..40334f2e3 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -34,6 +34,11 @@ else: ASSIGN_NODES = (ast.Assign) +def filter_whitespace(code): + # type: (unicode) -> unicode + return code.replace('\f', ' ') # replace FF (form feed) with whitespace + + def get_assign_targets(node): # type: (ast.AST) -> List[ast.expr] """Get list of targets from Assign and AnnAssign node.""" @@ -466,7 +471,7 @@ class Parser(object): def __init__(self, code, encoding='utf-8'): # type: (unicode, unicode) -> None - self.code = code + self.code = filter_whitespace(code) self.encoding = encoding self.comments = {} # type: Dict[Tuple[unicode, unicode], unicode] self.deforders = {} # type: Dict[unicode, int] diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 72c3065bc..fbef01341 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -176,8 +176,8 @@ def isstaticmethod(obj, cls=None, name=None): elif cls and name: # trace __mro__ if the method is defined in parent class # - # .. note:: This only works with new style classes. - for basecls in getattr(cls, '__mro__', []): + # .. note:: This only works well with new style classes. + for basecls in getattr(cls, '__mro__', [cls]): meth = basecls.__dict__.get(name) if meth: if isinstance(meth, staticmethod): diff --git a/tests/test_pycode_parser.py b/tests/test_pycode_parser.py index 29363e17e..0875329a4 100644 --- a/tests/test_pycode_parser.py +++ b/tests/test_pycode_parser.py @@ -315,3 +315,12 @@ def test_decorators(): 'func3': ('def', 7, 9), 'Foo': ('class', 11, 15), 'Foo.method': ('def', 13, 15)} + + +def test_formfeed_char(): + source = ('class Foo:\n' + '\f\n' + ' attr = 1234 #: comment\n') + parser = Parser(source) + parser.parse() + assert parser.comments == {('Foo', 'attr'): 'comment'} diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py index 76f21a5e1..e18e21761 100644 --- a/tests/test_util_inspect.py +++ b/tests/test_util_inspect.py @@ -362,3 +362,26 @@ def test_dict_customtype(): description = inspect.object_description(dictionary) # Type is unsortable, just check that it does not crash assert ": 2" in description + + +def test_isstaticmethod(): + class Foo(): + @staticmethod + def method1(): + pass + + def method2(self): + pass + + class Bar(Foo): + pass + + assert inspect.isstaticmethod(Foo.method1, Foo, 'method1') is True + assert inspect.isstaticmethod(Foo.method2, Foo, 'method2') is False + + if sys.version_info < (3, 0): + assert inspect.isstaticmethod(Bar.method1, Bar, 'method1') is False + assert inspect.isstaticmethod(Bar.method2, Bar, 'method2') is False + else: + assert inspect.isstaticmethod(Bar.method1, Bar, 'method1') is True + assert inspect.isstaticmethod(Bar.method2, Bar, 'method2') is False