mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8824 from jfbu/merge_3.x_into_master
Merge 3.x into master
This commit is contained in:
commit
acbe71c15c
2
CHANGES
2
CHANGES
@ -120,6 +120,8 @@ Features added
|
|||||||
* #8514: autodoc: Default values of overloaded functions are taken from actual
|
* #8514: autodoc: Default values of overloaded functions are taken from actual
|
||||||
implementation if they're ellipsis
|
implementation if they're ellipsis
|
||||||
* #8775: autodoc: Support type union operator (PEP-604) in Python 3.10 or above
|
* #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
|
* #8619: html: kbd role generates customizable HTML tags for compound keys
|
||||||
* #8634: html: Allow to change the order of JS/CSS via ``priority`` parameter
|
* #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()`
|
for :meth:`Sphinx.add_js_file()` and :meth:`Sphinx.add_css_file()`
|
||||||
|
@ -127,6 +127,17 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
.. automodule:: foo
|
.. automodule:: foo
|
||||||
:no-undoc-members:
|
: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
|
* Members without docstrings will be left out, unless you give the
|
||||||
``undoc-members`` flag option::
|
``undoc-members`` flag option::
|
||||||
|
@ -129,6 +129,9 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|||||||
thread.start()
|
thread.start()
|
||||||
self.workers.append(thread)
|
self.workers.append(thread)
|
||||||
|
|
||||||
|
def is_ignored_uri(self, uri: str) -> bool:
|
||||||
|
return any(pat.match(uri) for pat in self.to_ignore)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def good(self) -> Set[str]:
|
def good(self) -> Set[str]:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
@ -279,10 +282,6 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|||||||
srcdir = path.dirname(self.env.doc2path(docname))
|
srcdir = path.dirname(self.env.doc2path(docname))
|
||||||
if path.exists(path.join(srcdir, uri)):
|
if path.exists(path.join(srcdir, uri)):
|
||||||
return 'working', '', 0
|
return 'working', '', 0
|
||||||
else:
|
|
||||||
for rex in self.to_ignore:
|
|
||||||
if rex.match(uri):
|
|
||||||
return 'ignored', '', 0
|
|
||||||
else:
|
else:
|
||||||
self._broken[uri] = ''
|
self._broken[uri] = ''
|
||||||
return 'broken', '', 0
|
return 'broken', '', 0
|
||||||
@ -292,9 +291,6 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|||||||
return 'broken', self._broken[uri], 0
|
return 'broken', self._broken[uri], 0
|
||||||
elif uri in self._redirected:
|
elif uri in self._redirected:
|
||||||
return 'redirected', self._redirected[uri][0], self._redirected[uri][1]
|
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
|
# need to actually check the URI
|
||||||
for _ in range(self.config.linkcheck_retries):
|
for _ in range(self.config.linkcheck_retries):
|
||||||
@ -442,13 +438,18 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|||||||
def finish(self) -> None:
|
def finish(self) -> None:
|
||||||
logger.info('')
|
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,\
|
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:
|
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:
|
while done < total_links:
|
||||||
self.process_result(self.rqueue.get())
|
self.process_result(self.rqueue.get())
|
||||||
done += 1
|
done += 1
|
||||||
|
@ -32,6 +32,9 @@ AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members',
|
|||||||
'ignore-module-all', 'exclude-members', 'member-order',
|
'ignore-module-all', 'exclude-members', 'member-order',
|
||||||
'imported-members']
|
'imported-members']
|
||||||
|
|
||||||
|
AUTODOC_EXTENDABLE_OPTIONS = ['members', 'private-members', 'special-members',
|
||||||
|
'exclude-members']
|
||||||
|
|
||||||
|
|
||||||
class DummyOptionSpec(dict):
|
class DummyOptionSpec(dict):
|
||||||
"""An option_spec allows any options."""
|
"""An option_spec allows any options."""
|
||||||
@ -76,8 +79,20 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o
|
|||||||
else:
|
else:
|
||||||
negated = options.pop('no-' + name, True) is None
|
negated = options.pop('no-' + name, True) is None
|
||||||
if name in config.autodoc_default_options and not negated:
|
if name in config.autodoc_default_options and not negated:
|
||||||
|
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]
|
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))
|
return Options(assemble_option_dict(options.items(), documenter.option_spec))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
\NeedsTeXFormat{LaTeX2e}
|
\NeedsTeXFormat{LaTeX2e}
|
||||||
\ProvidesPackage{sphinxpackagefootnote}%
|
\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:
|
% Provides support for this output mark-up from Sphinx latex writer:
|
||||||
% - footnote environment
|
% - footnote environment
|
||||||
% - savenotes environment (table templates)
|
% - savenotes environment (table templates)
|
||||||
@ -8,7 +8,7 @@
|
|||||||
%
|
%
|
||||||
%%
|
%%
|
||||||
%% Package: sphinxpackagefootnote
|
%% 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
|
%% as available at https://www.ctan.org/pkg/footnotehyper
|
||||||
%% License: the one applying to Sphinx
|
%% License: the one applying to Sphinx
|
||||||
%%
|
%%
|
||||||
@ -22,6 +22,7 @@
|
|||||||
%% 4. macro definition \sphinxfootnotemark,
|
%% 4. macro definition \sphinxfootnotemark,
|
||||||
%% 5. macro definition \sphinxlongtablepatch
|
%% 5. macro definition \sphinxlongtablepatch
|
||||||
%% 6. replaced some \undefined by \@undefined
|
%% 6. replaced some \undefined by \@undefined
|
||||||
|
\newif\iffootnotehyperparse\footnotehyperparsetrue
|
||||||
\DeclareOption*{\PackageWarning{sphinxpackagefootnote}{Option `\CurrentOption' is unknown}}%
|
\DeclareOption*{\PackageWarning{sphinxpackagefootnote}{Option `\CurrentOption' is unknown}}%
|
||||||
\ProcessOptions\relax
|
\ProcessOptions\relax
|
||||||
\newbox\FNH@notes
|
\newbox\FNH@notes
|
||||||
@ -223,38 +224,76 @@
|
|||||||
\FNH@endfntext@fntext {\unvbox\z@}%
|
\FNH@endfntext@fntext {\unvbox\z@}%
|
||||||
\endgroup
|
\endgroup
|
||||||
}%
|
}%
|
||||||
\AtBeginDocument{%
|
\let\FNH@prefntext\@empty
|
||||||
\let\FNH@@makefntext\@makefntext
|
\let\FNH@postfntext\@empty
|
||||||
\ifx\@makefntextFB\@undefined
|
\AtBeginDocument{\iffootnotehyperparse\expandafter\FNH@check\fi}%
|
||||||
\expandafter\@gobble\else\expandafter\@firstofone\fi
|
\def\FNH@safeif#1{%
|
||||||
{\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else
|
\iftrue\csname if#1\endcsname\csname fi\endcsname\expandafter\@firstoftwo
|
||||||
\let\FNH@@makefntext\@makefntextORI\fi}%
|
\else\csname fi\endcsname\expandafter\@secondoftwo
|
||||||
\expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}%
|
\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
|
\FNH@@@1.2!3?4,\FNH@@@\relax
|
||||||
}%
|
}%
|
||||||
\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{%
|
\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
|
\else
|
||||||
\edef\FNH@restore@{\catcode`\noexpand\@\the\catcode`\@\relax}%
|
\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}%
|
||||||
\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@
|
|
||||||
\expandafter\FNH@check@b
|
\expandafter\FNH@check@b
|
||||||
\fi
|
\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{%
|
\def\FNH@check@b #1\relax{%
|
||||||
\expandafter\expandafter\expandafter\FNH@check@c
|
\expandafter\expandafter\expandafter\FNH@check@c
|
||||||
\expandafter\meaning\expandafter\FNH@prefntext
|
\expandafter\meaning\expandafter\FNH@prefntext
|
||||||
\meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax
|
\meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax
|
||||||
}%
|
}%
|
||||||
\def\FNH@check@c #11.2!3?4,#2#3\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
|
% slight reformulation for Sphinx
|
||||||
\def\FNH@bad@makefntext@alert{%
|
\def\FNH@bad@makefntext@alert{%
|
||||||
|
@ -568,6 +568,36 @@ def test_autodoc_members(app):
|
|||||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
' .. 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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_exclude_members(app):
|
def test_autodoc_exclude_members(app):
|
||||||
@ -587,6 +617,57 @@ def test_autodoc_exclude_members(app):
|
|||||||
'.. py:class:: Base()',
|
'.. 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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_undoc_members(app):
|
def test_autodoc_undoc_members(app):
|
||||||
@ -611,6 +692,48 @@ def test_autodoc_undoc_members(app):
|
|||||||
' .. py:method:: Class.undocmeth()'
|
' .. 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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_inherited_members(app):
|
def test_autodoc_inherited_members(app):
|
||||||
@ -712,6 +835,38 @@ def test_autodoc_special_members(app):
|
|||||||
' .. py:method:: Class.undocmeth()'
|
' .. 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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_ignore_module_all(app):
|
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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_noindex(app):
|
def test_autodoc_noindex(app):
|
||||||
options = {"noindex": True}
|
options = {"noindex": None}
|
||||||
actual = do_autodoc(app, 'module', 'target', options)
|
actual = do_autodoc(app, 'module', 'target', options)
|
||||||
assert list(actual) == [
|
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)
|
actual = do_autodoc(app, 'class', 'target.InnerChild', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -864,7 +1019,7 @@ def test_autodoc_staticmethod(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_descriptor(app):
|
def test_autodoc_descriptor(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.descriptor.Class', options)
|
actual = do_autodoc(app, 'class', 'target.descriptor.Class', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -892,7 +1047,7 @@ def test_autodoc_descriptor(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_cached_property(app):
|
def test_autodoc_cached_property(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options)
|
actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -912,8 +1067,8 @@ def test_autodoc_member_order(app):
|
|||||||
# case member-order='bysource'
|
# case member-order='bysource'
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -937,8 +1092,8 @@ def test_autodoc_member_order(app):
|
|||||||
# case member-order='groupwise'
|
# case member-order='groupwise'
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
'member-order': 'groupwise',
|
'member-order': 'groupwise',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -961,8 +1116,8 @@ def test_autodoc_member_order(app):
|
|||||||
|
|
||||||
# case member-order=None
|
# case member-order=None
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -989,7 +1144,7 @@ def test_autodoc_module_member_order(app):
|
|||||||
# case member-order='bysource'
|
# case member-order='bysource'
|
||||||
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:module:: target.sort_by_all',
|
'.. 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
|
# case member-order='bysource' and ignore-module-all
|
||||||
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
"ignore-module-all": True}
|
"ignore-module-all": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:module:: target.sort_by_all',
|
'.. py:module:: target.sort_by_all',
|
||||||
@ -1052,7 +1207,7 @@ def test_autodoc_class_scope(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_class_attributes(app):
|
def test_class_attributes(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.AttCls', options)
|
actual = do_autodoc(app, 'class', 'target.AttCls', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1162,7 +1317,7 @@ def test_autoattribute_instance_attributes(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_slots(app):
|
def test_slots(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.slots', options)
|
actual = do_autodoc(app, 'module', 'target.slots', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1559,7 +1714,7 @@ def test_partialmethod_undoc_members(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_typed_instance_variables(app):
|
def test_autodoc_typed_instance_variables(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typed_vars', options)
|
actual = do_autodoc(app, 'module', 'target.typed_vars', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1657,8 +1812,8 @@ def test_autodoc_typed_instance_variables(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_typed_inherited_instance_variables(app):
|
def test_autodoc_typed_inherited_instance_variables(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
"inherited-members": True}
|
"inherited-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.typed_vars.Derived', options)
|
actual = do_autodoc(app, 'class', 'target.typed_vars.Derived', options)
|
||||||
assert list(actual) == [
|
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.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_hide_value(app):
|
def test_hide_value(app):
|
||||||
options = {'members': True}
|
options = {'members': None}
|
||||||
actual = do_autodoc(app, 'module', 'target.hide_value', options)
|
actual = do_autodoc(app, 'module', 'target.hide_value', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
|
@ -53,7 +53,7 @@ def test_classes(app):
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_instance_variable(app):
|
def test_instance_variable(app):
|
||||||
options = {'members': True}
|
options = {'members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options)
|
actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -77,8 +77,8 @@ def test_instance_variable(app):
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_inherited_instance_variable(app):
|
def test_inherited_instance_variable(app):
|
||||||
options = {'members': True,
|
options = {'members': None,
|
||||||
'inherited-members': True}
|
'inherited-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options)
|
actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -110,7 +110,7 @@ def test_inherited_instance_variable(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_uninitialized_attributes(app):
|
def test_uninitialized_attributes(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"inherited-members": True}
|
"inherited-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options)
|
actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -138,8 +138,8 @@ def test_uninitialized_attributes(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_undocumented_uninitialized_attributes(app):
|
def test_undocumented_uninitialized_attributes(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"inherited-members": True,
|
"inherited-members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options)
|
actual = do_autodoc(app, 'class', 'target.uninitialized_attributes.Derived', options)
|
||||||
assert list(actual) == [
|
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.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required.')
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_show_inheritance_for_subclass_of_generic_type(app):
|
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)
|
actual = do_autodoc(app, 'class', 'target.classes.Quux', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
|
@ -18,7 +18,7 @@ from .test_ext_autodoc import do_autodoc
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_empty_all(app):
|
def test_empty_all(app):
|
||||||
options = {'members': True}
|
options = {'members': None}
|
||||||
actual = do_autodoc(app, 'module', 'target.empty_all', options)
|
actual = do_autodoc(app, 'module', 'target.empty_all', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -39,6 +39,6 @@ def test_empty_all(app):
|
|||||||
def test_subclass_of_mocked_object(app):
|
def test_subclass_of_mocked_object(app):
|
||||||
sys.modules.pop('target', None) # unload target module to clear the module cache
|
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)
|
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||||
assert '.. py:class:: Inherited(*args: Any, **kwargs: Any)' in actual
|
assert '.. py:class:: Inherited(*args: Any, **kwargs: Any)' in actual
|
||||||
|
@ -486,7 +486,7 @@ def test_mocked_module_imports(app, warning):
|
|||||||
confoverrides={'autodoc_typehints': "signature"})
|
confoverrides={'autodoc_typehints': "signature"})
|
||||||
def test_autodoc_typehints_signature(app):
|
def test_autodoc_typehints_signature(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -552,7 +552,7 @@ def test_autodoc_typehints_signature(app):
|
|||||||
confoverrides={'autodoc_typehints': "none"})
|
confoverrides={'autodoc_typehints': "none"})
|
||||||
def test_autodoc_typehints_none(app):
|
def test_autodoc_typehints_none(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -851,7 +851,7 @@ def test_autodoc_default_options(app):
|
|||||||
assert ' .. py:attribute:: EnumCls.val4' not in actual
|
assert ' .. py:attribute:: EnumCls.val4' not in actual
|
||||||
|
|
||||||
# with :members: = True
|
# 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')
|
actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
|
||||||
assert ' .. py:attribute:: EnumCls.val1' in actual
|
assert ' .. py:attribute:: EnumCls.val1' in actual
|
||||||
assert ' .. py:attribute:: EnumCls.val4' not in actual
|
assert ' .. py:attribute:: EnumCls.val4' not in actual
|
||||||
|
Loading…
Reference in New Issue
Block a user