mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use keyword-arguments with `IndexEntry
`
This commit is contained in:
parent
bd7d595c6b
commit
8682f64b6f
@ -594,19 +594,42 @@ class PythonModuleIndex(Index):
|
|||||||
# first submodule - make parent a group head
|
# first submodule - make parent a group head
|
||||||
if entries:
|
if entries:
|
||||||
last = entries[-1]
|
last = entries[-1]
|
||||||
entries[-1] = IndexEntry(last[0], 1, last[2], last[3],
|
entries[-1] = IndexEntry(
|
||||||
last[4], last[5], last[6])
|
name=last.name,
|
||||||
|
subtype=1,
|
||||||
|
docname=last.docname,
|
||||||
|
anchor=last.anchor,
|
||||||
|
extra=last.extra,
|
||||||
|
qualifier=last.qualifier,
|
||||||
|
descr=last.descr,
|
||||||
|
)
|
||||||
elif not prev_modname.startswith(package):
|
elif not prev_modname.startswith(package):
|
||||||
# submodule without parent in list, add dummy entry
|
# submodule without parent in list, add dummy entry
|
||||||
entries.append(IndexEntry(stripped + package, 1, '', '', '', '', ''))
|
dummy_entry = IndexEntry(
|
||||||
|
name=stripped + package,
|
||||||
|
subtype=1,
|
||||||
|
docname='',
|
||||||
|
anchor='',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
)
|
||||||
|
entries.append(dummy_entry)
|
||||||
subtype = 2
|
subtype = 2
|
||||||
else:
|
else:
|
||||||
num_toplevels += 1
|
num_toplevels += 1
|
||||||
subtype = 0
|
subtype = 0
|
||||||
|
|
||||||
qualifier = _('Deprecated') if deprecated else ''
|
entry = IndexEntry(
|
||||||
entries.append(IndexEntry(stripped + modname, subtype, docname,
|
name=stripped + modname,
|
||||||
node_id, platforms, qualifier, synopsis))
|
subtype=subtype,
|
||||||
|
docname=module.docname,
|
||||||
|
anchor=module.node_id,
|
||||||
|
extra=module.platform,
|
||||||
|
qualifier=_('Deprecated') if module.deprecated else '',
|
||||||
|
descr=module.synopsis,
|
||||||
|
)
|
||||||
|
entries.append(entry)
|
||||||
prev_modname = modname
|
prev_modname = modname
|
||||||
|
|
||||||
# apply heuristics when to collapse modindex at page load:
|
# apply heuristics when to collapse modindex at page load:
|
||||||
|
@ -572,34 +572,67 @@ def test_module_index(app):
|
|||||||
index = PythonModuleIndex(app.env.domains.python_domain)
|
index = PythonModuleIndex(app.env.domains.python_domain)
|
||||||
assert index.generate() == (
|
assert index.generate() == (
|
||||||
[
|
[
|
||||||
('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]),
|
(
|
||||||
|
'd',
|
||||||
|
[
|
||||||
|
IndexEntry(
|
||||||
|
name='docutils',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-docutils',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
's',
|
's',
|
||||||
[
|
[
|
||||||
IndexEntry('sphinx', 1, 'index', 'module-sphinx', '', '', ''),
|
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.builders',
|
name='sphinx',
|
||||||
2,
|
subtype=1,
|
||||||
'index',
|
docname='index',
|
||||||
'module-sphinx.builders',
|
anchor='module-sphinx',
|
||||||
'',
|
extra='',
|
||||||
'',
|
qualifier='',
|
||||||
'',
|
descr='',
|
||||||
),
|
),
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.builders.html',
|
name='sphinx.builders',
|
||||||
2,
|
subtype=2,
|
||||||
'index',
|
docname='index',
|
||||||
'module-sphinx.builders.html',
|
anchor='module-sphinx.builders',
|
||||||
'',
|
extra='',
|
||||||
'',
|
qualifier='',
|
||||||
'',
|
descr='',
|
||||||
),
|
),
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.config', 2, 'index', 'module-sphinx.config', '', '', ''
|
name='sphinx.builders.html',
|
||||||
|
subtype=2,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx.builders.html',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
),
|
),
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx_intl', 0, 'index', 'module-sphinx_intl', '', '', ''
|
name='sphinx.config',
|
||||||
|
subtype=2,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx.config',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
IndexEntry(
|
||||||
|
name='sphinx_intl',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx_intl',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -618,9 +651,23 @@ def test_module_index_submodule(app):
|
|||||||
(
|
(
|
||||||
's',
|
's',
|
||||||
[
|
[
|
||||||
IndexEntry('sphinx', 1, '', '', '', '', ''),
|
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.config', 2, 'index', 'module-sphinx.config', '', '', ''
|
name='sphinx',
|
||||||
|
subtype=1,
|
||||||
|
docname='',
|
||||||
|
anchor='',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
IndexEntry(
|
||||||
|
name='sphinx.config',
|
||||||
|
subtype=2,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx.config',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -636,8 +683,34 @@ def test_module_index_not_collapsed(app):
|
|||||||
index = PythonModuleIndex(app.env.domains.python_domain)
|
index = PythonModuleIndex(app.env.domains.python_domain)
|
||||||
assert index.generate() == (
|
assert index.generate() == (
|
||||||
[
|
[
|
||||||
('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]),
|
(
|
||||||
('s', [IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', '')]),
|
'd',
|
||||||
|
[
|
||||||
|
IndexEntry(
|
||||||
|
name='docutils',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-docutils',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
's',
|
||||||
|
[
|
||||||
|
IndexEntry(
|
||||||
|
name='sphinx',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
@ -666,22 +739,22 @@ def test_modindex_common_prefix(app):
|
|||||||
'b',
|
'b',
|
||||||
[
|
[
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.builders',
|
name='sphinx.builders',
|
||||||
1,
|
subtype=1,
|
||||||
'index',
|
docname='index',
|
||||||
'module-sphinx.builders',
|
anchor='module-sphinx.builders',
|
||||||
'',
|
extra='',
|
||||||
'',
|
qualifier='',
|
||||||
'',
|
descr='',
|
||||||
),
|
),
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.builders.html',
|
name='sphinx.builders.html',
|
||||||
2,
|
subtype=2,
|
||||||
'index',
|
docname='index',
|
||||||
'module-sphinx.builders.html',
|
anchor='module-sphinx.builders.html',
|
||||||
'',
|
extra='',
|
||||||
'',
|
qualifier='',
|
||||||
'',
|
descr='',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -689,17 +762,50 @@ def test_modindex_common_prefix(app):
|
|||||||
'c',
|
'c',
|
||||||
[
|
[
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx.config', 0, 'index', 'module-sphinx.config', '', '', ''
|
name='sphinx.config',
|
||||||
)
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx.config',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'd',
|
||||||
|
[
|
||||||
|
IndexEntry(
|
||||||
|
name='docutils',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-docutils',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]),
|
|
||||||
(
|
(
|
||||||
's',
|
's',
|
||||||
[
|
[
|
||||||
IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', ''),
|
|
||||||
IndexEntry(
|
IndexEntry(
|
||||||
'sphinx_intl', 0, 'index', 'module-sphinx_intl', '', '', ''
|
name='sphinx',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
|
),
|
||||||
|
IndexEntry(
|
||||||
|
name='sphinx_intl',
|
||||||
|
subtype=0,
|
||||||
|
docname='index',
|
||||||
|
anchor='module-sphinx_intl',
|
||||||
|
extra='',
|
||||||
|
qualifier='',
|
||||||
|
descr='',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user