mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Migrate to py3 style type annotation: sphinx.ext.linkcode
This commit is contained in:
parent
4ba8518117
commit
eb07a0fee1
@ -8,25 +8,23 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from typing import Any, Dict, Set
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
from docutils.nodes import Node
|
||||||
|
|
||||||
import sphinx
|
import sphinx
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.application import Sphinx
|
||||||
from sphinx.errors import SphinxError
|
from sphinx.errors import SphinxError
|
||||||
from sphinx.locale import _
|
from sphinx.locale import _
|
||||||
|
|
||||||
if False:
|
|
||||||
# For type annotation
|
|
||||||
from typing import Any, Dict, Set # NOQA
|
|
||||||
from sphinx.application import Sphinx # NOQA
|
|
||||||
|
|
||||||
|
|
||||||
class LinkcodeError(SphinxError):
|
class LinkcodeError(SphinxError):
|
||||||
category = "linkcode error"
|
category = "linkcode error"
|
||||||
|
|
||||||
|
|
||||||
def doctree_read(app, doctree):
|
def doctree_read(app: Sphinx, doctree: Node) -> None:
|
||||||
# type: (Sphinx, nodes.Node) -> None
|
|
||||||
env = app.builder.env
|
env = app.builder.env
|
||||||
|
|
||||||
resolve_target = getattr(env.config, 'linkcode_resolve', None)
|
resolve_target = getattr(env.config, 'linkcode_resolve', None)
|
||||||
@ -75,8 +73,7 @@ def doctree_read(app, doctree):
|
|||||||
signode += onlynode
|
signode += onlynode
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app: Sphinx) -> Dict[str, Any]:
|
||||||
# type: (Sphinx) -> Dict[str, Any]
|
|
||||||
app.connect('doctree-read', doctree_read)
|
app.connect('doctree-read', doctree_read)
|
||||||
app.add_config_value('linkcode_resolve', None, '')
|
app.add_config_value('linkcode_resolve', None, '')
|
||||||
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
Loading…
Reference in New Issue
Block a user