From 38db131ee9076b845c8bfb6b6078a4fa6e95b1b6 Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Sun, 6 Sep 2015 16:08:37 +0200 Subject: [PATCH] C++, yet more code cleanup --- sphinx/domains/cpp.py | 10 +++------- tests/test_domain_cpp.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index b012152df..b17e4cf5b 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -1867,10 +1867,6 @@ class ASTClass(ASTBase): def get_id_v1(self, objectType, symbol): return symbol.get_full_nested_name().get_id_v1() - #name = _id_shortwords.get(self.name) - #if name is not None: - # return name - #return self.name.replace(u' ', u'-') def get_id_v2(self, objectType, symbol): return symbol.get_full_nested_name().get_id_v2() @@ -3272,7 +3268,7 @@ class CPPObject(ObjectDescription): names[name] = ast.symbol.docname signode['names'].append(name) else: - #print("[CPP] non-unique name:", name) + # print("[CPP] non-unique name:", name) pass for id in ids: if id: # is None when the element didn't exist in that version @@ -3524,10 +3520,10 @@ class CPPDomain(Domain): def process_doc(self, env, docname, document): # just for debugging - #print(self.data['rootSymbol'].dump(0)) + # print(self.data['rootSymbol'].dump(0)) pass - #def merge_domaindata(self, docnames, otherdata): + # def merge_domaindata(self, docnames, otherdata): # # TODO: merge rootSymbol def _resolve_xref_inner(self, env, fromdocname, builder, diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index c13de0b4f..53f9f95e6 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -18,6 +18,7 @@ from sphinx.domains.cpp import Symbol ids = [] + def parse(name, string): parser = DefinitionParser(string, None) ast = parser.parse_declaration(name) @@ -28,9 +29,10 @@ def parse(name, string): raise DefinitionError("") # The scopedness would usually have been set by CPPEnumObject if name == "enum": - ast.scoped = None # simulate unscoped enum + ast.scoped = None # simulate unscoped enum return ast + def check(name, input, idv1output=None, idv2output=None, output=None): # first a simple check of the AST if output is None: @@ -50,12 +52,12 @@ def check(name, input, idv1output=None, idv2output=None, output=None): idv2output = "_CPPv2" + idv2output try: idv1 = ast.get_id_v1() - assert idv1 != None + assert idv1 is not None except NoOldIdError: idv1 = None try: idv2 = ast.get_id_v2() - assert idv2 != None + assert idv2 is not None except NoOldIdError: idv2 = None if idv1 != idv1output or idv2 != idv2output: @@ -69,6 +71,7 @@ def check(name, input, idv1output=None, idv2output=None, output=None): ids.append(ast.get_id_v2()) #print ".. %s:: %s" % (name, input) + def test_type_definitions(): check("type", "public bool b", "b", "1b", "bool b") check("type", "bool A::b", "A::b", "N1A1bE") @@ -88,7 +91,7 @@ def test_type_definitions(): check("type", "std::function F", "F", "1F") check("type", "std::function F", "F", "1F") check("type", "MyContainer::const_iterator", - "MyContainer::const_iterator","N11MyContainer14const_iteratorE") + "MyContainer::const_iterator", "N11MyContainer14const_iteratorE") check("type", "public MyContainer::const_iterator", "MyContainer::const_iterator", "N11MyContainer14const_iteratorE", @@ -231,6 +234,7 @@ def test_type_definitions(): check('enumerator', 'A = std::numeric_limits::max()', None, "1A") + def test_templates(): check('class', "A", None, "IE1AI1TE", output="template<> A") # first just check which objects support templating