Commit 454f96f2 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet

docs: automarkup.py: ignore exceptions when seeking for xrefs

When using the automarkup extension with:
	make pdfdocs

without passing an specific book, the code will raise an exception:

	  File "/devel/v4l/docs/Documentation/sphinx/automarkup.py", line 86, in auto_markup
	    node.parent.replace(node, markup_funcs(name, app, node))
	  File "/devel/v4l/docs/Documentation/sphinx/automarkup.py", line 59, in markup_funcs
	    'function', target, pxref, lit_text)
	  File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/domains/c.py", line 308, in resolve_xref
	    contnode, target)
	  File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/util/nodes.py", line 450, in make_refnode
	    '#' + targetid)
	  File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/builders/latex/__init__.py", line 159, in get_relative_uri
	    return self.get_target_uri(to, typ)
	  File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/builders/latex/__init__.py", line 152, in get_target_uri
	    raise NoUri
	sphinx.environment.NoUri

This happens because not all references will belong to a single
PDF/LaTeX document.

Better to just ignore those than breaking Sphinx build.

Fixes: d74b0d31 ("Docs: An initial automarkup extension for sphinx")
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
[jc: Narrowed the "except" and tweaked the comment]
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 66f2a122
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# #
from docutils import nodes from docutils import nodes
from sphinx import addnodes from sphinx import addnodes
from sphinx.environment import NoUri
import re import re
# #
...@@ -55,8 +56,15 @@ def markup_funcs(docname, app, node): ...@@ -55,8 +56,15 @@ def markup_funcs(docname, app, node):
reftype = 'function', reftype = 'function',
reftarget = target, modname = None, reftarget = target, modname = None,
classname = None) classname = None)
xref = cdom.resolve_xref(app.env, docname, app.builder, #
'function', target, pxref, lit_text) # XXX The Latex builder will throw NoUri exceptions here,
# work around that by ignoring them.
#
try:
xref = cdom.resolve_xref(app.env, docname, app.builder,
'function', target, pxref, lit_text)
except NoUri:
xref = None
# #
# Toss the xref into the list if we got it; otherwise just put # Toss the xref into the list if we got it; otherwise just put
# the function text. # the function text.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment