diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-05 01:22:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 01:22:10 +0900 |
commit | acbe71c15cf355e23f9f48ffa9a3b1b04b46e711 (patch) | |
tree | a7c32ac0bb0c7c415f8c1c6573d866d324acc2b6 | |
parent | 307a0e580fffa92ece92f08dc1be3a7db4a90dd1 (diff) | |
parent | 87fa272763f9d19b5fa51038b2b5e4a58773de21 (diff) | |
download | sphinx-git-acbe71c15cf355e23f9f48ffa9a3b1b04b46e711.tar.gz |
Merge pull request #8824 from jfbu/merge_3.x_into_master
Merge 3.x into master
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | doc/usage/extensions/autodoc.rst | 11 | ||||
-rw-r--r-- | sphinx/builders/linkcheck.py | 29 | ||||
-rw-r--r-- | sphinx/ext/autodoc/directive.py | 17 | ||||
-rw-r--r-- | sphinx/texinputs/sphinxpackagefootnote.sty | 83 | ||||
-rw-r--r-- | tests/test_ext_autodoc.py | 193 | ||||
-rw-r--r-- | tests/test_ext_autodoc_autoclass.py | 14 | ||||
-rw-r--r-- | tests/test_ext_autodoc_automodule.py | 4 | ||||
-rw-r--r-- | tests/test_ext_autodoc_configs.py | 6 |
9 files changed, 291 insertions, 68 deletions
@@ -120,6 +120,8 @@ Features added * #8514: autodoc: Default values of overloaded functions are taken from actual implementation if they're ellipsis * #8775: autodoc: Support type union operator (PEP-604) in Python 3.10 or above +* #8297: autodoc: Allow to extend :confval:`autodoc_default_options` via + directive options * #8619: html: kbd role generates customizable HTML tags for compound keys * #8634: html: Allow to change the order of JS/CSS via ``priority`` parameter for :meth:`Sphinx.add_js_file()` and :meth:`Sphinx.add_css_file()` diff --git a/doc/usage/extensions/autodoc.rst b/doc/usage/extensions/autodoc.rst index ed85c941e..f69ac8c5c 100644 --- a/doc/usage/extensions/autodoc.rst +++ b/doc/usage/extensions/autodoc.rst @@ -127,6 +127,17 @@ inserting them into the page source under a suitable :rst:dir:`py:module`, .. automodule:: foo :no-undoc-members: + .. tip:: + + You can use autodoc directive options to temporarily override or + extend default options which takes list as an input. For example:: + + .. autoclass:: Noodle + :members: eat + :private-members: +_spicy, _garlickly + + .. versionchanged:: 3.5 + The default options can be overridden or extended temporarily. * Members without docstrings will be left out, unless you give the ``undoc-members`` flag option:: diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index c61ba5cfc..70cd302d5 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -129,6 +129,9 @@ class CheckExternalLinksBuilder(DummyBuilder): thread.start() self.workers.append(thread) + def is_ignored_uri(self, uri: str) -> bool: + return any(pat.match(uri) for pat in self.to_ignore) + @property def good(self) -> Set[str]: warnings.warn( @@ -280,21 +283,14 @@ class CheckExternalLinksBuilder(DummyBuilder): if path.exists(path.join(srcdir, uri)): return 'working', '', 0 else: - for rex in self.to_ignore: - if rex.match(uri): - return 'ignored', '', 0 - else: - self._broken[uri] = '' - return 'broken', '', 0 + self._broken[uri] = '' + return 'broken', '', 0 elif uri in self._good: return 'working', 'old', 0 elif uri in self._broken: return 'broken', self._broken[uri], 0 elif uri in self._redirected: return 'redirected', self._redirected[uri][0], self._redirected[uri][1] - for rex in self.to_ignore: - if rex.match(uri): - return 'ignored', '', 0 # need to actually check the URI for _ in range(self.config.linkcheck_retries): @@ -442,13 +438,18 @@ class CheckExternalLinksBuilder(DummyBuilder): def finish(self) -> None: logger.info('') - for hyperlink in self.hyperlinks.values(): - self.wqueue.put(hyperlink, False) - - total_links = len(self.hyperlinks) - done = 0 with open(path.join(self.outdir, 'output.txt'), 'w') as self.txt_outfile,\ open(path.join(self.outdir, 'output.json'), 'w') as self.json_outfile: + total_links = 0 + for hyperlink in self.hyperlinks.values(): + if self.is_ignored_uri(hyperlink.uri): + self.process_result((hyperlink.uri, hyperlink.docname, hyperlink.lineno, + 'ignored', '', 0)) + else: + self.wqueue.put(hyperlink, False) + total_links += 1 + + done = 0 while done < total_links: self.process_result(self.rqueue.get()) done += 1 diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 72407de35..69177f271 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -32,6 +32,9 @@ AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members', 'ignore-module-all', 'exclude-members', 'member-order', 'imported-members'] +AUTODOC_EXTENDABLE_OPTIONS = ['members', 'private-members', 'special-members', + 'exclude-members'] + class DummyOptionSpec(dict): """An option_spec allows any options.""" @@ -76,7 +79,19 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o else: negated = options.pop('no-' + name, True) is None if name in config.autodoc_default_options and not negated: - options[name] = config.autodoc_default_options[name] + if name in options and isinstance(config.autodoc_default_options[name], str): + # take value from options if present or extend it + # with autodoc_default_options if necessary + if name in AUTODOC_EXTENDABLE_OPTIONS: + if options[name] is not None and options[name].startswith('+'): + options[name] = ','.join([config.autodoc_default_options[name], + options[name][1:]]) + else: + options[name] = config.autodoc_default_options[name] + + elif options.get(name) is not None: + # remove '+' from option argument if there's nothing to merge it with + options[name] = options[name].lstrip('+') return Options(assemble_option_dict(options.items(), documenter.option_spec)) diff --git a/sphinx/texinputs/sphinxpackagefootnote.sty b/sphinx/texinputs/sphinxpackagefootnote.sty index 25c8e2627..529d24f33 100644 --- a/sphinx/texinputs/sphinxpackagefootnote.sty +++ b/sphinx/texinputs/sphinxpackagefootnote.sty @@ -1,6 +1,6 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{sphinxpackagefootnote}% - [2021/01/29 v1.1c footnotehyper adapted to sphinx (Sphinx team)] + [2021/02/04 v1.1d footnotehyper adapted to sphinx (Sphinx team)] % Provides support for this output mark-up from Sphinx latex writer: % - footnote environment % - savenotes environment (table templates) @@ -8,7 +8,7 @@ % %% %% Package: sphinxpackagefootnote -%% Version: based on footnotehyper.sty 2021/01/29 v1.1c +%% Version: based on footnotehyper.sty 2021/02/04 v1.1d %% as available at https://www.ctan.org/pkg/footnotehyper %% License: the one applying to Sphinx %% @@ -22,6 +22,7 @@ %% 4. macro definition \sphinxfootnotemark, %% 5. macro definition \sphinxlongtablepatch %% 6. replaced some \undefined by \@undefined +\newif\iffootnotehyperparse\footnotehyperparsetrue \DeclareOption*{\PackageWarning{sphinxpackagefootnote}{Option `\CurrentOption' is unknown}}% \ProcessOptions\relax \newbox\FNH@notes @@ -223,38 +224,76 @@ \FNH@endfntext@fntext {\unvbox\z@}% \endgroup }% -\AtBeginDocument{% - \let\FNH@@makefntext\@makefntext - \ifx\@makefntextFB\@undefined - \expandafter\@gobble\else\expandafter\@firstofone\fi - {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else - \let\FNH@@makefntext\@makefntextORI\fi}% - \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}% - \FNH@@@1.2!3?4,\FNH@@@\relax +\let\FNH@prefntext\@empty +\let\FNH@postfntext\@empty +\AtBeginDocument{\iffootnotehyperparse\expandafter\FNH@check\fi}% +\def\FNH@safeif#1{% + \iftrue\csname if#1\endcsname\csname fi\endcsname\expandafter\@firstoftwo + \else\csname fi\endcsname\expandafter\@secondoftwo + \fi +}% +\def\FNH@check{% + \ifx\@makefntextFB\@undefined\expandafter\FNH@check@ + \else\expandafter\FNH@frenchb@ + \fi +}% +\def\FNH@frenchb@{% + \def\FNH@prefntext{% + \localleftbox{}% + \let\FBeverypar@save\FBeverypar@quote + \let\FBeverypar@quote\relax + \FNH@safeif{FB@koma}% + {\FNH@safeif{FBFrenchFootnotes}% + {\ifx\footnote\thanks + \let\@@makefnmark\@@makefnmarkTH + \@makefntextTH{} % space as in french.ldf + \else + \let\@@makefnmark\@@makefnmarkFB + \@makefntextFB{} % space as in french.ldf + \fi + }{\let\@@makefnmark\@@makefnmarkORI + \@makefntextORI{}% no space as in french.ldf + }% + }% + {\FNH@safeif{FBFrenchFootnotes}% + {\@makefntextFB{}}% + {\@makefntextORI{}}% + }% + }% + \def\FNH@postfntext{% + \let\FBeverypar@quote\FBeverypar@save + \localleftbox{\FBeveryline@quote}% + }% +}% +\def\FNH@check@{% + \expandafter\FNH@check@a\@makefntext{1.2!3?4,}% + \FNH@@@1.2!3?4,\FNH@@@\relax }% \long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{% - \ifx\relax#3\FNH@bad@makefntext@alert + \ifx\relax#3\expandafter\FNH@checkagain@ \else - \edef\FNH@restore@{\catcode`\noexpand\@\the\catcode`\@\relax}% - \makeatletter - \ifx\@makefntextFB\@undefined - \expandafter\@gobble\else\expandafter\@firstofone\fi - {\@ifclassloaded{memoir}% - {\ifFBFrenchFootnotes\expandafter\@gobble\fi}% - {}}% - \@secondoftwo - \scantokens{\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}}% - \FNH@restore@ + \def\FNH@prefntext{#1}\def\FNH@postfntext{#2}% \expandafter\FNH@check@b \fi }% +\def\FNH@checkagain@{% + \expandafter\FNH@checkagain@a + \detokenize\expandafter{\@makefntext{1.2!3?4,}}\relax\FNH@@@ +}% +\edef\FNH@temp{\noexpand\FNH@checkagain@a ##1\string{1.2!3?4,\string}}% +\expandafter\def\FNH@temp#2#3\FNH@@@{% + \ifx\relax#2% + \def\FNH@prefntext{\@makefntext{}}% + \else\FNH@bad@makefntext@alert + \fi +}% \def\FNH@check@b #1\relax{% \expandafter\expandafter\expandafter\FNH@check@c \expandafter\meaning\expandafter\FNH@prefntext \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax }% \def\FNH@check@c #11.2!3?4,#2#3\relax{% - \ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@makefntext@alert + \ifx\FNH@check@c#2\else\FNH@bad@makefntext@alert\fi }% % slight reformulation for Sphinx \def\FNH@bad@makefntext@alert{% diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 73da31427..d657ead60 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -568,6 +568,36 @@ def test_autodoc_members(app): ' .. py:method:: Base.inheritedstaticmeth(cls)' ] + # ALL-members override autodoc_default_options + options = {"members": None} + app.config.autodoc_default_options["members"] = "inheritedstaticmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()', + ' .. py:method:: Base.inheritedmeth()', + ' .. py:method:: Base.inheritedstaticmeth(cls)' + ] + + # members override autodoc_default_options + options = {"members": "inheritedmeth"} + app.config.autodoc_default_options["members"] = "inheritedstaticmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedmeth()', + ] + + # members extends autodoc_default_options + options = {"members": "+inheritedmeth"} + app.config.autodoc_default_options["members"] = "inheritedstaticmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedmeth()', + ' .. py:method:: Base.inheritedstaticmeth(cls)' + ] + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_exclude_members(app): @@ -587,6 +617,57 @@ def test_autodoc_exclude_members(app): '.. py:class:: Base()', ] + # + has no effect when autodoc_default_options are not present + options = {"members": None, + "exclude-members": "+inheritedmeth,inheritedstaticmeth"} + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()' + ] + + # exclude-members overrides autodoc_default_options + options = {"members": None, + "exclude-members": "inheritedmeth"} + app.config.autodoc_default_options["exclude-members"] = "inheritedstaticmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()', + ' .. py:method:: Base.inheritedstaticmeth(cls)' + ] + + # exclude-members extends autodoc_default_options + options = {"members": None, + "exclude-members": "+inheritedmeth"} + app.config.autodoc_default_options["exclude-members"] = "inheritedstaticmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()', + ] + + # no exclude-members causes use autodoc_default_options + options = {"members": None} + app.config.autodoc_default_options["exclude-members"] = "inheritedstaticmeth,inheritedmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()', + ] + + # empty exclude-members cancels autodoc_default_options + options = {"members": None, + "exclude-members": None} + app.config.autodoc_default_options["exclude-members"] = "inheritedstaticmeth,inheritedmeth" + actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Base()', + ' .. py:method:: Base.inheritedclassmeth()', + ' .. py:method:: Base.inheritedmeth()', + ' .. py:method:: Base.inheritedstaticmeth(cls)' + ] + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_undoc_members(app): @@ -611,6 +692,48 @@ def test_autodoc_undoc_members(app): ' .. py:method:: Class.undocmeth()' ] + # use autodoc_default_options + options = {"members": None} + app.config.autodoc_default_options["undoc-members"] = None + actual = do_autodoc(app, 'class', 'target.Class', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Class(arg)', + ' .. py:attribute:: Class.attr', + ' .. py:attribute:: Class.docattr', + ' .. py:method:: Class.excludemeth()', + ' .. py:attribute:: Class.inst_attr_comment', + ' .. py:attribute:: Class.inst_attr_inline', + ' .. py:attribute:: Class.inst_attr_string', + ' .. py:attribute:: Class.mdocattr', + ' .. py:method:: Class.meth()', + ' .. py:method:: Class.moore(a, e, f) -> happiness', + ' .. py:method:: Class.roger(a, *, b=2, c=3, d=4, e=5, f=6)', + ' .. py:attribute:: Class.skipattr', + ' .. py:method:: Class.skipmeth()', + ' .. py:attribute:: Class.udocattr', + ' .. py:method:: Class.undocmeth()' + ] + + # options negation work check + options = {"members": None, + "no-undoc-members": None} + app.config.autodoc_default_options["undoc-members"] = None + actual = do_autodoc(app, 'class', 'target.Class', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Class(arg)', + ' .. py:attribute:: Class.attr', + ' .. py:attribute:: Class.docattr', + ' .. py:method:: Class.excludemeth()', + ' .. py:attribute:: Class.inst_attr_comment', + ' .. py:attribute:: Class.inst_attr_inline', + ' .. py:attribute:: Class.inst_attr_string', + ' .. py:attribute:: Class.mdocattr', + ' .. py:method:: Class.meth()', + ' .. py:method:: Class.moore(a, e, f) -> happiness', + ' .. py:method:: Class.skipmeth()', + ' .. py:attribute:: Class.udocattr', + ] + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_inherited_members(app): @@ -712,6 +835,38 @@ def test_autodoc_special_members(app): ' .. py:method:: Class.undocmeth()' ] + # specific special methods from autodoc_default_options + options = {"undoc-members": None} + app.config.autodoc_default_options["special-members"] = "__special2__" + actual = do_autodoc(app, 'class', 'target.Class', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Class(arg)', + ' .. py:method:: Class.__special2__()', + ] + + # specific special methods option with autodoc_default_options + options = {"undoc-members": None, + "special-members": "__init__,__special1__"} + app.config.autodoc_default_options["special-members"] = "__special2__" + actual = do_autodoc(app, 'class', 'target.Class', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Class(arg)', + ' .. py:method:: Class.__init__(arg)', + ' .. py:method:: Class.__special1__()', + ] + + # specific special methods merge with autodoc_default_options + options = {"undoc-members": None, + "special-members": "+__init__,__special1__"} + app.config.autodoc_default_options["special-members"] = "__special2__" + actual = do_autodoc(app, 'class', 'target.Class', options) + assert list(filter(lambda l: '::' in l, actual)) == [ + '.. py:class:: Class(arg)', + ' .. py:method:: Class.__init__(arg)', + ' .. py:method:: Class.__special1__()', + ' .. py:method:: Class.__special2__()', + ] + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_ignore_module_all(app): @@ -739,7 +894,7 @@ def test_autodoc_ignore_module_all(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_noindex(app): - options = {"noindex": True} + options = {"noindex": None} actual = do_autodoc(app, 'module', 'target', options) assert list(actual) == [ '', @@ -820,7 +975,7 @@ def test_autodoc_inner_class(app): '', ] - options['show-inheritance'] = True + options['show-inheritance'] = None actual = do_autodoc(app, 'class', 'target.InnerChild', options) assert list(actual) == [ '', @@ -864,7 +1019,7 @@ def test_autodoc_staticmethod(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_descriptor(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'class', 'target.descriptor.Class', options) assert list(actual) == [ '', @@ -892,7 +1047,7 @@ def test_autodoc_descriptor(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_cached_property(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options) assert list(actual) == [ '', @@ -912,8 +1067,8 @@ def test_autodoc_member_order(app): # case member-order='bysource' options = {"members": None, 'member-order': 'bysource', - "undoc-members": True, - 'private-members': True} + "undoc-members": None, + 'private-members': None} actual = do_autodoc(app, 'class', 'target.Class', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Class(arg)', @@ -937,8 +1092,8 @@ def test_autodoc_member_order(app): # case member-order='groupwise' options = {"members": None, 'member-order': 'groupwise', - "undoc-members": True, - 'private-members': True} + "undoc-members": None, + 'private-members': None} actual = do_autodoc(app, 'class', 'target.Class', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Class(arg)', @@ -961,8 +1116,8 @@ def test_autodoc_member_order(app): # case member-order=None options = {"members": None, - "undoc-members": True, - 'private-members': True} + "undoc-members": None, + 'private-members': None} actual = do_autodoc(app, 'class', 'target.Class', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Class(arg)', @@ -989,7 +1144,7 @@ def test_autodoc_module_member_order(app): # case member-order='bysource' options = {"members": 'foo, Bar, baz, qux, Quux, foobar', 'member-order': 'bysource', - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'module', 'target.sort_by_all', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:module:: target.sort_by_all', @@ -1004,8 +1159,8 @@ def test_autodoc_module_member_order(app): # case member-order='bysource' and ignore-module-all options = {"members": 'foo, Bar, baz, qux, Quux, foobar', 'member-order': 'bysource', - "undoc-members": True, - "ignore-module-all": True} + "undoc-members": None, + "ignore-module-all": None} actual = do_autodoc(app, 'module', 'target.sort_by_all', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:module:: target.sort_by_all', @@ -1052,7 +1207,7 @@ def test_autodoc_class_scope(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_class_attributes(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'class', 'target.AttCls', options) assert list(actual) == [ '', @@ -1162,7 +1317,7 @@ def test_autoattribute_instance_attributes(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_slots(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'module', 'target.slots', options) assert list(actual) == [ '', @@ -1559,7 +1714,7 @@ def test_partialmethod_undoc_members(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_typed_instance_variables(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'module', 'target.typed_vars', options) assert list(actual) == [ '', @@ -1657,8 +1812,8 @@ def test_autodoc_typed_instance_variables(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_typed_inherited_instance_variables(app): options = {"members": None, - "undoc-members": True, - "inherited-members": True} + "undoc-members": None, + "inherited-members": None} actual = do_autodoc(app, 'class', 'target.typed_vars.Derived', options) assert list(actual) == [ '', @@ -2273,7 +2428,7 @@ def test_type_union_operator(app): @pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_hide_value(app): - options = {'members': True} + options = {'members': None} actual = do_autodoc(app, 'module', 'target.hide_value', options) assert list(actual) == [ '', diff --git a/tests/test_ext_autodoc_autoclass.py b/tests/test_ext_autodoc_autoclass.py index 74ddb02f9..538b36881 100644 --- a/tests/test_ext_autodoc_autoclass.py +++ b/tests/test_ext_autodoc_autoclass.py @@ -53,7 +53,7 @@ def test_classes(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_instance_variable(app): - options = {'members': True} + options = {'members': None} actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options) assert list(actual) == [ '', @@ -77,8 +77,8 @@ def test_instance_variable(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_inherited_instance_variable(app): - options = {'members': True, - 'inherited-members': True} + options = {'members': None, + 'inherited-members': None} actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options) assert list(actual) == [ '', @@ -110,7 +110,7 @@ def test_inherited_instance_variable(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_uninitialized_attributes(app): options = {"members": None, - "inherited-members": True} + "inherited-members": None} actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options) assert list(actual) == [ '', @@ -138,8 +138,8 @@ def test_uninitialized_attributes(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_undocumented_uninitialized_attributes(app): options = {"members": None, - "inherited-members": True, - "undoc-members": True} + "inherited-members": None, + "undoc-members": None} actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options) assert list(actual) == [ '', @@ -228,7 +228,7 @@ def test_slots_attribute(app): @pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required.') @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_show_inheritance_for_subclass_of_generic_type(app): - options = {'show-inheritance': True} + options = {'show-inheritance': None} actual = do_autodoc(app, 'class', 'target.classes.Quux', options) assert list(actual) == [ '', diff --git a/tests/test_ext_autodoc_automodule.py b/tests/test_ext_autodoc_automodule.py index df57724b3..3332704bb 100644 --- a/tests/test_ext_autodoc_automodule.py +++ b/tests/test_ext_autodoc_automodule.py @@ -18,7 +18,7 @@ from .test_ext_autodoc import do_autodoc @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_empty_all(app): - options = {'members': True} + options = {'members': None} actual = do_autodoc(app, 'module', 'target.empty_all', options) assert list(actual) == [ '', @@ -39,6 +39,6 @@ def test_empty_all(app): def test_subclass_of_mocked_object(app): sys.modules.pop('target', None) # unload target module to clear the module cache - options = {'members': True} + options = {'members': None} actual = do_autodoc(app, 'module', 'target.need_mocks', options) assert '.. py:class:: Inherited(*args: Any, **kwargs: Any)' in actual diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py index bae684397..06bf39c24 100644 --- a/tests/test_ext_autodoc_configs.py +++ b/tests/test_ext_autodoc_configs.py @@ -486,7 +486,7 @@ def test_mocked_module_imports(app, warning): confoverrides={'autodoc_typehints': "signature"}) def test_autodoc_typehints_signature(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'module', 'target.typehints', options) assert list(actual) == [ '', @@ -552,7 +552,7 @@ def test_autodoc_typehints_signature(app): confoverrides={'autodoc_typehints': "none"}) def test_autodoc_typehints_none(app): options = {"members": None, - "undoc-members": True} + "undoc-members": None} actual = do_autodoc(app, 'module', 'target.typehints', options) assert list(actual) == [ '', @@ -851,7 +851,7 @@ def test_autodoc_default_options(app): assert ' .. py:attribute:: EnumCls.val4' not in actual # with :members: = True - app.config.autodoc_default_options = {'members': True} + app.config.autodoc_default_options = {'members': None} actual = do_autodoc(app, 'class', 'target.enums.EnumCls') assert ' .. py:attribute:: EnumCls.val1' in actual assert ' .. py:attribute:: EnumCls.val4' not in actual |