Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bogus warnings for "citation not referenced" for cross-file citations #3874

Closed
Jellby opened this issue Jun 18, 2017 · 6 comments
Closed

Bogus warnings for "citation not referenced" for cross-file citations #3874

Jellby opened this issue Jun 18, 2017 · 6 comments

Comments

@Jellby
Copy link
Contributor

Jellby commented Jun 18, 2017

Problem

Citations, either in the standard [foo]_ and .. [foo] Bar form or with the sphinxcontrib.bibtex extension, produce "WARNING: Citation [foo] is not referenced." whenever the citation and the reference are in different files.

This was fixed in #3633, but only for well-behaved labels (where label = id), then 2f61be8 was supposed to fix that but caused this bug (regression). See #3633 (comment).

Procedure to reproduce the problem

A simple sphinx project with one file containing

[foo]_

and another one containing:

.. [foo] Bar

(plus the minimal toctree, titles, etc.)

Environment info

  • OS: Kubuntu 14.04
  • Python version: 2.7.6
  • Sphinx version: Built from 6fe4e70 (which was stable at the time)
@jschueller
Copy link
Contributor

jschueller commented Jun 18, 2017

Note that this is independent of sphinxcontrib.bibtex : I dont use it but I got the same error here with current master:

reading sources... [100%] user_manual/user_manual                                                                                                                                               
looking for now-outdated files... none found
pickling environment... done
checking consistency... 
Warning, treated as error:
[...] bibliography.rst:6:Citation [Au2001] is not referenced.

Your patch makes the error go away:

diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 26645eed..93ca2536 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -590,7 +590,7 @@ class StandardDomain(Domain):
         # type: (BuildEnvironment, unicode, nodes.Node) -> None
         for name, refs in iteritems(document.citation_refs):
             for ref in refs:
-                labelid = ref.get('refid')
+                labelid = ref.get('refid') or nodes.make_id(ref.get('refname'))
                 if labelid:
                     citation_refs = self.data['citation_refs'].setdefault(labelid, [])
                     citation_refs.append(docname)

@tk0miya
Copy link
Member

tk0miya commented Jun 24, 2017

Fixed at 69b090f again.
Could you check this please?

@tk0miya tk0miya closed this as completed Jun 24, 2017
@tk0miya tk0miya added this to the 1.6.3 milestone Jun 24, 2017
@Jellby
Copy link
Contributor Author

Jellby commented Jun 24, 2017

It seems to work, thank you!

@jschueller
Copy link
Contributor

@tk0miya could this land into master please ?

@tk0miya
Copy link
Member

tk0miya commented Jun 24, 2017

@jschueller merged now :-)

@jschueller
Copy link
Contributor

Thanks.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants