Skip to content

Commit b0d1739

Browse files
authored
Merge branch 'master' into autosummary-short-signature
2 parents 04a1afb + 3bc10dd commit b0d1739

File tree

14 files changed

+158
-40
lines changed

14 files changed

+158
-40
lines changed

CHANGES.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Deprecated
3131
Features added
3232
--------------
3333

34-
* Add a new ``duplicate_declaration`` warning type,
34+
* #13173: Add a new ``duplicate_declaration`` warning type,
3535
with ``duplicate_declaration.c`` and ``duplicate_declaration.cpp`` subtypes.
3636
Patch by Julien Lecomte and Adam Turner.
3737
* #11824: linkcode: Allow extensions to add support for a domain by defining
@@ -46,9 +46,9 @@ Features added
4646
Patch by Adam Turner.
4747
* #13065: Enable colour by default in when running on CI.
4848
Patch by Adam Turner.
49-
* Allow supressing warnings from the :rst:dir:`toctree` directive when a glob
50-
pattern doesn't match any documents, via the new ``toc.empty_glob``
51-
warning sub-type.
49+
* #13230: Allow supressing warnings from the :rst:dir:`toctree` directive
50+
when a glob pattern doesn't match any documents,
51+
via the new ``toc.empty_glob`` warning sub-type.
5252
Patch by Slawek Figiel.
5353
* #9732: Add the new ``autodoc.mocked_object`` warnings sub-type.
5454
Patch by Cyril Roelandt.
@@ -73,6 +73,13 @@ Features added
7373
* #9732: Add the new ``ref.any`` warnings sub-type
7474
to allow suppressing the ambiguous 'any' cross-reference warning.
7575
Patch by Simão Afonso and Adam Turner.
76+
* #13272: The Python and JavaScript module directives now support
77+
the ``:no-index-entry:`` option.
78+
Patch by Adam Turner.
79+
* #12233: autodoc: Allow directives to use ``:no-index-entry:``
80+
and include the ``:no-index:`` and ``:no-index-entry:`` options within
81+
:confval:`autodoc_default_options`.
82+
Patch by Jonny Saunders and Adam Turner.
7683
* #13172: Add support for short signatures in autosummary.
7784
Patch by Tim Hoffmann
7885

