mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: Rename find_source_node() to get_node_source()
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -17,6 +17,7 @@ Deprecated
|
|||||||
* ``sphinx.ext.autodoc.importer.MockLoader``
|
* ``sphinx.ext.autodoc.importer.MockLoader``
|
||||||
* ``sphinx.ext.autodoc.importer.mock()``
|
* ``sphinx.ext.autodoc.importer.mock()``
|
||||||
* ``sphinx.ext.autosummary.autolink_role()``
|
* ``sphinx.ext.autosummary.autolink_role()``
|
||||||
|
* ``sphinx.util.node.find_source_node()``
|
||||||
* ``sphinx.util.i18n.find_catalog()``
|
* ``sphinx.util.i18n.find_catalog()``
|
||||||
* ``sphinx.util.i18n.find_catalog_files()``
|
* ``sphinx.util.i18n.find_catalog_files()``
|
||||||
* ``sphinx.util.i18n.find_catalog_source_files()``
|
* ``sphinx.util.i18n.find_catalog_source_files()``
|
||||||
|
|||||||
@@ -254,6 +254,11 @@ The following is a list of deprecated interfaces.
|
|||||||
- 4.0
|
- 4.0
|
||||||
- ``sphinx.ext.autosummary.AutoLink``
|
- ``sphinx.ext.autosummary.AutoLink``
|
||||||
|
|
||||||
|
* - ``sphinx.util.node.find_source_node()``
|
||||||
|
- 2.1
|
||||||
|
- 4.0
|
||||||
|
- ``sphinx.util.node.get_node_source()``
|
||||||
|
|
||||||
* - ``sphinx.util.i18n.find_catalog()``
|
* - ``sphinx.util.i18n.find_catalog()``
|
||||||
- 2.1
|
- 2.1
|
||||||
- 4.0
|
- 4.0
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import warnings
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.deprecation import RemovedInSphinx40Warning
|
||||||
from sphinx.locale import __
|
from sphinx.locale import __
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
|
|
||||||
@@ -152,7 +154,7 @@ def apply_source_workaround(node):
|
|||||||
|
|
||||||
# workaround: literal_block under bullet list (#4913)
|
# workaround: literal_block under bullet list (#4913)
|
||||||
if isinstance(node, nodes.literal_block) and node.source is None:
|
if isinstance(node, nodes.literal_block) and node.source is None:
|
||||||
node.source = find_source_node(node)
|
node.source = get_node_source(node)
|
||||||
|
|
||||||
# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
|
# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
|
||||||
if not node.rawsource:
|
if not node.rawsource:
|
||||||
@@ -170,7 +172,7 @@ def apply_source_workaround(node):
|
|||||||
))):
|
))):
|
||||||
logger.debug('[i18n] PATCH: %r to have source and line: %s',
|
logger.debug('[i18n] PATCH: %r to have source and line: %s',
|
||||||
get_full_module_name(node), repr_domxml(node))
|
get_full_module_name(node), repr_domxml(node))
|
||||||
node.source = find_source_node(node)
|
node.source = get_node_source(node)
|
||||||
node.line = 0 # need fix docutils to get `node.line`
|
node.line = 0 # need fix docutils to get `node.line`
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -278,6 +280,13 @@ def extract_messages(doctree):
|
|||||||
|
|
||||||
|
|
||||||
def find_source_node(node):
|
def find_source_node(node):
|
||||||
|
# type: (nodes.Element) -> str
|
||||||
|
warnings.warn('find_source_node() is deprecated.',
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
return get_node_source(node)
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_source(node):
|
||||||
# type: (nodes.Element) -> str
|
# type: (nodes.Element) -> str
|
||||||
for pnode in traverse_parent(node):
|
for pnode in traverse_parent(node):
|
||||||
if pnode.source:
|
if pnode.source:
|
||||||
|
|||||||
Reference in New Issue
Block a user