summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sphinx/domains/cpp.py14
-rw-r--r--tests/roots/test-ext-intersphinx-cppdomain/conf.py4
-rw-r--r--tests/roots/test-ext-intersphinx-cppdomain/index.rst6
-rw-r--r--tests/test_domain_cpp.py2
-rw-r--r--tests/test_ext_intersphinx.py20
-rw-r--r--tests/test_util_inventory.py2
6 files changed, 48 insertions, 0 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 2fceeded3..b1e83a041 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -5032,6 +5032,20 @@ class CPPDomain(Domain):
newestId = symbol.declaration.get_newest_id()
yield (name, name, objectType, docname, newestId, 1)
+ def get_full_qualified_name(self, node):
+ # type: (nodes.Node) -> unicode
+ target = node.get('reftarget', None)
+ if target is None:
+ return None
+ parentKey = node.get("cpp:parent_key", None)
+ if parentKey is None:
+ return None
+
+ rootSymbol = self.data['root_symbol']
+ parentSymbol = rootSymbol.direct_lookup(parentKey)
+ parentName = parentSymbol.get_full_nested_name()
+ return '::'.join([text_type(parentName), target])
+
def setup(app):
# type: (Sphinx) -> Dict[unicode, Any]
diff --git a/tests/roots/test-ext-intersphinx-cppdomain/conf.py b/tests/roots/test-ext-intersphinx-cppdomain/conf.py
new file mode 100644
index 000000000..cbc4a8f43
--- /dev/null
+++ b/tests/roots/test-ext-intersphinx-cppdomain/conf.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+
+extensions = ['sphinx.ext.intersphinx']
+master_doc = 'index'
diff --git a/tests/roots/test-ext-intersphinx-cppdomain/index.rst b/tests/roots/test-ext-intersphinx-cppdomain/index.rst
new file mode 100644
index 000000000..b5397f856
--- /dev/null
+++ b/tests/roots/test-ext-intersphinx-cppdomain/index.rst
@@ -0,0 +1,6 @@
+test-ext-intersphinx-cppdomain
+==============================
+
+.. cpp:namespace:: foo
+
+:cpp:class:`Bar`
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 49d8e3206..3b2b3ba10 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -13,6 +13,8 @@ import re
from six import text_type
import pytest
+from mock import Mock
+from docutils import nodes
from sphinx import addnodes
from sphinx.domains.cpp import DefinitionParser, DefinitionError, NoOldIdError
diff --git a/tests/test_ext_intersphinx.py b/tests/test_ext_intersphinx.py
index 4774604e8..47f2029dc 100644
--- a/tests/test_ext_intersphinx.py
+++ b/tests/test_ext_intersphinx.py
@@ -212,6 +212,26 @@ def test_missing_reference_stddomain(tempdir, app, status, warning):
assert rn.astext() == 'ls -l'
+@pytest.mark.sphinx('html', testroot='ext-intersphinx-cppdomain')
+def test_missing_reference_cppdomain(tempdir, app, status, warning):
+ inv_file = tempdir / 'inventory'
+ inv_file.write_bytes(inventory_v2)
+ app.config.intersphinx_mapping = {
+ 'https://docs.python.org/': inv_file,
+ }
+ app.config.intersphinx_cache_limit = 0
+
+ # load the inventory and check if it's done correctly
+ load_mappings(app)
+
+ app.build()
+ html = (app.outdir / 'index.html').text()
+ assert ('<a class="reference external"'
+ ' href="https://docs.python.org/index.html#cpp_foo_bar"'
+ ' title="(in foo v2.0)"><code class="xref cpp cpp-class docutils literal">'
+ '<span class="pre">Bar</span></code></a>' in html)
+
+
def test_missing_reference_jsdomain(tempdir, app, status, warning):
inv_file = tempdir / 'inventory'
inv_file.write_bytes(inventory_v2)
diff --git a/tests/test_util_inventory.py b/tests/test_util_inventory.py
index 35f80d960..ecd2be1a6 100644
--- a/tests/test_util_inventory.py
+++ b/tests/test_util_inventory.py
@@ -34,6 +34,8 @@ module1 py:module 0 foo.html#module-module1 Long Module desc
module2 py:module 0 foo.html#module-$ -
module1.func py:function 1 sub/foo.html#$ -
CFunc c:function 2 cfunc.html#CFunc -
+foo::Bar cpp:class 1 index.html#cpp_foo_bar -
+foo::Bar::baz cpp:function 1 index.html#cpp_foo_bar_baz -
a term std:term -1 glossary.html#term-a-term -
ls.-l std:cmdoption 1 index.html#cmdoption-ls-l -
docname std:doc -1 docname.html -