Consistently name the object description options (#11533)

*  The directive option ``:noindex:`` was renamed to ``:no-index:``.
*  The directive option ``:noindexentry:`` was renamed to ``:no-index-entry:``.
*  The directive option ``:nocontentsentry:`` was renamed to ``:no-contents-entry:``.

The previous names are retained as aliases, but will be deprecated
and removed in a future version of Sphinx (9.0 or later).
This commit is contained in:
Adam Turner
2023-07-28 22:30:26 +01:00
committed by GitHub
parent ff20efcd7e
commit 1cfb68d8be
31 changed files with 264 additions and 212 deletions

View File

@@ -12,7 +12,7 @@ project's :file:`conf.py` file, but this is not available to you as an
extension developer.
.. module:: sphinx.application
:noindex:
:no-index:
To ensure that another extension is activated as a part of your own extension,
use the :meth:`sphinx.application.Sphinx.setup_extension` method. This will

View File

@@ -226,7 +226,7 @@ them to generate links or output multiply used elements.
documents.
.. function:: pathto(file, 1)
:noindex:
:no-index:
Return the path to a *file* which is a filename relative to the root of the
generated output. Use this to refer to static files.

View File

@@ -105,7 +105,7 @@ Emitting events
---------------
.. class:: Sphinx
:noindex:
:no-index:
.. automethod:: emit

View File

@@ -303,7 +303,7 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
.. versionadded:: 0.4
* All autodoc directives support the ``noindex`` flag option that has the
* All autodoc directives support the ``no-index`` flag option that has the
same effect as for standard :rst:dir:`py:function` etc. directives: no
index entries are generated for the documented object (and all
autodocumented members).
@@ -724,7 +724,7 @@ There are also config values that you can set:
.. versionadded:: 1.7
.. confval:: suppress_warnings
:noindex:
:no-index:
:mod:`autodoc` supports to suppress warning messages via
:confval:`suppress_warnings`. It allows following warnings types in
@@ -755,7 +755,7 @@ autodoc provides the following additional events:
:param obj: the object itself
:param options: the options given to the directive: an object with attributes
``inherited_members``, ``undoc_members``, ``show_inheritance`` and
``noindex`` that are true if the flag option of same name was given to the
``no-index`` that are true if the flag option of same name was given to the
auto directive
:param lines: the lines of the docstring, see above
@@ -786,7 +786,7 @@ autodoc provides the following additional events:
:param obj: the object itself
:param options: the options given to the directive: an object with attributes
``inherited_members``, ``undoc_members``, ``show_inheritance`` and
``noindex`` that are true if the flag option of same name was given to the
``no-index`` that are true if the flag option of same name was given to the
auto directive
:param signature: function signature, as a string of the form
``"(parameter_1, parameter_2)"``, or ``None`` if introspection didn't
@@ -849,5 +849,5 @@ member should be included in the documentation by using the following event:
user handler does not override the decision
:param options: the options given to the directive: an object with attributes
``inherited_members``, ``undoc_members``, ``show_inheritance`` and
``noindex`` that are true if the flag option of same name was given to the
``no-index`` that are true if the flag option of same name was given to the
auto directive

View File

@@ -349,7 +349,7 @@ Additionally, the following filters are available
replaces the builtin Jinja `escape filter`_ that does html-escaping.
.. function:: underline(s, line='=')
:noindex:
:no-index:
Add a title underline to a piece of text.

View File

@@ -132,8 +132,8 @@ part (``sphinx``) from all names::
:parts: -1
.. py:class:: sphinx.ext.inheritance_diagram.InheritanceDiagram
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
The internal class that implements the ``inheritance-diagram`` directive.

View File

@@ -48,12 +48,12 @@ A domain will typically keep an internal index of all entities to aid
cross-referencing.
Typically it will also add entries in the shown general index.
If you want to suppress the addition of an entry in the shown index, you can
give the directive option flag ``:noindexentry:``.
give the directive option flag ``:no-index-entry:``.
If you want to exclude the object description from the table of contents, you
can give the directive option flag ``:nocontentsentry:``.
can give the directive option flag ``:no-contents-entry:``.
If you want to typeset an object description, without even making it available
for cross-referencing, you can give the directive option flag ``:noindex:``
(which implies ``:noindexentry:``).
for cross-referencing, you can give the directive option flag ``:no-index:``
(which implies ``:no-index-entry:``).
If you do not want to typeset anything, you can give the directive option flag
``:no-typesetting:``. This can for example be used to create only a target and
index entry for later reference.
@@ -72,6 +72,19 @@ options.
The directive option ``no-typesetting`` in the Python, C, C++, Javascript,
and reStructuredText domains.
.. versionchanged:: 7.2
* The directive option ``:noindex:`` was renamed
to ``:no-index:``.
* The directive option ``:noindexentry:`` was renamed
to ``:no-index-entry:``.
* The directive option ``:nocontentsentry:`` was renamed
to ``:no-contents-entry:``.
The previous names are retained as aliases,
but will be deprecated and removed
in a future version of Sphinx.
An example using a Python domain directive::
.. py:function:: spam(eggs)
@@ -85,9 +98,9 @@ that are continued in the next line. Example::
.. py:function:: filterwarnings(action, message='', category=Warning, \
module='', lineno=0, append=False)
:noindex:
:no-index:
(This example also shows how to use the ``:noindex:`` flag.)
(This example also shows how to use the ``:no-index:`` flag.)
The domains also provide roles that link back to these object descriptions.
For example, to link to one of the functions described in the example above,
@@ -643,7 +656,7 @@ For functions with optional parameters that don't have default values
argument support), you can use brackets to specify the optional parts:
.. py:function:: compile(source[, filename[, symbol]])
:noindex:
:no-index:
It is customary to put the opening bracket before the comma.
@@ -721,7 +734,7 @@ explained by an example::
This will render like this:
.. py:function:: send_message(sender, recipient, message_body, [priority=1])
:noindex:
:no-index:
Send a message to a recipient
@@ -1021,20 +1034,20 @@ Example::
This will be rendered as:
.. c:struct:: Data
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. c:union:: @data
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. c:var:: int a
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. c:var:: double b
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
Explicit ref: :c:var:`Data.@data.a`. Short-hand ref: :c:var:`Data.a`.
@@ -1116,12 +1129,12 @@ Inline Expressions and Types
will be rendered as follows:
.. c:var:: int a = 42
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. c:function:: int f(int i)
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
An expression: :c:expr:`a * f(a)` (or as text: :c:texpr:`a * f(a)`).
@@ -1340,27 +1353,27 @@ visibility statement (``public``, ``private`` or ``protected``).
The example are rendered as follows.
.. cpp:type:: std::vector<int> MyList
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
A typedef-like declaration of a type.
.. cpp:type:: MyContainer::const_iterator
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
Declaration of a type alias with unspecified type.
.. cpp:type:: MyType = std::unordered_map<int, std::string>
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
Declaration of a type alias.
.. cpp:type:: template<typename T> \
MyContainer = std::vector<T>
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. rst:directive:: .. cpp:enum:: unscoped enum declaration
.. cpp:enum-struct:: scoped enum declaration
@@ -1455,7 +1468,7 @@ Options
Some directives support options:
- ``:noindexentry:`` and ``:nocontentsentry:``, see :ref:`basic-domain-markup`.
- ``:no-index-entry:`` and ``:no-contents-entry:``, see :ref:`basic-domain-markup`.
- ``:tparam-line-spec:``, for templated declarations.
If specified, each template parameter will be rendered on a separate line.
@@ -1487,20 +1500,20 @@ Example::
This will be rendered as:
.. cpp:class:: Data
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. cpp:union:: @data
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. cpp:var:: int a
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. cpp:var:: double b
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
Explicit ref: :cpp:var:`Data::@data::a`. Short-hand ref: :cpp:var:`Data::a`.
@@ -1606,14 +1619,14 @@ introduction` instead of a template parameter list::
They are rendered as follows.
.. cpp:function:: std::Iterator{It} void advance(It &it)
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
A function template with a template parameter constrained to be an Iterator.
.. cpp:class:: std::LessThanComparable{T} MySortedContainer
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
A class template with a template parameter constrained to be
LessThanComparable.
@@ -1643,12 +1656,12 @@ Inline Expressions and Types
will be rendered as follows:
.. cpp:var:: int a = 42
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
.. cpp:function:: int f(int i)
:nocontentsentry:
:noindexentry:
:no-contents-entry:
:no-index-entry:
An expression: :cpp:expr:`a * f(a)` (or as text: :cpp:texpr:`a * f(a)`).
@@ -2037,7 +2050,7 @@ The JavaScript domain (name **js**) provides the following directives:
:rst:dir:`py:class` would, for example.
By default, this directive will create a linkable entity and will cause an
entry in the global module index, unless the ``noindex`` option is
entry in the global module index, unless the ``no-index`` option is
specified. If this option is specified, the directive will only update the
current module name.
@@ -2069,7 +2082,7 @@ The JavaScript domain (name **js**) provides the following directives:
This is rendered as:
.. js:function:: $.getJSON(href, callback[, errback])
:noindex:
:no-index:
:param string href: An URI to the location of the resource.
:param callback: Gets called with the object.
@@ -2117,7 +2130,7 @@ The JavaScript domain (name **js**) provides the following directives:
This is rendered as:
.. js:class:: MyAnimal(name[, age])
:noindex:
:no-index:
:param string name: The name of the animal
:param number age: an optional age for the animal
@@ -2173,12 +2186,12 @@ The reStructuredText domain (name **rst**) provides the following directives:
will be rendered as:
.. rst:directive:: foo
:noindex:
:no-index:
Foo description.
.. rst:directive:: .. bar:: baz
:noindex:
:no-index:
Bar description.
@@ -2197,13 +2210,13 @@ The reStructuredText domain (name **rst**) provides the following directives:
will be rendered as:
.. rst:directive:: toctree
:noindex:
:no-index:
.. rst:directive:option:: caption: caption of ToC
:noindex:
:no-index:
.. rst:directive:option:: glob
:noindex:
:no-index:
.. rubric:: options
@@ -2232,7 +2245,7 @@ The reStructuredText domain (name **rst**) provides the following directives:
will be rendered as:
.. rst:role:: foo
:noindex:
:no-index:
Foo description.

View File

@@ -54,10 +54,13 @@ class ObjectDescription(SphinxDirective, Generic[ObjDescT]):
optional_arguments = 0
final_argument_whitespace = True
option_spec: OptionSpec = {
'no-index': directives.flag,
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
}
# types of doc fields that this directive handles, see sphinx.util.docfields
@@ -186,7 +189,7 @@ class ObjectDescription(SphinxDirective, Generic[ObjDescT]):
* find out if called as a domain-specific directive, set self.domain
* create a `desc` node to fit all description inside
* parse standard options, currently `noindex`
* parse standard options, currently `no-index`
* create an index node if needed as self.indexnode
* parse all given signatures (as returned by self.get_signatures())
using self.handle_signature(), which should either return a name
@@ -216,9 +219,21 @@ class ObjectDescription(SphinxDirective, Generic[ObjDescT]):
node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = noindex = ('noindex' in self.options)
node['noindexentry'] = ('noindexentry' in self.options)
node['nocontentsentry'] = ('nocontentsentry' in self.options)
node['no-index'] = node['noindex'] = no_index = (
'no-index' in self.options
# xref RemovedInSphinx90Warning
# deprecate noindex in Sphinx 9.0
or 'noindex' in self.options)
node['no-index-entry'] = node['noindexentry'] = (
'no-index-entry' in self.options
# xref RemovedInSphinx90Warning
# deprecate noindexentry in Sphinx 9.0
or 'noindexentry' in self.options)
node['no-contents-entry'] = node['nocontentsentry'] = (
'no-contents-entry' in self.options
# xref RemovedInSphinx90Warning
# deprecate nocontentsentry in Sphinx 9.0
or 'nocontentsentry' in self.options)
node['no-typesetting'] = ('no-typesetting' in self.options)
if self.domain:
node['classes'].append(self.domain)
@@ -253,7 +268,7 @@ class ObjectDescription(SphinxDirective, Generic[ObjDescT]):
signode['_toc_name'] = ''
if name not in self.names:
self.names.append(name)
if not noindex:
if not no_index:
# only add target and index entry if this is the first
# description of the object with this name in this desc block
self.add_target_and_index(name, sig, signode)
@@ -276,7 +291,7 @@ class ObjectDescription(SphinxDirective, Generic[ObjDescT]):
if node['no-typesetting']:
# Attempt to return the index node, and a new target node
# containing all the ids of this node and its children.
# If ``:noindex:`` is set, or there are no ids on the node
# If ``:no-index:`` is set, or there are no ids on the node
# or any of its children, then just return the index node,
# as Docutils expects a target node to have at least one id.
if node_ids := [node_id for el in node.findall(nodes.Element)

View File

@@ -3164,9 +3164,11 @@ class CObject(ObjectDescription[ASTDeclaration]):
"""
option_spec: OptionSpec = {
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
'single-line-parameter-list': directives.flag,
}
@@ -3235,7 +3237,7 @@ class CObject(ObjectDescription[ASTDeclaration]):
self.state.document.note_explicit_target(signode)
if 'noindexentry' not in self.options:
if 'no-index-entry' not in self.options:
indexText = self.get_index_text(name)
self.indexnode['entries'].append(('single', indexText, newestId, '', None))
@@ -3542,7 +3544,7 @@ class AliasTransform(SphinxTransform):
desc['domain'] = 'c'
# 'desctype' is a backwards compatible attribute
desc['objtype'] = desc['desctype'] = 'alias'
desc['noindex'] = True
desc['no-index'] = True
childContainer = desc
for sChild in s.children:
@@ -3643,7 +3645,7 @@ class CAliasObject(ObjectDescription):
node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = True
node['no-index'] = True
self.names: list[str] = []
aliasOptions = {

View File

@@ -7215,9 +7215,11 @@ class CPPObject(ObjectDescription[ASTDeclaration]):
]
option_spec: OptionSpec = {
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
'tparam-line-spec': directives.flag,
'single-line-parameter-list': directives.flag,
}
@@ -7295,7 +7297,7 @@ class CPPObject(ObjectDescription[ASTDeclaration]):
if decl.objectType == 'concept':
isInConcept = True
break
if not isInConcept and 'noindexentry' not in self.options:
if not isInConcept and 'no-index-entry' not in self.options:
strippedName = name
for prefix in self.env.config.cpp_index_common_prefix:
if name.startswith(prefix):
@@ -7667,7 +7669,7 @@ class AliasTransform(SphinxTransform):
desc['domain'] = 'cpp'
# 'desctype' is a backwards compatible attribute
desc['objtype'] = desc['desctype'] = 'alias'
desc['noindex'] = True
desc['no-index'] = True
childContainer = desc
for sChild in s._children:

View File

@@ -43,10 +43,13 @@ class JSObject(ObjectDescription[tuple[str, str]]):
allow_nesting = False
option_spec: OptionSpec = {
'no-index': directives.flag,
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
'single-line-parameter-list': directives.flag,
}
@@ -146,7 +149,7 @@ class JSObject(ObjectDescription[tuple[str, str]]):
domain = cast(JavaScriptDomain, self.env.get_domain('js'))
domain.note_object(fullname, self.objtype, node_id, location=signode)
if 'noindexentry' not in self.options:
if 'no-index-entry' not in self.options:
indextext = self.get_index_text(mod_name, name_obj) # type: ignore[arg-type]
if indextext:
self.indexnode['entries'].append(('single', indextext, node_id, '', None))
@@ -278,8 +281,8 @@ class JSModule(SphinxDirective):
Options
-------
noindex
If the ``noindex`` option is specified, no linkable elements will be
no-index
If the ``:no-index:`` option is specified, no linkable elements will be
created, and the module won't be added to the global module index. This
is useful for splitting up the module definition across multiple
sections or files.
@@ -292,15 +295,17 @@ class JSModule(SphinxDirective):
optional_arguments = 0
final_argument_whitespace = False
option_spec: OptionSpec = {
'no-index': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
}
def run(self) -> list[Node]:
mod_name = self.arguments[0].strip()
self.env.ref_context['js:module'] = mod_name
noindex = 'noindex' in self.options
no_index = 'no-index' in self.options
content_node: Element = nodes.section()
# necessary so that the child nodes get the right source/line set
@@ -308,7 +313,7 @@ class JSModule(SphinxDirective):
nested_parse_with_titles(self.state, self.content, content_node, self.content_offset)
ret: list[Node] = []
if not noindex:
if not no_index:
domain = cast(JavaScriptDomain, self.env.get_domain('js'))
node_id = make_id(self.env, self.state.document, 'module', mod_name)

View File

@@ -659,10 +659,13 @@ class PyObject(ObjectDescription[tuple[str, str]]):
:vartype allow_nesting: bool
"""
option_spec: OptionSpec = {
'no-index': directives.flag,
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
'single-line-parameter-list': directives.flag,
'single-line-type-parameter-list': directives.flag,
'module': directives.unchanged,
@@ -854,7 +857,7 @@ class PyObject(ObjectDescription[tuple[str, str]]):
domain.note_object(canonical_name, self.objtype, node_id, aliased=True,
location=signode)
if 'noindexentry' not in self.options:
if 'no-index-entry' not in self.options:
indextext = self.get_index_text(modname, name_cls)
if indextext:
self.indexnode['entries'].append(('single', indextext, node_id, '', None))
@@ -958,7 +961,7 @@ class PyFunction(PyObject):
def add_target_and_index(self, name_cls: tuple[str, str], sig: str,
signode: desc_signature) -> None:
super().add_target_and_index(name_cls, sig, signode)
if 'noindexentry' not in self.options:
if 'no-index-entry' not in self.options:
modname = self.options.get('module', self.env.ref_context.get('py:module'))
node_id = signode['ids'][0]
@@ -1261,9 +1264,11 @@ class PyModule(SphinxDirective):
option_spec: OptionSpec = {
'platform': lambda x: x,
'synopsis': lambda x: x,
'no-index': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
'deprecated': directives.flag,
}
@@ -1271,7 +1276,7 @@ class PyModule(SphinxDirective):
domain = cast(PythonDomain, self.env.get_domain('py'))
modname = self.arguments[0].strip()
noindex = 'noindex' in self.options
no_index = 'no-index' in self.options
self.env.ref_context['py:module'] = modname
content_node: Element = nodes.section()
@@ -1280,7 +1285,7 @@ class PyModule(SphinxDirective):
nested_parse_with_titles(self.state, self.content, content_node, self.content_offset)
ret: list[Node] = []
if not noindex:
if not no_index:
# note module to the domain
node_id = make_id(self.env, self.state.document, 'module', modname)
target = nodes.target('', '', ids=[node_id], ismod=True)
@@ -1508,7 +1513,7 @@ class PythonDomain(Domain):
else:
# duplicated
logger.warning(__('duplicate object description of %s, '
'other instance in %s, use :noindex: for one of them'),
'other instance in %s, use :no-index: for one of them'),
name, other.docname, location=location)
self.objects[name] = ObjectEntry(self.env.docname, node_id, objtype, aliased)

View File

@@ -34,10 +34,13 @@ class ReSTMarkup(ObjectDescription[str]):
Description of generic reST markup.
"""
option_spec: OptionSpec = {
'no-index': directives.flag,
'no-index-entry': directives.flag,
'no-contents-entry': directives.flag,
'no-typesetting': directives.flag,
'noindex': directives.flag,
'noindexentry': directives.flag,
'nocontentsentry': directives.flag,
'no-typesetting': directives.flag,
}
def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> None:
@@ -48,7 +51,7 @@ class ReSTMarkup(ObjectDescription[str]):
domain = cast(ReSTDomain, self.env.get_domain('rst'))
domain.note_object(self.objtype, name, node_id, location=signode)
if 'noindexentry' not in self.options:
if 'no-index-entry' not in self.options:
indextext = self.get_index_text(self.objtype, name)
if indextext:
self.indexnode['entries'].append(('single', indextext, node_id, '', None))

View File

@@ -118,9 +118,9 @@ class TocTreeCollector(EnvironmentCollector):
if not sig_node.get('_toc_name', ''):
continue
# Skip if explicitly disabled
if sig_node.parent.get('nocontentsentry'):
if sig_node.parent.get('no-contents-entry'):
continue
# Skip entries with no ID (e.g. with :noindex: set)
# Skip entries with no ID (e.g. with :no-index: set)
ids = sig_node['ids']
if not ids:
continue

View File

@@ -308,6 +308,7 @@ class Documenter:
titles_allowed = True
option_spec: OptionSpec = {
'no-index': bool_option,
'noindex': bool_option,
}
@@ -530,8 +531,8 @@ class Documenter:
if i == 0:
prefix = " " * len(prefix)
if self.options.noindex:
self.add_line(' :noindex:', sourcename)
if self.options.no_index or self.options.noindex:
self.add_line(' :no-index:', sourcename)
if self.objpath:
# Be explicit about the module, this is necessary since .. class::
# etc. don't support a prepended module name
@@ -953,13 +954,14 @@ class ModuleDocumenter(Documenter):
option_spec: OptionSpec = {
'members': members_option, 'undoc-members': bool_option,
'noindex': bool_option, 'inherited-members': inherited_members_option,
'no-index': bool_option, 'inherited-members': inherited_members_option,
'show-inheritance': bool_option, 'synopsis': identity,
'platform': identity, 'deprecated': bool_option,
'member-order': member_order_option, 'exclude-members': exclude_members_option,
'private-members': members_option, 'special-members': members_option,
'imported-members': bool_option, 'ignore-module-all': bool_option,
'no-value': bool_option,
'noindex': bool_option,
}
def __init__(self, *args: Any) -> None:
@@ -1425,11 +1427,12 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
member_order = 20
option_spec: OptionSpec = {
'members': members_option, 'undoc-members': bool_option,
'noindex': bool_option, 'inherited-members': inherited_members_option,
'no-index': bool_option, 'inherited-members': inherited_members_option,
'show-inheritance': bool_option, 'member-order': member_order_option,
'exclude-members': exclude_members_option,
'private-members': members_option, 'special-members': members_option,
'class-doc-from': class_doc_from_option,
'noindex': bool_option,
}
# Must be higher than FunctionDocumenter, ClassDocumenter, and

View File

@@ -367,7 +367,7 @@ def _process_docstring(app: Sphinx, what: str, name: str, obj: Any,
The object to which the docstring belongs.
options : sphinx.ext.autodoc.Options
The options given to the directive: an object with attributes
inherited_members, undoc_members, show_inheritance and noindex that
inherited_members, undoc_members, show_inheritance and no_index that
are True if the flag option of same name was given to the auto
directive.
lines : list of str
@@ -421,7 +421,7 @@ def _skip_member(app: Sphinx, what: str, name: str, obj: Any,
does not override the decision
options : sphinx.ext.autodoc.Options
The options given to the directive: an object with attributes
inherited_members, undoc_members, show_inheritance and noindex that
inherited_members, undoc_members, show_inheritance and no_index that
are True if the flag option of same name was given to the auto
directive.

View File

@@ -108,7 +108,7 @@ class GoogleDocstring:
The object to which the docstring belongs.
options : :class:`sphinx.ext.autodoc.Options`, optional
The options given to the directive: an object with attributes
inherited_members, undoc_members, show_inheritance and noindex that
inherited_members, undoc_members, show_inheritance and no_index that
are True if the flag option of same name was given to the auto
directive.
@@ -660,8 +660,9 @@ class GoogleDocstring:
lines.append(f':vartype {_name}: {_type}')
else:
lines.append('.. attribute:: ' + _name)
if self._opt and 'noindex' in self._opt:
lines.append(' :noindex:')
if self._opt:
if 'no-index' in self._opt or 'noindex' in self._opt:
lines.append(' :no-index:')
lines.append('')
fields = self._format_field('', '', _desc)
@@ -728,8 +729,9 @@ class GoogleDocstring:
lines: list[str] = []
for _name, _type, _desc in self._consume_fields(parse_type=False):
lines.append('.. method:: %s' % _name)
if self._opt and 'noindex' in self._opt:
lines.append(' :noindex:')
if self._opt:
if 'no-index' in self._opt or 'noindex' in self._opt:
lines.append(' :no-index:')
if _desc:
lines.extend([''] + self._indent(_desc, 3))
lines.append('')
@@ -1085,7 +1087,7 @@ class NumpyDocstring(GoogleDocstring):
The object to which the docstring belongs.
options : :class:`sphinx.ext.autodoc.Options`, optional
The options given to the directive: an object with attributes
inherited_members, undoc_members, show_inheritance and noindex that
inherited_members, undoc_members, show_inheritance and no_index that
are True if the flag option of same name was given to the auto
directive.

View File

@@ -72,8 +72,10 @@ def assert_node(node: Node, cls: Any = None, xpath: str = "", **kwargs: Any) ->
'The node%s does not have any attributes' % xpath
for key, value in kwargs.items():
assert key in node, \
f'The node{xpath} does not have {key!r} attribute: {node!r}'
if key not in node:
if (key := key.replace('_', '-')) not in node:
raise AssertionError(f'The node{xpath} does not have {key!r}'
f' attribute: {node!r}')
assert node[key] == value, \
f'The node{xpath}[{key}] is not {value!r}: {node[key]!r}'

View File

@@ -8,7 +8,7 @@ Testing object descriptions
.. function:: func_without_body()
.. function:: func_noindex
:noindex:
:no-index:
.. function:: func_with_module
:module: foolib

View File

@@ -176,7 +176,7 @@ The section with an object description
======================================
.. py:function:: dummy(N)
:noindex:
:no-index:
Footnotes referred twice
========================

View File

@@ -6,14 +6,14 @@ i18n with docfields
.. single TypedField
.. class:: Cls1
:noindex:
:no-index:
:param param: description of parameter param
.. grouped TypedFields
.. class:: Cls2
:noindex:
:no-index:
:param foo: description of parameter foo
:param bar: description of parameter bar
@@ -22,14 +22,14 @@ i18n with docfields
.. single GroupedField
.. class:: Cls3(values)
:noindex:
:no-index:
:raises ValueError: if the values are out of range
.. grouped GroupedFields
.. class:: Cls4(values)
:noindex:
:no-index:
:raises TypeError: if the values are not valid
:raises ValueError: if the values are out of range
@@ -38,7 +38,7 @@ i18n with docfields
.. single Field
.. class:: Cls5
:noindex:
:no-index:
:returns: a new :class:`Cls3` instance

View File

@@ -34,7 +34,7 @@ Testing object descriptions
:FIELd_name PARTial caps:
.. function:: func_noindex
:noindex:
:no-index:
.. function:: func_with_module
:module: foolib

View File

@@ -2,7 +2,7 @@ test-warnings
=============
.. automodule:: autodoc_fodder
:noindex:
:no-index:
.. autoclass:: MarkupError

View File

@@ -8,7 +8,7 @@ from sphinx.testing import restructuredtext
from sphinx.testing.util import assert_node
DOMAINS = [
# directive, noindex, noindexentry, signature of f, signature of g, index entry of g
# directive, no-index, no-index-entry, signature of f, signature of g, index entry of g
('c:function', False, True, 'void f()', 'void g()', ('single', 'g (C function)', 'c.g', '', None)),
('cpp:function', False, True, 'void f()', 'void g()', ('single', 'g (C++ function)', '_CPPv41gv', '', None)),
('js:function', True, True, 'f()', 'g()', ('single', 'g() (built-in function)', 'g', '', None)),
@@ -19,16 +19,16 @@ DOMAINS = [
]
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
text = (f'.. {directive}:: {sig_f}\n'
f' :no-typesetting:\n')
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, nodes.target))
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_twice(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_twice(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
text = (f'.. {directive}:: {sig_f}\n'
f' :no-typesetting:\n'
f'.. {directive}:: {sig_g}\n'
@@ -38,24 +38,24 @@ def test_object_description_no_typesetting_twice(app, directive, noindex, noinde
assert_node(doctree, (addnodes.index, addnodes.index, nodes.target, nodes.target))
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_noindex_orig(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
if not noindex:
pytest.skip(f'{directive} does not support :noindex: option')
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_noindex_orig(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
if not no_index:
pytest.skip(f'{directive} does not support :no-index: option')
text = (f'.. {directive}:: {sig_f}\n'
f' :noindex:\n'
f' :no-index:\n'
f'.. {directive}:: {sig_g}\n')
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, addnodes.desc, addnodes.index, addnodes.desc))
assert_node(doctree[2], addnodes.index, entries=[index_g])
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_noindex(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
if not noindex:
pytest.skip(f'{directive} does not support :noindex: option')
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_noindex(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
if not no_index:
pytest.skip(f'{directive} does not support :no-index: option')
text = (f'.. {directive}:: {sig_f}\n'
f' :noindex:\n'
f' :no-index:\n'
f' :no-typesetting:\n'
f'.. {directive}:: {sig_g}\n'
f' :no-typesetting:\n')
@@ -65,12 +65,12 @@ def test_object_description_no_typesetting_noindex(app, directive, noindex, noin
assert_node(doctree[1], addnodes.index, entries=[index_g])
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_noindexentry(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
if not noindexentry:
pytest.skip(f'{directive} does not support :noindexentry: option')
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_no_index_entry(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
if not no_index_entry:
pytest.skip(f'{directive} does not support :no-index-entry: option')
text = (f'.. {directive}:: {sig_f}\n'
f' :noindexentry:\n'
f' :no-index-entry:\n'
f' :no-typesetting:\n'
f'.. {directive}:: {sig_g}\n'
f' :no-typesetting:\n')
@@ -80,8 +80,8 @@ def test_object_description_no_typesetting_noindexentry(app, directive, noindex,
assert_node(doctree[1], addnodes.index, entries=[index_g])
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_code(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_code(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
text = (f'.. {directive}:: {sig_f}\n'
f' :no-typesetting:\n'
f'.. {directive}:: {sig_g}\n'
@@ -94,8 +94,8 @@ def test_object_description_no_typesetting_code(app, directive, noindex, noindex
assert_node(doctree, (addnodes.index, addnodes.index, nodes.target, nodes.target, nodes.literal_block))
@pytest.mark.parametrize(('directive', 'noindex', 'noindexentry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_heading(app, directive, noindex, noindexentry, sig_f, sig_g, index_g):
@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
def test_object_description_no_typesetting_heading(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
text = (f'.. {directive}:: {sig_f}\n'
f' :no-typesetting:\n'
f'.. {directive}:: {sig_g}\n'

View File

@@ -792,7 +792,7 @@ def test_domain_c_parse_cfunction(app):
"PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)")
doctree = restructuredtext.parse(app, text)
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
entry = _get_obj(app, 'PyType_GenericAlloc')
assert entry == ('index', 'c.PyType_GenericAlloc', 'function')
@@ -802,7 +802,7 @@ def test_domain_c_parse_cmember(app):
text = ".. c:member:: PyObject* PyTypeObject.tp_bases"
doctree = restructuredtext.parse(app, text)
assert_node(doctree[1], addnodes.desc, desctype="member",
domain="c", objtype="member", noindex=False)
domain="c", objtype="member", no_index=False)
entry = _get_obj(app, 'PyTypeObject.tp_bases')
assert entry == ('index', 'c.PyTypeObject.tp_bases', 'member')
@@ -812,16 +812,16 @@ def test_domain_c_parse_cvar(app):
text = ".. c:var:: PyObject* PyClass_Type"
doctree = restructuredtext.parse(app, text)
assert_node(doctree[1], addnodes.desc, desctype="var",
domain="c", objtype="var", noindex=False)
domain="c", objtype="var", no_index=False)
entry = _get_obj(app, 'PyClass_Type')
assert entry == ('index', 'c.PyClass_Type', 'member')
def test_domain_c_parse_noindexentry(app):
def test_domain_c_parse_no_index_entry(app):
text = (".. c:function:: void f()\n"
".. c:function:: void g()\n"
" :noindexentry:\n")
" :no-index-entry:\n")
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
assert_node(doctree[0], addnodes.index, entries=[('single', 'f (C function)', 'c.f', '', None)])
@@ -849,7 +849,7 @@ def test_cfunction_signature_with_c_maximum_signature_line_length_equal(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -880,7 +880,7 @@ def test_cfunction_signature_with_c_maximum_signature_line_length_force_single(a
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -910,7 +910,7 @@ def test_cfunction_signature_with_c_maximum_signature_line_length_break(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -940,7 +940,7 @@ def test_cfunction_signature_with_maximum_signature_line_length_equal(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -971,7 +971,7 @@ def test_cfunction_signature_with_maximum_signature_line_length_force_single(app
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -1001,7 +1001,7 @@ def test_cfunction_signature_with_maximum_signature_line_length_break(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="c", objtype="function", noindex=False)
domain="c", objtype="function", no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,
@@ -1032,7 +1032,7 @@ def test_c_maximum_signature_line_length_overrides_global(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='c', objtype='function', noindex=False)
domain='c', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, "str"]],
desc_sig_space,

View File

@@ -1425,10 +1425,10 @@ _var cpp:member 1 index.html#_CPPv44$ -
assert len(ws) == 0
def test_domain_cpp_parse_noindexentry(app):
def test_domain_cpp_parse_no_index_entry(app):
text = (".. cpp:function:: void f()\n"
".. cpp:function:: void g()\n"
" :noindexentry:\n")
" :no-index-entry:\n")
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
assert_node(doctree[0], addnodes.index, entries=[('single', 'f (C++ function)', '_CPPv41fv', '', None)])
@@ -1521,7 +1521,7 @@ def test_cpp_function_signature_with_cpp_maximum_signature_line_length_equal(app
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1552,7 +1552,7 @@ def test_cpp_function_signature_with_cpp_maximum_signature_line_length_force_sin
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1582,7 +1582,7 @@ def test_cpp_function_signature_with_cpp_maximum_signature_line_length_break(app
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1612,7 +1612,7 @@ def test_cpp_function_signature_with_maximum_signature_line_length_equal(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1643,7 +1643,7 @@ def test_cpp_function_signature_with_maximum_signature_line_length_force_single(
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1673,7 +1673,7 @@ def test_cpp_function_signature_with_maximum_signature_line_length_break(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,
@@ -1698,7 +1698,7 @@ def test_cpp_maximum_signature_line_length_overrides_global(app):
desc_content)],
))
assert_node(doctree[1], addnodes.desc, desctype='function',
domain='cpp', objtype='function', noindex=False)
domain='cpp', objtype='function', no_index=False)
assert_node(doctree[1][0][0][3], [desc_parameterlist, desc_parameter, (
[pending_xref, [desc_sig_name, 'str']],
desc_sig_space,

View File

@@ -195,7 +195,7 @@ def test_js_function(app):
[desc_parameter, ([desc_sig_name, "b"])])])
assert_node(doctree[0], addnodes.index,
entries=[("single", "sum() (built-in function)", "sum", "", None)])
assert_node(doctree[1], addnodes.desc, domain="js", objtype="function", noindex=False)
assert_node(doctree[1], addnodes.desc, domain="js", objtype="function", no_index=False)
def test_js_class(app):
@@ -209,7 +209,7 @@ def test_js_class(app):
[desc_content, ()])]))
assert_node(doctree[0], addnodes.index,
entries=[("single", "Application() (class)", "Application", "", None)])
assert_node(doctree[1], addnodes.desc, domain="js", objtype="class", noindex=False)
assert_node(doctree[1], addnodes.desc, domain="js", objtype="class", no_index=False)
def test_js_data(app):
@@ -220,13 +220,13 @@ def test_js_data(app):
[desc_content, ()])]))
assert_node(doctree[0], addnodes.index,
entries=[("single", "name (global variable or constant)", "name", "", None)])
assert_node(doctree[1], addnodes.desc, domain="js", objtype="data", noindex=False)
assert_node(doctree[1], addnodes.desc, domain="js", objtype="data", no_index=False)
def test_noindexentry(app):
def test_no_index_entry(app):
text = (".. js:function:: f()\n"
".. js:function:: g()\n"
" :noindexentry:\n")
" :no-index-entry:\n")
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
assert_node(doctree[0], addnodes.index, entries=[('single', 'f() (built-in function)', 'f', '', None)])
@@ -262,7 +262,7 @@ def test_jsfunction_signature_with_javascript_maximum_signature_line_length_equa
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "name"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=False)
@@ -286,7 +286,7 @@ def test_jsfunction_signature_with_javascript_maximum_signature_line_length_forc
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "names"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=False)
@@ -309,7 +309,7 @@ def test_jsfunction_signature_with_javascript_maximum_signature_line_length_brea
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "names"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=True)
@@ -332,7 +332,7 @@ def test_jsfunction_signature_with_maximum_signature_line_length_equal(app):
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "name"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=False)
@@ -356,7 +356,7 @@ def test_jsfunction_signature_with_maximum_signature_line_length_force_single(ap
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "names"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=False)
@@ -379,7 +379,7 @@ def test_jsfunction_signature_with_maximum_signature_line_length_break(app):
)],
))
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "names"])])
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=True)
@@ -401,7 +401,7 @@ def test_javascript_maximum_signature_line_length_overrides_global(app):
desc_content)])
assert_node(doctree, expected_doctree)
assert_node(doctree[1], desc, desctype="function",
domain="js", objtype="function", noindex=False)
domain="js", objtype="function", no_index=False)
expected_sig = [desc_parameterlist, desc_parameter, [desc_sig_name, "name"]]
assert_node(doctree[1][0][1], expected_sig)
assert_node(doctree[1][0][1], desc_parameterlist, multi_line_parameter_list=False)

View File

@@ -420,7 +420,7 @@ def test_pyfunction_signature(app):
[desc_returns, pending_xref, "str"])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, desc_parameter, ([desc_sig_name, "name"],
[desc_sig_punctuation, ":"],
@@ -438,7 +438,7 @@ def test_pyfunction_signature_full(app):
[desc_returns, pending_xref, "str"])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
[desc_parameterlist, ([desc_parameter, ([desc_sig_name, "a"],
[desc_sig_punctuation, ":"],
@@ -569,7 +569,7 @@ def test_optional_pyfunction_signature(app):
[desc_returns, pending_xref, "ast object"])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1],
([desc_parameter, ([desc_sig_name, "source"])],
[desc_optional, ([desc_parameter, ([desc_sig_name, "filename"])],
@@ -585,7 +585,7 @@ def test_pyexception_signature(app):
[desc_name, "IOError"])],
desc_content)]))
assert_node(doctree[1], desc, desctype="exception",
domain="py", objtype="exception", noindex=False)
domain="py", objtype="exception", no_index=False)
def test_pydata_signature(app):
@@ -606,7 +606,7 @@ def test_pydata_signature(app):
)],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="data",
domain="py", objtype="data", noindex=False)
domain="py", objtype="data", no_index=False)
def test_pydata_signature_old(app):
@@ -619,7 +619,7 @@ def test_pydata_signature_old(app):
"= 1")])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="data",
domain="py", objtype="data", noindex=False)
domain="py", objtype="data", no_index=False)
def test_pydata_with_union_type_operator(app):
@@ -959,7 +959,7 @@ def test_pydecorator_signature(app):
[desc_name, "deco"])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert 'deco' in domain.objects
assert domain.objects['deco'] == ('index', 'deco', 'function', False)
@@ -974,7 +974,7 @@ def test_pydecoratormethod_signature(app):
[desc_name, "deco"])],
desc_content)]))
assert_node(doctree[1], addnodes.desc, desctype="method",
domain="py", objtype="method", noindex=False)
domain="py", objtype="method", no_index=False)
assert 'deco' in domain.objects
assert domain.objects['deco'] == ('index', 'deco', 'method', False)
@@ -1401,10 +1401,10 @@ def test_modindex_common_prefix(app):
)
def test_noindexentry(app):
def test_no_index_entry(app):
text = (".. py:function:: f()\n"
".. py:function:: g()\n"
" :noindexentry:\n")
" :no-index-entry:\n")
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
assert_node(doctree[0], addnodes.index, entries=[('pair', 'built-in function; f()', 'f', '', None)])
@@ -1412,7 +1412,7 @@ def test_noindexentry(app):
text = (".. py:class:: f\n"
".. py:class:: g\n"
" :noindexentry:\n")
" :no-index-entry:\n")
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
assert_node(doctree[0], addnodes.index, entries=[('single', 'f (built-in class)', 'f', '', None)])
@@ -1456,7 +1456,7 @@ def test_warn_missing_reference(app, status, warning):
@pytest.mark.parametrize('include_options', (True, False))
def test_signature_line_number(app, include_options):
text = (".. py:function:: foo(bar : string)\n" +
(" :noindexentry:\n" if include_options else ""))
(" :no-index-entry:\n" if include_options else ""))
doc = restructuredtext.parse(app, text)
xrefs = list(doc.findall(condition=addnodes.pending_xref))
assert len(xrefs) == 1
@@ -1483,7 +1483,7 @@ def test_pyfunction_signature_with_python_maximum_signature_line_length_equal(ap
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "name"],
[desc_sig_punctuation, ":"],
@@ -1512,7 +1512,7 @@ def test_pyfunction_signature_with_python_maximum_signature_line_length_force_si
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "names"],
[desc_sig_punctuation, ":"],
@@ -1540,7 +1540,7 @@ def test_pyfunction_signature_with_python_maximum_signature_line_length_break(ap
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "names"],
[desc_sig_punctuation, ":"],
@@ -1568,7 +1568,7 @@ def test_pyfunction_signature_with_maximum_signature_line_length_equal(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "name"],
[desc_sig_punctuation, ":"],
@@ -1597,7 +1597,7 @@ def test_pyfunction_signature_with_maximum_signature_line_length_force_single(ap
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "names"],
[desc_sig_punctuation, ":"],
@@ -1625,7 +1625,7 @@ def test_pyfunction_signature_with_maximum_signature_line_length_break(app):
)],
))
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, (
[desc_sig_name, "names"],
[desc_sig_punctuation, ":"],
@@ -1652,7 +1652,7 @@ def test_python_maximum_signature_line_length_overrides_global(app):
desc_content)])
assert_node(doctree, expected_doctree)
assert_node(doctree[1], addnodes.desc, desctype="function",
domain="py", objtype="function", noindex=False)
domain="py", objtype="function", no_index=False)
signame_node = [desc_sig_name, "name"]
expected_sig = [desc_parameterlist, desc_parameter, (signame_node,
[desc_sig_punctuation, ":"],

View File

@@ -38,7 +38,7 @@ def test_rst_directive(app):
assert_node(doctree[0],
entries=[("single", "toctree (directive)", "directive-toctree", "", None)])
assert_node(doctree[1], addnodes.desc, desctype="directive",
domain="rst", objtype="directive", noindex=False)
domain="rst", objtype="directive", no_index=False)
# decorated
text = ".. rst:directive:: .. toctree::"
@@ -49,7 +49,7 @@ def test_rst_directive(app):
assert_node(doctree[0],
entries=[("single", "toctree (directive)", "directive-toctree", "", None)])
assert_node(doctree[1], addnodes.desc, desctype="directive",
domain="rst", objtype="directive", noindex=False)
domain="rst", objtype="directive", no_index=False)
def test_rst_directive_with_argument(app):
@@ -62,7 +62,7 @@ def test_rst_directive_with_argument(app):
assert_node(doctree[0],
entries=[("single", "toctree (directive)", "directive-toctree", "", None)])
assert_node(doctree[1], addnodes.desc, desctype="directive",
domain="rst", objtype="directive", noindex=False)
domain="rst", objtype="directive", no_index=False)
def test_rst_directive_option(app):
@@ -75,7 +75,7 @@ def test_rst_directive_option(app):
entries=[("single", ":foo: (directive option)",
"directive-option-foo", "", "F")])
assert_node(doctree[1], addnodes.desc, desctype="directive:option",
domain="rst", objtype="directive:option", noindex=False)
domain="rst", objtype="directive:option", no_index=False)
def test_rst_directive_option_with_argument(app):
@@ -89,7 +89,7 @@ def test_rst_directive_option_with_argument(app):
entries=[("single", ":foo: (directive option)",
"directive-option-foo", "", "F")])
assert_node(doctree[1], addnodes.desc, desctype="directive:option",
domain="rst", objtype="directive:option", noindex=False)
domain="rst", objtype="directive:option", no_index=False)
def test_rst_directive_option_type(app):
@@ -104,7 +104,7 @@ def test_rst_directive_option_type(app):
entries=[("single", ":foo: (directive option)",
"directive-option-foo", "", "F")])
assert_node(doctree[1], addnodes.desc, desctype="directive:option",
domain="rst", objtype="directive:option", noindex=False)
domain="rst", objtype="directive:option", no_index=False)
def test_rst_directive_and_directive_option(app):
@@ -122,7 +122,7 @@ def test_rst_directive_and_directive_option(app):
assert_node(doctree[1][1][1], ([desc_signature, desc_name, ":bar:"],
[desc_content, ()]))
assert_node(doctree[1][1][1], addnodes.desc, desctype="directive:option",
domain="rst", objtype="directive:option", noindex=False)
domain="rst", objtype="directive:option", no_index=False)
def test_rst_role(app):
@@ -134,4 +134,4 @@ def test_rst_role(app):
assert_node(doctree[0],
entries=[("single", "ref (role)", "role-ref", "", None)])
assert_node(doctree[1], addnodes.desc, desctype="role",
domain="rst", objtype="role", noindex=False)
domain="rst", objtype="role", no_index=False)

View File

@@ -48,7 +48,7 @@ def make_directive_bridge(env):
special_members = False,
imported_members = False,
show_inheritance = False,
noindex = False,
no_index = False,
annotation = None,
synopsis = '',
platform = '',
@@ -925,22 +925,22 @@ def test_autodoc_ignore_module_all(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_noindex(app):
options = {"noindex": None}
options = {"no-index": None}
actual = do_autodoc(app, 'module', 'target', options)
assert list(actual) == [
'',
'.. py:module:: target',
' :noindex:',
' :no-index:',
'',
]
# TODO: :noindex: should be propagated to children of target item.
# TODO: :no-index: should be propagated to children of target item.
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(actual) == [
'',
'.. py:class:: Base()',
' :noindex:',
' :no-index:',
' :module: target.inheritance',
'',
]

View File

@@ -1162,19 +1162,19 @@ Methods:
expected = """
.. attribute:: arg
:noindex:
:no-index:
description
.. method:: func(i, j)
:noindex:
:no-index:
description
""" # noqa: W293
config = Config()
actual = str(GoogleDocstring(docstring, config=config, app=None, what='module',
options={'noindex': True}))
options={'no-index': True}))
assert expected == actual
def test_keywords_with_types(self):