mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Move sphinx.directives.other:Index to sphinx.domains.index
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -11,6 +11,7 @@ Deprecated
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
* The ``decode`` argument of ``sphinx.pycode.ModuleAnalyzer()``
|
* The ``decode`` argument of ``sphinx.pycode.ModuleAnalyzer()``
|
||||||
|
* ``sphinx.directives.other.Index``
|
||||||
* ``sphinx.environment.BuildEnvironment.indexentries``
|
* ``sphinx.environment.BuildEnvironment.indexentries``
|
||||||
* ``sphinx.environment.collectors.indexentries.IndexEntriesCollector``
|
* ``sphinx.environment.collectors.indexentries.IndexEntriesCollector``
|
||||||
* ``sphinx.io.FiletypeNotFoundError``
|
* ``sphinx.io.FiletypeNotFoundError``
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ The following is a list of deprecated interfaces.
|
|||||||
- 4.0
|
- 4.0
|
||||||
- N/A
|
- N/A
|
||||||
|
|
||||||
|
* - ``sphinx.directives.other.Index``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- ``sphinx.domains.index.IndexDirective``
|
||||||
|
|
||||||
* - ``sphinx.environment.BuildEnvironment.indexentries``
|
* - ``sphinx.environment.BuildEnvironment.indexentries``
|
||||||
- 2.4
|
- 2.4
|
||||||
- 4.0
|
- 4.0
|
||||||
|
|||||||
@@ -253,12 +253,13 @@ from sphinx.directives.code import ( # noqa
|
|||||||
Highlight, CodeBlock, LiteralInclude
|
Highlight, CodeBlock, LiteralInclude
|
||||||
)
|
)
|
||||||
from sphinx.directives.other import ( # noqa
|
from sphinx.directives.other import ( # noqa
|
||||||
TocTree, Author, Index, VersionChange, SeeAlso,
|
TocTree, Author, VersionChange, SeeAlso,
|
||||||
TabularColumns, Centered, Acks, HList, Only, Include, Class
|
TabularColumns, Centered, Acks, HList, Only, Include, Class
|
||||||
)
|
)
|
||||||
from sphinx.directives.patches import ( # noqa
|
from sphinx.directives.patches import ( # noqa
|
||||||
Figure, Meta
|
Figure, Meta
|
||||||
)
|
)
|
||||||
|
from sphinx.domains.index import IndexDirective # noqa
|
||||||
|
|
||||||
deprecated_alias('sphinx.directives',
|
deprecated_alias('sphinx.directives',
|
||||||
{
|
{
|
||||||
@@ -267,7 +268,7 @@ deprecated_alias('sphinx.directives',
|
|||||||
'LiteralInclude': LiteralInclude,
|
'LiteralInclude': LiteralInclude,
|
||||||
'TocTree': TocTree,
|
'TocTree': TocTree,
|
||||||
'Author': Author,
|
'Author': Author,
|
||||||
'Index': Index,
|
'Index': IndexDirective,
|
||||||
'VersionChange': VersionChange,
|
'VersionChange': VersionChange,
|
||||||
'SeeAlso': SeeAlso,
|
'SeeAlso': SeeAlso,
|
||||||
'TabularColumns': TabularColumns,
|
'TabularColumns': TabularColumns,
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ from docutils.parsers.rst.directives.misc import Class
|
|||||||
from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
|
||||||
from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
|
from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
|
||||||
from sphinx.locale import _
|
from sphinx.locale import _
|
||||||
from sphinx.util import url_re, docname_join
|
from sphinx.util import url_re, docname_join
|
||||||
from sphinx.util.docutils import SphinxDirective
|
from sphinx.util.docutils import SphinxDirective
|
||||||
from sphinx.util.matching import Matcher, patfilter
|
from sphinx.util.matching import Matcher, patfilter
|
||||||
from sphinx.util.nodes import explicit_title_re, process_index_entry
|
from sphinx.util.nodes import explicit_title_re
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@@ -182,30 +183,6 @@ class Author(SphinxDirective):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class Index(SphinxDirective):
|
|
||||||
"""
|
|
||||||
Directive to add entries to the index.
|
|
||||||
"""
|
|
||||||
has_content = False
|
|
||||||
required_arguments = 1
|
|
||||||
optional_arguments = 0
|
|
||||||
final_argument_whitespace = True
|
|
||||||
option_spec = {} # type: Dict
|
|
||||||
|
|
||||||
def run(self) -> List[Node]:
|
|
||||||
arguments = self.arguments[0].split('\n')
|
|
||||||
targetid = 'index-%s' % self.env.new_serialno('index')
|
|
||||||
targetnode = nodes.target('', '', ids=[targetid])
|
|
||||||
self.state.document.note_explicit_target(targetnode)
|
|
||||||
indexnode = addnodes.index()
|
|
||||||
indexnode['entries'] = []
|
|
||||||
indexnode['inline'] = False
|
|
||||||
self.set_source_info(indexnode)
|
|
||||||
for entry in arguments:
|
|
||||||
indexnode['entries'].extend(process_index_entry(entry, targetid))
|
|
||||||
return [indexnode, targetnode]
|
|
||||||
|
|
||||||
|
|
||||||
class SeeAlso(BaseAdmonition):
|
class SeeAlso(BaseAdmonition):
|
||||||
"""
|
"""
|
||||||
An admonition mentioning things to look at as reference.
|
An admonition mentioning things to look at as reference.
|
||||||
@@ -383,12 +360,21 @@ class Include(BaseInclude, SphinxDirective):
|
|||||||
return super().run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
|
# Import old modules here for compatibility
|
||||||
|
from sphinx.domains.index import IndexDirective # NOQA
|
||||||
|
|
||||||
|
deprecated_alias('sphinx.directives.other',
|
||||||
|
{
|
||||||
|
'Index': IndexDirective,
|
||||||
|
},
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
|
||||||
|
|
||||||
def setup(app: "Sphinx") -> Dict[str, Any]:
|
def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||||
directives.register_directive('toctree', TocTree)
|
directives.register_directive('toctree', TocTree)
|
||||||
directives.register_directive('sectionauthor', Author)
|
directives.register_directive('sectionauthor', Author)
|
||||||
directives.register_directive('moduleauthor', Author)
|
directives.register_directive('moduleauthor', Author)
|
||||||
directives.register_directive('codeauthor', Author)
|
directives.register_directive('codeauthor', Author)
|
||||||
directives.register_directive('index', Index)
|
|
||||||
directives.register_directive('seealso', SeeAlso)
|
directives.register_directive('seealso', SeeAlso)
|
||||||
directives.register_directive('tabularcolumns', TabularColumns)
|
directives.register_directive('tabularcolumns', TabularColumns)
|
||||||
directives.register_directive('centered', Centered)
|
directives.register_directive('centered', Centered)
|
||||||
|
|||||||
@@ -10,14 +10,20 @@
|
|||||||
|
|
||||||
from typing import Any, Dict, Iterable, List, Tuple
|
from typing import Any, Dict, Iterable, List, Tuple
|
||||||
|
|
||||||
|
from docutils import nodes
|
||||||
from docutils.nodes import Node
|
from docutils.nodes import Node
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.application import Sphinx
|
|
||||||
from sphinx.domains import Domain
|
from sphinx.domains import Domain
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
from sphinx.util import split_index_msg
|
from sphinx.util import split_index_msg
|
||||||
|
from sphinx.util.docutils import SphinxDirective
|
||||||
|
from sphinx.util.nodes import process_index_entry
|
||||||
|
|
||||||
|
if False:
|
||||||
|
# For type annotation
|
||||||
|
from sphinx.application import Sphinx
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -54,8 +60,33 @@ class IndexDomain(Domain):
|
|||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
|
|
||||||
|
|
||||||
def setup(app: Sphinx) -> Dict[str, Any]:
|
class IndexDirective(SphinxDirective):
|
||||||
|
"""
|
||||||
|
Directive to add entries to the index.
|
||||||
|
"""
|
||||||
|
has_content = False
|
||||||
|
required_arguments = 1
|
||||||
|
optional_arguments = 0
|
||||||
|
final_argument_whitespace = True
|
||||||
|
option_spec = {} # type: Dict
|
||||||
|
|
||||||
|
def run(self) -> List[Node]:
|
||||||
|
arguments = self.arguments[0].split('\n')
|
||||||
|
targetid = 'index-%s' % self.env.new_serialno('index')
|
||||||
|
targetnode = nodes.target('', '', ids=[targetid])
|
||||||
|
self.state.document.note_explicit_target(targetnode)
|
||||||
|
indexnode = addnodes.index()
|
||||||
|
indexnode['entries'] = []
|
||||||
|
indexnode['inline'] = False
|
||||||
|
self.set_source_info(indexnode)
|
||||||
|
for entry in arguments:
|
||||||
|
indexnode['entries'].extend(process_index_entry(entry, targetid))
|
||||||
|
return [indexnode, targetnode]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||||
app.add_domain(IndexDomain)
|
app.add_domain(IndexDomain)
|
||||||
|
app.add_directive('index', IndexDirective)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'version': 'builtin',
|
'version': 'builtin',
|
||||||
|
|||||||
Reference in New Issue
Block a user