{"action":"created","issue":{"url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2456","repository_url":"https://api.github.com/repos/sphinx-doc/sphinx","labels_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2456/labels{/name}","comments_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2456/comments","events_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2456/events","html_url":"https://github.com/sphinx-doc/sphinx/issues/2456","id":148911654,"number":2456,"title":"Reference target not found with C++ namespaces in Latex builder","user":{"login":"djungelorm","id":6644613,"avatar_url":"https://avatars.githubusercontent.com/u/6644613?v=3","gravatar_id":"","url":"https://api.github.com/users/djungelorm","html_url":"https://github.com/djungelorm","followers_url":"https://api.github.com/users/djungelorm/followers","following_url":"https://api.github.com/users/djungelorm/following{/other_user}","gists_url":"https://api.github.com/users/djungelorm/gists{/gist_id}","starred_url":"https://api.github.com/users/djungelorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djungelorm/subscriptions","organizations_url":"https://api.github.com/users/djungelorm/orgs","repos_url":"https://api.github.com/users/djungelorm/repos","events_url":"https://api.github.com/users/djungelorm/events{/privacy}","received_events_url":"https://api.github.com/users/djungelorm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-17T02:36:21Z","updated_at":"2016-04-17T09:12:56Z","closed_at":null,"body":"In Sphinx 1.4.1, referencing a C++ class without prefixing it with its namespace works fine with the html builder, but fails with the latex builder. This works fine in Sphinx 1.3.6 -- the latex builder behaves exactly like the html builder, generating a correct reference.\r\n\r\n**Example**\r\nsrc/contents.rst\r\n```\r\n.. cpp:namespace:: my_namespace\r\n\r\n.. cpp:class:: MyClass\r\n\r\n:cpp:class:`MyClass`\r\n:cpp:class:`my_namespace::MyClass`\r\n```\r\n\r\n**Output from latex builder in Sphinx 1.4.1**\r\n```\r\n$ sphinx-build -b latex -n src out\r\nRunning Sphinx v1.4.1\r\nmaking output directory...\r\nloading pickled environment... not yet created\r\nbuilding [mo]: targets for 0 po files that are out of date\r\nbuilding [latex]: all documents\r\nupdating environment: 1 added, 0 changed, 0 removed\r\nreading sources... [100%] contents                                                                                                                                                                                 \r\nlooking for now-outdated files... none found\r\npickling environment... done\r\nchecking consistency... done\r\nprocessing Python.tex... contents \r\nresolving references...\r\n/home/alex/workspaces/ksp/sphinx-bug/src/contents.rst:5: WARNING: cpp:class reference target not found: MyClass\r\nwriting... done\r\ncopying TeX support files...\r\ndone\r\nbuild succeeded, 1 warning.\r\n```\r\n\r\n**Output from html builder in Sphinx 1.4.1**\r\n```\r\n$ sphinx-build -b html -n src out\r\nRunning Sphinx v1.4.1\r\nmaking output directory...\r\nloading pickled environment... not yet created\r\nbuilding [mo]: targets for 0 po files that are out of date\r\nbuilding [html]: targets for 1 source files that are out of date\r\nupdating environment: 1 added, 0 changed, 0 removed\r\nreading sources... [100%] contents                                                                                                                                                                                 \r\nlooking for now-outdated files... none found\r\npickling environment... done\r\nchecking consistency... done\r\npreparing documents... done\r\nwriting output... [100%] contents                                                                                                                                                                                  \r\ngenerating indices... genindex\r\nwriting additional pages... search\r\ncopying static files... done\r\ncopying extra files... done\r\ndumping search index in English (code: en) ... done\r\ndumping object inventory... done\r\nbuild succeeded.\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/comments/210983773","html_url":"https://github.com/sphinx-doc/sphinx/issues/2456#issuecomment-210983773","issue_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2456","id":210983773,"user":{"login":"tk0miya","id":748828,"avatar_url":"https://avatars.githubusercontent.com/u/748828?v=3","gravatar_id":"","url":"https://api.github.com/users/tk0miya","html_url":"https://github.com/tk0miya","followers_url":"https://api.github.com/users/tk0miya/followers","following_url":"https://api.github.com/users/tk0miya/following{/other_user}","gists_url":"https://api.github.com/users/tk0miya/gists{/gist_id}","starred_url":"https://api.github.com/users/tk0miya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tk0miya/subscriptions","organizations_url":"https://api.github.com/users/tk0miya/orgs","repos_url":"https://api.github.com/users/tk0miya/repos","events_url":"https://api.github.com/users/tk0miya/events{/privacy}","received_events_url":"https://api.github.com/users/tk0miya/received_events","type":"User","site_admin":false},"created_at":"2016-04-17T09:12:56Z","updated_at":"2016-04-17T09:12:56Z","body":"It comes from behavior of `docutils.nodes.Element.copy()`. It converts the attribute name lower case. The conversion causes the cpp domain lose sight of namespaces in spite of it still exists.\r\n\r\nAs a workaround, the following code works fine. (I know it's ugly)\r\n```\r\ndiff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py\r\nindex 6847d5a..3febf69 100644\r\n--- a/sphinx/domains/cpp.py\r\n+++ b/sphinx/domains/cpp.py\r\n@@ -4102,7 +4102,7 @@ class CPPDomain(Domain):\r\n             warner.warn('Unparseable C++ cross-reference: %r\\n%s'\r\n                         % (target, str(e.description)))\r\n             return None, None\r\n-        parentKey = node.get(\"cpp:parentKey\", None)\r\n+        parentKey = node.get(\"cpp:parentKey\") or node.get(\"cpp:parentkey\")\r\n         rootSymbol = self.data['rootSymbol']\r\n         if parentKey:\r\n             parentSymbol = rootSymbol.direct_lookup(parentKey)\r\n```"}}