Implement :no-index-entry: for autodoc (#12233)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
Jonny Saunders
2025-01-27 18:01:31 -08:00
committed by GitHub
parent 7801540c08
commit 18bb8bcef5
5 changed files with 79 additions and 2 deletions

View File

@@ -3180,3 +3180,32 @@ def test_literal_render(app):
*function_rst('bar', 'x: typing.Literal[1234]'),
*function_rst('foo', 'x: typing.Literal[target.literal.MyEnum.a]'),
]
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_no_index_entry(app):
# modules can use no-index-entry
options = {'no-index-entry': None}
actual = do_autodoc(app, 'module', 'target.module', options)
assert ' :no-index-entry:' in list(actual)
# classes can use no-index-entry
actual = do_autodoc(app, 'class', 'target.classes.Foo', options)
assert ' :no-index-entry:' in list(actual)
# functions can use no-index-entry
actual = do_autodoc(app, 'function', 'target.functions.func', options)
assert ' :no-index-entry:' in list(actual)
# modules respect no-index-entry in autodoc_default_options
app.config.autodoc_default_options = {'no-index-entry': True}
actual = do_autodoc(app, 'module', 'target.module')
assert ' :no-index-entry:' in list(actual)
# classes respect config-level no-index-entry
actual = do_autodoc(app, 'class', 'target.classes.Foo')
assert ' :no-index-entry:' in list(actual)
# functions respect config-level no-index-entry
actual = do_autodoc(app, 'function', 'target.functions.func')
assert ' :no-index-entry:' in list(actual)