mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Handle exceptions for `get_node_source and get_node_line`
This commit is contained in:
@@ -509,7 +509,10 @@ class HyperlinkCollector(SphinxPostTransform):
|
||||
if newuri:
|
||||
uri = newuri
|
||||
|
||||
lineno = get_node_line(node)
|
||||
try:
|
||||
lineno = get_node_line(node)
|
||||
except ValueError:
|
||||
lineno = None
|
||||
uri_info = Hyperlink(uri, self.env.docname, lineno)
|
||||
if uri not in hyperlinks:
|
||||
hyperlinks[uri] = uri_info
|
||||
|
||||
@@ -172,7 +172,10 @@ def apply_source_workaround(node: Element) -> None:
|
||||
))):
|
||||
logger.debug('[i18n] PATCH: %r to have source and line: %s',
|
||||
get_full_module_name(node), repr_domxml(node))
|
||||
node.source = get_node_source(node) or ''
|
||||
try:
|
||||
node.source = get_node_source(node)
|
||||
except ValueError:
|
||||
node.source = ''
|
||||
node.line = 0 # need fix docutils to get `node.line`
|
||||
return
|
||||
|
||||
@@ -561,8 +564,9 @@ def set_role_source_info(inliner: Inliner, lineno: int, node: Node) -> None:
|
||||
|
||||
|
||||
def copy_source_info(src: Element, dst: Element) -> None:
|
||||
dst.source = get_node_source(src)
|
||||
dst.line = get_node_line(src)
|
||||
with contextlib.suppress(ValueError):
|
||||
dst.source = get_node_source(src)
|
||||
dst.line = get_node_line(src)
|
||||
|
||||
|
||||
NON_SMARTQUOTABLE_PARENT_NODES = (
|
||||
|
||||
Reference in New Issue
Block a user