mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, yet more code cleanup
This commit is contained in:
parent
45a8169184
commit
38db131ee9
@ -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,
|
||||
|
@ -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<R(A1, A2, A3)> F", "F", "1F")
|
||||
check("type", "std::function<R(A1, A2, A3, As...)> 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<unsigned long>::max()',
|
||||
None, "1A")
|
||||
|
||||
|
||||
def test_templates():
|
||||
check('class', "A<T>", None, "IE1AI1TE", output="template<> A<T>")
|
||||
# first just check which objects support templating
|
||||
|
Loading…
Reference in New Issue
Block a user