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

C++, fix parsing of full xrefs. #6226

Merged
merged 2 commits into from Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -22,6 +22,7 @@ Bugs fixed
- sphinx.application.CONFIG_FILENAME
- :confval:`viewcode_import`

* #6208: C++, properly parse full xrefs that happen to have a short xref as prefix.
* #6220, #6225: napoleon: AttributeError is raised for raised section having
references
* #6245: circular import error on importing SerializingHTMLBuilder
Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/cpp.py
Expand Up @@ -6391,6 +6391,7 @@ def parse_xref_object(self):
# if there are '()' left, just skip them
self.skip_ws()
self.skip_string('()')
self.assert_end()
templatePrefix = self._check_template_consistency(name, templatePrefix,
fullSpecShorthand=True)
res1 = ASTNamespace(name, templatePrefix)
Expand All @@ -6403,6 +6404,7 @@ def parse_xref_object(self):
# if there are '()' left, just skip them
self.skip_ws()
self.skip_string('()')
self.assert_end()
return res2, False
except DefinitionError as e2:
errs = []
Expand Down Expand Up @@ -7145,7 +7147,6 @@ def warn(self, msg):
parser = DefinitionParser(target, warner, env.config)
try:
ast, isShorthand = parser.parse_xref_object()
parser.assert_end()
except DefinitionError as e:
def findWarning(e): # as arg to stop flake8 from complaining
if typ != 'any' and typ != 'func':
Expand All @@ -7154,7 +7155,6 @@ def findWarning(e): # as arg to stop flake8 from complaining
parser2 = DefinitionParser(target[:-2], warner, env.config)
try:
parser2.parse_xref_object()
parser2.assert_end()
except DefinitionError as e2:
return target[:-2], e2
# strange, that we don't get the error now, use the original
Expand Down
14 changes: 14 additions & 0 deletions tests/test_domain_cpp.py
Expand Up @@ -755,6 +755,20 @@ def test_attributes():
check('member', 'int *[[attr]] *i', {1: 'i__iPP', 2: '1i'})


def test_xref_parsing():
def check(target):
class Config:
cpp_id_attributes = ["id_attr"]
cpp_paren_attributes = ["paren_attr"]
parser = DefinitionParser(target, None, Config())
ast, isShorthand = parser.parse_xref_object()
parser.assert_end()
check('f')
check('f()')
check('void f()')
check('T f()')


# def test_print():
# # used for getting all the ids out for checking
# for a in ids:
Expand Down