@@ -86,8 +93,7 @@ Bugs fixed
8693
* #13130: LaTeX docs: ``pdflatex`` index creation may fail for index entries
8794
in French. See :confval:`latex_use_xindy`.
8895
Patch by Jean-François B.
89-
* LaTeX: fix a ``7.4.0`` typo in a default for ``\sphinxboxsetup``
90-
(refs: PR #13152).
96+
* #13152: LaTeX: fix a typo from v7.4.0 in a default for ``\sphinxboxsetup``.
9197
Patch by Jean-François B.
9298
* #13096: HTML Search: check that query terms exist as properties in
9399
term indices before accessing them.

doc/usage/domains/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ the content should be the description.
4848

4949
A domain will typically keep an internal index of all entities to aid
5050
cross-referencing.
51-
Typically it will also add entries in the shown general index.
51+
Typically, it will also add entries in the shown general index.
5252
If you want to suppress the addition of an entry in the shown index, you can
5353
give the directive option flag ``:no-index-entry:``.
5454
If you want to exclude the object description from the table of contents, you

doc/usage/extensions/autodoc.rst

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,15 @@ Automatically document modules
326326
327327
.. versionadded:: 0.4
328328
329+
.. rst:directive:option:: no-index-entry
330+
:type:
331+
332+
Do not generate an index entry for the documented module
333+
or any auto-documented members.
334+
Unlike ``:no-index:``, cross-references are still created.
335+
336+
.. versionadded:: 8.2
337+
329338
.. rst:directive:option:: platform: platforms
330339
:type: comma separated list
331340
@@ -578,6 +587,15 @@ Automatically document classes or exceptions
578587
579588
.. versionadded:: 0.4
580589
590+
.. rst:directive:option:: no-index-entry
591+
:type:
592+
593+
Do not generate an index entry for the documented class
594+
or any auto-documented members.
595+
Unlike ``:no-index:``, cross-references are still created.
596+
597+
.. versionadded:: 8.2
598+
581599
.. rst:directive:option:: class-doc-from
582600
:type: class, init, or both
583601
@@ -854,6 +872,14 @@ Automatically document function-like objects
854872
855873
.. versionadded:: 0.4
856874
875+
.. rst:directive:option:: no-index-entry
876+
:type:
877+
878+
Do not generate an index entry for the documented function.
879+
Unlike ``:no-index:``, cross-references are still created.
880+
881+
.. versionadded:: 8.2
882+
857883
858884
Automatically document attributes or data
859885
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -900,11 +926,18 @@ Automatically document attributes or data
900926
.. rst:directive:option:: no-index
901927
:type:
902928
903-
Do not generate an index entry for the documented class
904-
or any auto-documented members.
929+
Do not generate an index entry for the documented variable or constant.
905930
906931
.. versionadded:: 0.4
907932
933+
.. rst:directive:option:: no-index-entry
934+
:type:
935+
936+
Do not generate an index entry for the documented variable or constant.
937+
Unlike ``:no-index:``, cross-references are still created.
938+
939+
.. versionadded:: 8.2
940+
908941
.. rst:directive:option:: annotation: value
909942
:type: string
910943
@@ -1039,6 +1072,8 @@ There are also config values that you can set:
10391072
* ``'show-inheritance'``: See :rst:dir:`autoclass:show-inheritance`.
10401073
* ``'class-doc-from'``: See :rst:dir:`autoclass:class-doc-from`.
10411074
* ``'no-value'``: See :rst:dir:`autodata:no-value`.
1075+
* ``'no-index'``: See :rst:dir:`automodule:no-index`.
1076+
* ``'no-index-entry'``: See :rst:dir:`automodule:no-index-entry`.
10421077

10431078
.. versionadded:: 1.8
10441079

doc/usage/referencing.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ The following role creates a cross-reference to a term in a
254254
If you use a term that's not explained in a glossary, you'll get a warning
255255
during build.
256256

257+
This role also supports :ref:`custom link text <xref-modifiers>` from the general
258+
cross-reference syntax.
259+
257260

258261
.. _any-role:
259262

sphinx/domains/javascript.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]:
155155
def add_target_and_index(
156156
self, name_obj: tuple[str, str], sig: str, signode: desc_signature
157157
) -> None:
158-
mod_name = self.env.ref_context.get('js:module')
159-
fullname = (mod_name + '.' if mod_name else '') + name_obj[0]
158+
mod_name = self.env.ref_context.get('js:module', '')
159+
fullname = (f'{mod_name}.' if mod_name else '') + name_obj[0]
160160
node_id = make_id(self.env, self.state.document, '', fullname)
161161
signode['ids'].append(node_id)
162162
self.state.document.note_explicit_target(signode)
@@ -165,11 +165,10 @@ def add_target_and_index(
165165
domain.note_object(fullname, self.objtype, node_id, location=signode)
166166

167167
if 'no-index-entry' not in self.options:
168-
indextext = self.get_index_text(mod_name, name_obj) # type: ignore[arg-type]
169-
if indextext:
168+
if index_text := self.get_index_text(mod_name, name_obj):
170169
self.indexnode['entries'].append((
171170
'single',
172-
indextext,
171+
index_text,
173172
node_id,
174173
'',
175174
None,
@@ -333,6 +332,7 @@ class JSModule(SphinxDirective):
333332
final_argument_whitespace = False
334333
option_spec: ClassVar[OptionSpec] = {
335334
'no-index': directives.flag,
335+
'no-index-entry': directives.flag,
336336
'no-contents-entry': directives.flag,
337337
'no-typesetting': directives.flag,
338338
'noindex': directives.flag,
@@ -365,9 +365,12 @@ def run(self) -> list[Node]:
365365
)
366366

367367
# The node order is: index node first, then target node
368-
indextext = _('%s (module)') % mod_name
369-
inode = addnodes.index(entries=[('single', indextext, node_id, '', None)])
370-
ret.append(inode)
368+
if 'no-index-entry' not in self.options:
369+
index_text = _('%s (module)') % mod_name
370+
inode = addnodes.index(
371+
entries=[('single', index_text, node_id, '', None)]
372+
)
373+
ret.append(inode)
371374
target = nodes.target('', '', ids=[node_id], ismod=True)
372375
self.state.document.note_explicit_target(target)
373376
ret.append(target)

sphinx/domains/python/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ class PyModule(SphinxDirective):
479479
'platform': lambda x: x,
480480
'synopsis': lambda x: x,
481481
'no-index': directives.flag,
482+
'no-index-entry': directives.flag,
482483
'no-contents-entry': directives.flag,
483484
'no-typesetting': directives.flag,
484485
'noindex': directives.flag,
@@ -520,10 +521,15 @@ def run(self) -> list[Node]:
520521

521522
# the platform and synopsis aren't printed; in fact, they are only
522523
# used in the modindex currently
523-
indextext = f'module; {modname}'
524-
inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)])
525-
# The node order is: index node first, then target node.
526-
ret.extend((inode, target))
524+
525+
if 'no-index-entry' not in self.options:
526+
index_text = f'module; {modname}'
527+
inode = addnodes.index(
528+
entries=[('pair', index_text, node_id, '', None)]
529+
)
530+
# The node order is: index node first, then target node.
531+
ret.append(inode)
532+
ret.append(target)
527533
ret.extend(content_nodes)
528534
return ret
529535

