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, C++: remove noindex option #7895

Merged
merged 1 commit into from Jul 2, 2020
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
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -27,6 +27,8 @@ Bugs fixed
* #7846: html theme: XML-invalid files were generated
* #7869: :rst:role:`abbr` role without an explanation will show the explanation
from the previous abbr role
* C and C++, removed ``noindex`` directive option as it did
nothing.

Testing
--------
Expand Down
1 change: 0 additions & 1 deletion doc/usage/restructuredtext/domains.rst
Expand Up @@ -1038,7 +1038,6 @@ Options

Some directives support options:

- ``:noindex:``, see :ref:`basic-domain-markup`.
- ``:tparam-line-spec:``, for templated declarations.
If specified, each template parameter will be rendered on a separate line.

Expand Down
33 changes: 16 additions & 17 deletions sphinx/domains/c.py
Expand Up @@ -1884,7 +1884,7 @@ def merge_with(self, other: "Symbol", docnames: List[str],
ourChild._fill_empty(otherChild.declaration, otherChild.docname)
elif ourChild.docname != otherChild.docname:
name = str(ourChild.declaration)
msg = __("Duplicate declaration, also defined in '%s'.\n"
msg = __("Duplicate C declaration, also defined in '%s'.\n"
"Declaration is '%s'.")
msg = msg % (ourChild.docname, name)
logger.warning(msg, location=otherChild.docname)
Expand Down Expand Up @@ -3019,6 +3019,13 @@ class CObject(ObjectDescription):
names=('rtype',)),
]

option_spec = {
# have a dummy option to ensure proper errors on options,
# otherwise the option is taken as a continuation of the
# argument
'dummy': None
}

def _add_enumerator_to_parent(self, ast: ASTDeclaration) -> None:
assert ast.objectType == 'enumerator'
# find the parent, if it exists && is an enum
Expand Down Expand Up @@ -3085,7 +3092,8 @@ def add_target_and_index(self, ast: ASTDeclaration, sig: str,
self.state.document.note_explicit_target(signode)

domain = cast(CDomain, self.env.get_domain('c'))
domain.note_object(name, self.objtype, newestId)
if name not in domain.objects:
domain.objects[name] = (domain.env.docname, newestId, self.objtype)

indexText = self.get_index_text(name)
self.indexnode['entries'].append(('single', indexText, newestId, '', None))
Expand Down Expand Up @@ -3150,7 +3158,10 @@ def handle_signature(self, sig: str, signode: TextElement) -> ASTDeclaration:
# Assume we are actually in the old symbol,
# instead of the newly created duplicate.
self.env.temp_data['c:last_symbol'] = e.symbol
logger.warning("Duplicate declaration, %s", sig, location=signode)
msg = __("Duplicate C declaration, also defined in '%s'.\n"
"Declaration is '%s'.")
msg = msg % (e.symbol.docname, sig)
logger.warning(msg, location=signode)

if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast)
Expand Down Expand Up @@ -3418,14 +3429,6 @@ class CDomain(Domain):
def objects(self) -> Dict[str, Tuple[str, str, str]]:
return self.data.setdefault('objects', {}) # fullname -> docname, node_id, objtype

def note_object(self, name: str, objtype: str, node_id: str, location: Any = None) -> None:
if name in self.objects:
docname = self.objects[name][0]
logger.warning(__('Duplicate C object description of %s, '
'other instance in %s, use :noindex: for one of them'),
name, docname, location=location)
self.objects[name] = (self.env.docname, node_id, objtype)

def clear_doc(self, docname: str) -> None:
if Symbol.debug_show_tree:
print("clear_doc:", docname)
Expand Down Expand Up @@ -3471,13 +3474,9 @@ def merge_domaindata(self, docnames: List[str], otherdata: Dict) -> None:
ourObjects = self.data['objects']
for fullname, (fn, id_, objtype) in otherdata['objects'].items():
if fn in docnames:
if fullname in ourObjects:
msg = __("Duplicate declaration, also defined in '%s'.\n"
"Name of declaration is '%s'.")
msg = msg % (ourObjects[fullname], fullname)
logger.warning(msg, location=fn)
else:
if fullname not in ourObjects:
ourObjects[fullname] = (fn, id_, objtype)
# no need to warn on duplicates, the symbol merge already does that

def _resolve_xref_inner(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
typ: str, target: str, node: pending_xref,
Expand Down
21 changes: 10 additions & 11 deletions sphinx/domains/cpp.py
Expand Up @@ -4455,7 +4455,7 @@ def unconditionalAdd(self, otherChild):
ourChild._fill_empty(otherChild.declaration, otherChild.docname)
elif ourChild.docname != otherChild.docname:
name = str(ourChild.declaration)
msg = __("Duplicate declaration, also defined in '%s'.\n"
msg = __("Duplicate C++ declaration, also defined in '%s'.\n"
"Declaration is '%s'.")
msg = msg % (ourChild.docname, name)
logger.warning(msg, location=otherChild.docname)
Expand Down Expand Up @@ -6624,8 +6624,9 @@ class CPPObject(ObjectDescription):
names=('returns', 'return')),
]

option_spec = dict(ObjectDescription.option_spec)
option_spec['tparam-line-spec'] = directives.flag
option_spec = {
'tparam-line-spec': directives.flag,
}

def _add_enumerator_to_parent(self, ast: ASTDeclaration) -> None:
assert ast.objectType == 'enumerator'
Expand Down Expand Up @@ -6808,7 +6809,10 @@ def handle_signature(self, sig: str, signode: desc_signature) -> ASTDeclaration:
# Assume we are actually in the old symbol,
# instead of the newly created duplicate.
self.env.temp_data['cpp:last_symbol'] = e.symbol
logger.warning("Duplicate declaration, %s", sig, location=signode)
msg = __("Duplicate C++ declaration, also defined in '%s'.\n"
"Declaration is '%s'.")
msg = msg % (e.symbol.docname, sig)
logger.warning(msg, location=signode)

if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast)
Expand Down Expand Up @@ -7083,7 +7087,6 @@ def run(self) -> List[Node]:
node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = True

self.names = [] # type: List[str]
signatures = self.get_signatures()
Expand Down Expand Up @@ -7275,13 +7278,9 @@ def merge_domaindata(self, docnames: List[str], otherdata: Dict) -> None:
ourNames = self.data['names']
for name, docname in otherdata['names'].items():
if docname in docnames:
if name in ourNames:
msg = __("Duplicate declaration, also defined in '%s'.\n"
"Name of declaration is '%s'.")
msg = msg % (ourNames[name], name)
logger.warning(msg, location=docname)
else:
if name not in ourNames:
ourNames[name] = docname
# no need to warn on duplicates, the symbol merge already does that
if Symbol.debug_show_tree:
print("\tresult:")
print(self.data['root_symbol'].dump(1))
Expand Down