#302: Fix links generated by the `:doc:` role for LaTeX output.

For that, record the source docname in an xfileref node in node['refdoc'].
The LaTeX builder creates one big toctree out of all documents, therefore
"fromdocname" in resolve_references refers to the wrong file.
This commit is contained in:
Georg Brandl 2010-01-03 16:03:08 +01:00
parent 276fc659b0
commit 9d15d3f654
3 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,8 @@
Release 0.6.4 (in development)
==============================
* #302: Fix links generated by the ``:doc:`` role for LaTeX output.
* #286: collect todo nodes after the whole document has been read;
this allows placing substitution references in todo items.

View File

@ -53,7 +53,7 @@ default_settings = {
# This is increased every time an environment attribute is added
# or changed to properly invalidate pickle files.
ENV_VERSION = 30
ENV_VERSION = 31
default_substitutions = set([
@ -1177,7 +1177,7 @@ class BuildEnvironment:
docname, labelid = self.anonlabels.get(target, ('',''))
sectname = node.astext()
if not docname:
self.warn(fromdocname, 'undefined label: %s' %
self.warn(node['refdoc'], 'undefined label: %s' %
target, node.line)
else:
# reference to the named label; the final node will
@ -1186,7 +1186,7 @@ class BuildEnvironment:
('','',''))
if not docname:
self.warn(
fromdocname,
node['refdoc'],
'undefined label: %s' % target + ' -- if you '
'don\'t give a link caption the label must '
'precede a section header.', node.line)
@ -1212,10 +1212,10 @@ class BuildEnvironment:
elif typ == 'doc':
# directly reference to document by source name;
# can be absolute or relative
docname = docname_join(fromdocname, target)
docname = docname_join(node['refdoc'], target)
if docname not in self.all_docs:
self.warn(fromdocname, 'unknown document: %s' % docname,
node.line)
self.warn(node['refdoc'],
'unknown document: %s' % docname, node.line)
newnode = contnode
else:
if node['refcaption']:
@ -1232,7 +1232,7 @@ class BuildEnvironment:
# keywords are referenced by named labels
docname, labelid, _ = self.labels.get(target, ('','',''))
if not docname:
#self.warn(fromdocname, 'unknown keyword: %s' % target)
#self.warn(node['refdoc'], 'unknown keyword: %s' % target)
newnode = contnode
else:
newnode = nodes.reference('', '')
@ -1261,11 +1261,11 @@ class BuildEnvironment:
('', ''))
if not docname:
if typ == 'term':
self.warn(fromdocname,
self.warn(node['refdoc'],
'term not in glossary: %s' % target,
node.line)
elif typ == 'citation':
self.warn(fromdocname,
self.warn(node['refdoc'],
'citation not found: %s' % target,
node.line)
newnode = contnode

View File

@ -203,6 +203,7 @@ def xfileref_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
else:
# remove all whitespace to avoid referencing problems
target = ws_re.sub('', target)
pnode['refdoc'] = env.docname
pnode['reftarget'] = target
pnode += innernodetypes.get(typ, nodes.literal)(rawtext, title,
classes=['xref'])