mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C, flake and mypy fixes, rename attr in desc_signature_line
This commit is contained in:
parent
7a29b63421
commit
6ec42b071e
2
CHANGES
2
CHANGES
@ -40,6 +40,8 @@ Incompatible changes
|
|||||||
functions and methods
|
functions and methods
|
||||||
* The C domain has been rewritten, with additional directives and roles.
|
* The C domain has been rewritten, with additional directives and roles.
|
||||||
The existing ones are now more strict, resulting in new warnings.
|
The existing ones are now more strict, resulting in new warnings.
|
||||||
|
* The attribute ``sphinx_cpp_tagname`` in the ``desc_signature_line`` node
|
||||||
|
has been renamed to ``sphinx_line_type``.
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
@ -119,7 +119,7 @@ class desc_signature_line(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
|||||||
It should only be used in a ``desc_signature`` with ``is_multiline`` set.
|
It should only be used in a ``desc_signature`` with ``is_multiline`` set.
|
||||||
Set ``add_permalink = True`` for the line that should get the permalink.
|
Set ``add_permalink = True`` for the line that should get the permalink.
|
||||||
"""
|
"""
|
||||||
sphinx_cpp_tagname = ''
|
sphinx_line_type = ''
|
||||||
|
|
||||||
|
|
||||||
# nodes to use within a desc_signature or desc_signature_line
|
# nodes to use within a desc_signature or desc_signature_line
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Iterator, List, Tuple, Type, Union
|
Any, Callable, Dict, Iterator, List, Type, Tuple, Union
|
||||||
)
|
)
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
@ -25,7 +25,6 @@ from sphinx.builders import Builder
|
|||||||
from sphinx.directives import ObjectDescription
|
from sphinx.directives import ObjectDescription
|
||||||
from sphinx.domains import Domain, ObjType
|
from sphinx.domains import Domain, ObjType
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.errors import NoUri
|
|
||||||
from sphinx.locale import _, __
|
from sphinx.locale import _, __
|
||||||
from sphinx.roles import XRefRole
|
from sphinx.roles import XRefRole
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
@ -1220,7 +1219,7 @@ class ASTDeclaration(ASTBase):
|
|||||||
signode['is_multiline'] = True
|
signode['is_multiline'] = True
|
||||||
# Put each line in a desc_signature_line node.
|
# Put each line in a desc_signature_line node.
|
||||||
mainDeclNode = addnodes.desc_signature_line()
|
mainDeclNode = addnodes.desc_signature_line()
|
||||||
mainDeclNode.sphinx_c_tagname = 'declarator'
|
mainDeclNode.sphinx_line_type = 'declarator'
|
||||||
mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
|
mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
|
||||||
signode += mainDeclNode
|
signode += mainDeclNode
|
||||||
|
|
||||||
|
@ -9,9 +9,8 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import warnings
|
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Type, TypeVar, Union
|
Any, Callable, Dict, Iterator, List, Tuple, Type, TypeVar, Union
|
||||||
)
|
)
|
||||||
|
|
||||||
from docutils import nodes, utils
|
from docutils import nodes, utils
|
||||||
@ -24,7 +23,6 @@ from sphinx.addnodes import desc_signature, pending_xref
|
|||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.builders import Builder
|
from sphinx.builders import Builder
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
from sphinx.deprecation import RemovedInSphinx40Warning
|
|
||||||
from sphinx.directives import ObjectDescription
|
from sphinx.directives import ObjectDescription
|
||||||
from sphinx.domains import Domain, ObjType
|
from sphinx.domains import Domain, ObjType
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
@ -70,7 +68,7 @@ T = TypeVar('T')
|
|||||||
|
|
||||||
Each signature is in a desc_signature node, where all children are
|
Each signature is in a desc_signature node, where all children are
|
||||||
desc_signature_line nodes. Each of these lines will have the attribute
|
desc_signature_line nodes. Each of these lines will have the attribute
|
||||||
'sphinx_cpp_tagname' set to one of the following (prioritized):
|
'sphinx_line_type' set to one of the following (prioritized):
|
||||||
- 'declarator', if the line contains the name of the declared object.
|
- 'declarator', if the line contains the name of the declared object.
|
||||||
- 'templateParams', if the line starts a template parameter list,
|
- 'templateParams', if the line starts a template parameter list,
|
||||||
- 'templateParams', if the line has template parameters
|
- 'templateParams', if the line has template parameters
|
||||||
@ -1604,7 +1602,7 @@ class ASTTemplateParams(ASTBase):
|
|||||||
def makeLine(parentNode: desc_signature = parentNode) -> addnodes.desc_signature_line:
|
def makeLine(parentNode: desc_signature = parentNode) -> addnodes.desc_signature_line:
|
||||||
signode = addnodes.desc_signature_line()
|
signode = addnodes.desc_signature_line()
|
||||||
parentNode += signode
|
parentNode += signode
|
||||||
signode.sphinx_cpp_tagname = 'templateParams'
|
signode.sphinx_line_type = 'templateParams'
|
||||||
return signode
|
return signode
|
||||||
if self.isNested:
|
if self.isNested:
|
||||||
lineNode = parentNode # type: Element
|
lineNode = parentNode # type: Element
|
||||||
@ -1713,7 +1711,7 @@ class ASTTemplateIntroduction(ASTBase):
|
|||||||
# Note: 'lineSpec' has no effect on template introductions.
|
# Note: 'lineSpec' has no effect on template introductions.
|
||||||
signode = addnodes.desc_signature_line()
|
signode = addnodes.desc_signature_line()
|
||||||
parentNode += signode
|
parentNode += signode
|
||||||
signode.sphinx_cpp_tagname = 'templateIntroduction'
|
signode.sphinx_line_type = 'templateIntroduction'
|
||||||
self.concept.describe_signature(signode, 'markType', env, symbol)
|
self.concept.describe_signature(signode, 'markType', env, symbol)
|
||||||
signode += nodes.Text('{')
|
signode += nodes.Text('{')
|
||||||
first = True
|
first = True
|
||||||
@ -3416,7 +3414,7 @@ class ASTDeclaration(ASTBase):
|
|||||||
signode['is_multiline'] = True
|
signode['is_multiline'] = True
|
||||||
# Put each line in a desc_signature_line node.
|
# Put each line in a desc_signature_line node.
|
||||||
mainDeclNode = addnodes.desc_signature_line()
|
mainDeclNode = addnodes.desc_signature_line()
|
||||||
mainDeclNode.sphinx_cpp_tagname = 'declarator'
|
mainDeclNode.sphinx_line_type = 'declarator'
|
||||||
mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
|
mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
|
||||||
|
|
||||||
if self.templatePrefix:
|
if self.templatePrefix:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
sphinx.util.cfamily
|
sphinx.util.cfamily
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Utility functions common to the C and C++ domains.
|
Utility functions common to the C and C++ domains.
|
||||||
|
|
||||||
:copyright: Copyright 2020-2020 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ import re
|
|||||||
import warnings
|
import warnings
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Type, TypeVar, Union
|
Any, Callable, List, Match, Pattern, Tuple
|
||||||
)
|
)
|
||||||
|
|
||||||
from sphinx.deprecation import RemovedInSphinx40Warning
|
from sphinx.deprecation import RemovedInSphinx40Warning
|
||||||
@ -244,4 +244,4 @@ class BaseParser:
|
|||||||
def assert_end(self) -> None:
|
def assert_end(self) -> None:
|
||||||
self.skip_ws()
|
self.skip_ws()
|
||||||
if not self.eof:
|
if not self.eof:
|
||||||
self.fail('Expected end of definition.')
|
self.fail('Expected end of definition.')
|
||||||
|
Loading…
Reference in New Issue
Block a user