sphinx/domains/python/_object.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ def get_index_text(self, modname: str, name: tuple[str, str]) -> str:
409409
def add_target_and_index(
410410
self, name_cls: tuple[str, str], sig: str, signode: desc_signature
411411
) -> None:
412-
modname = self.options.get('module', self.env.ref_context.get('py:module'))
413-
fullname = (f'{modname}.' if modname else '') + name_cls[0]
412+
mod_name = self.options.get('module', self.env.ref_context.get('py:module'))
413+
fullname = (f'{mod_name}.' if mod_name else '') + name_cls[0]
414414
node_id = make_id(self.env, self.state.document, '', fullname)
415415
signode['ids'].append(node_id)
416416
self.state.document.note_explicit_target(signode)
@@ -425,11 +425,10 @@ def add_target_and_index(
425425
)
426426

427427
if 'no-index-entry' not in self.options:
428-
indextext = self.get_index_text(modname, name_cls)
429-
if indextext:
428+
if index_text := self.get_index_text(mod_name, name_cls):
430429
self.indexnode['entries'].append((
431430
'single',
432-
indextext,
431+
index_text,
433432
node_id,
434433
'',
435434
None,

sphinx/domains/rst.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ def add_target_and_index(
5757
domain.note_object(self.objtype, name, node_id, location=signode)
5858

5959
if 'no-index-entry' not in self.options:
60-
indextext = self.get_index_text(self.objtype, name)
61-
if indextext:
60+
if index_text := self.get_index_text(self.objtype, name):
6261
self.indexnode['entries'].append((
6362
'single',
64-
indextext,
63+
index_text,
6564
node_id,
6665
'',
6766
None,

sphinx/ext/autodoc/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ class Documenter:
365365

366366
option_spec: ClassVar[OptionSpec] = {
367367
'no-index': bool_option,
368+
'no-index-entry': bool_option,
368369
'noindex': bool_option,
369370
}
370371

@@ -605,6 +606,8 @@ def add_directive_header(self, sig: str) -> None:
605606

606607
if self.options.no_index or self.options.noindex:
607608
self.add_line(' :no-index:', sourcename)
609+
if self.options.no_index_entry:
610+
self.add_line(' :no-index-entry:', sourcename)
608611
if self.objpath:
609612
# Be explicit about the module, this is necessary since .. class::
610613
# etc. don't support a prepended module name
@@ -1110,6 +1113,7 @@ class ModuleDocumenter(Documenter):
11101113
'members': members_option,
11111114
'undoc-members': bool_option,
11121115
'no-index': bool_option,
1116+
'no-index-entry': bool_option,
11131117
'inherited-members': inherited_members_option,
11141118
'show-inheritance': bool_option,
11151119
'synopsis': identity,
@@ -1197,6 +1201,8 @@ def add_directive_header(self, sig: str) -> None:
11971201
self.add_line(' :platform: ' + self.options.platform, sourcename)
11981202
if self.options.deprecated:
11991203
self.add_line(' :deprecated:', sourcename)
1204+
if self.options.no_index_entry:
1205+
self.add_line(' :no-index-entry:', sourcename)
12001206

12011207
def get_module_members(self) -> dict[str, ObjectMember]:
12021208
"""Get members of target module."""
@@ -1625,6 +1631,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
16251631
'members': members_option,
16261632
'undoc-members': bool_option,
16271633
'no-index': bool_option,
1634+
'no-index-entry': bool_option,
16281635
'inherited-members': inherited_members_option,
16291636
'show-inheritance': bool_option,
16301637
'member-order': member_order_option,

sphinx/ext/autodoc/directive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
AUTODOC_DEFAULT_OPTIONS = [
3131
'members',
3232
'undoc-members',
33+
'no-index',
34+
'no-index-entry',
3335
'inherited-members',
3436
'show-inheritance',
3537
'private-members',

0 commit comments

Comments
 (0)