From 5845a0ab87afa68b1553090c6535cf21677cf6c5 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Thu, 18 Jun 2020 23:37:51 +0200 Subject: [PATCH 1/5] basic CSS: Take "simple" and "compact" lists into account See #7838. --- sphinx/themes/basic/static/basic.css_t | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index cf169f5e3..a1b8ce10a 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -537,6 +537,14 @@ ul ul > li:last-child > :last-child { margin-bottom: revert; } +ol.simple > li > p, +ul.simple > li > p, +ol.compact > li > p, +ul.compact > li > p { + margin-top: 0; + margin-bottom: 0; +} + dl.footnote > dt, dl.citation > dt { float: left; From 0051992ba514186473363fadd5ceaa496c276a60 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Fri, 19 Jun 2020 22:36:23 +0200 Subject: [PATCH 2/5] FIXUP: remove "compact" class --- sphinx/themes/basic/static/basic.css_t | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index a1b8ce10a..5345a9840 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -538,9 +538,7 @@ ul ul > li:last-child > :last-child { } ol.simple > li > p, -ul.simple > li > p, -ol.compact > li > p, -ul.compact > li > p { +ul.simple > li > p { margin-top: 0; margin-bottom: 0; } From 82768d8cffe46646db46a4b8baf73435888e2ffc Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Fri, 19 Jun 2020 23:12:41 +0200 Subject: [PATCH 3/5] basic CSS: better handling of list margins, including "simple" lists Fixes #7838. --- sphinx/themes/basic/static/basic.css_t | 33 ++++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 5345a9840..e0f24c8a1 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -513,33 +513,30 @@ ol.upperroman { list-style: upper-roman; } -ol > li:first-child > :first-child, -ul > li:first-child > :first-child { +:not(li) > ol > li:first-child > :first-child, +:not(li) > ul > li:first-child > :first-child { margin-top: 0px; } -ol ol > li:first-child > :first-child, -ol ul > li:first-child > :first-child, -ul ol > li:first-child > :first-child, -ul ul > li:first-child > :first-child { - margin-top: revert; -} - -ol > li:last-child > :last-child, -ul > li:last-child > :last-child { +:not(li) > ol > li:last-child > :last-child, +:not(li) > ul > li:last-child > :last-child { margin-bottom: 0px; } -ol ol > li:last-child > :last-child, -ol ul > li:last-child > :last-child, -ul ol > li:last-child > :last-child, -ul ul > li:last-child > :last-child { - margin-bottom: revert; +ol.simple ol p, +ol.simple ul p, +ul.simple ol p, +ul.simple ul p { + margin-top: 0; } -ol.simple > li > p, -ul.simple > li > p { +ol.simple > li:not(:first-child) > p, +ul.simple > li:not(:first-child) > p { margin-top: 0; +} + +ol.simple p, +ul.simple p { margin-bottom: 0; } From cc4534d12fb875bc11d7b26f9a0553d42af4ad53 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 5 Jul 2020 02:12:17 +0900 Subject: [PATCH 4/5] Update CHANGES for PR #7852 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 985116851..7be8d94d7 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugs fixed * #7812: autosummary: generates broken stub files if the target code contains an attribute and module that are same name * #7806: viewcode: Failed to resolve viewcode references on 3rd party builders +* #7838: html theme: List items have extra vertical space Testing -------- From 9b74e6cd675937dc53745513167a8c93531374fe Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 5 Jul 2020 03:08:27 +0900 Subject: [PATCH 5/5] autodoc: the signature of base function will be shown for decorated functions --- CHANGES | 5 +++++ sphinx/ext/autodoc/__init__.py | 14 +++----------- tests/test_ext_autodoc.py | 4 ++-- tests/test_ext_autodoc_autofunction.py | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 7be8d94d7..5ce96bac1 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,9 @@ Dependencies Incompatible changes -------------------- +* #7650: autodoc: the signature of base function will be shown for decorated + functions, not a signature of decorator + Deprecated ---------- @@ -23,6 +26,8 @@ Bugs fixed is 'description' * #7812: autodoc: crashed if the target name matches to both an attribute and module that are same name +* #7650: autodoc: function signature becomes ``(*args, **kwargs)`` if the + function is decorated by generic decorator * #7812: autosummary: generates broken stub files if the target code contains an attribute and module that are same name * #7806: viewcode: Failed to resolve viewcode references on 3rd party builders diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 85bea8c43..9300a2cce 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1157,10 +1157,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ try: self.env.app.emit('autodoc-before-process-signature', self.object, False) - if inspect.is_singledispatch_function(self.object): - sig = inspect.signature(self.object, follow_wrapped=True) - else: - sig = inspect.signature(self.object) + sig = inspect.signature(self.object, follow_wrapped=True) args = stringify_signature(sig, **kwargs) except TypeError as exc: logger.warning(__("Failed to get a function signature for %s: %s"), @@ -1740,13 +1737,8 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: sig = inspect.signature(self.object, bound_method=False) else: self.env.app.emit('autodoc-before-process-signature', self.object, True) - - meth = self.parent.__dict__.get(self.objpath[-1], None) - if meth and inspect.is_singledispatch_method(meth): - sig = inspect.signature(self.object, bound_method=True, - follow_wrapped=True) - else: - sig = inspect.signature(self.object, bound_method=True) + sig = inspect.signature(self.object, bound_method=True, + follow_wrapped=True) args = stringify_signature(sig, **kwargs) except TypeError as exc: logger.warning(__("Failed to get a method signature for %s: %s"), diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 652c7f10b..7b4823a2f 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -1267,7 +1267,7 @@ def test_automethod_for_decorated(app): actual = do_autodoc(app, 'method', 'target.decorator.Bar.meth') assert list(actual) == [ '', - '.. py:method:: Bar.meth()', + '.. py:method:: Bar.meth(name=None, age=None)', ' :module: target.decorator', '', ] @@ -1432,7 +1432,7 @@ def test_coroutine(app): actual = do_autodoc(app, 'function', 'target.coroutine.sync_func') assert list(actual) == [ '', - '.. py:function:: sync_func(*args, **kwargs)', + '.. py:function:: sync_func()', ' :module: target.coroutine', '', ] diff --git a/tests/test_ext_autodoc_autofunction.py b/tests/test_ext_autodoc_autofunction.py index da090d83a..bb292bc6a 100644 --- a/tests/test_ext_autodoc_autofunction.py +++ b/tests/test_ext_autodoc_autofunction.py @@ -98,7 +98,7 @@ def test_decorated(app): actual = do_autodoc(app, 'function', 'target.decorator.foo') assert list(actual) == [ '', - '.. py:function:: foo()', + '.. py:function:: foo(name=None, age=None)', ' :module: target.decorator', '', ]