mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7895 from jakobandersen/c_cpp_noindex
C, C++: remove noindex option
This commit is contained in:
commit
8c82ecbf2c
2
CHANGES
2
CHANGES
@ -29,6 +29,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
|
||||
--------
|
||||
|
@ -1073,7 +1073,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.
|
||||
|
||||
|
@ -1887,7 +1887,7 @@ class Symbol:
|
||||
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)
|
||||
@ -3022,6 +3022,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
|
||||
@ -3088,7 +3095,8 @@ class CObject(ObjectDescription):
|
||||
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))
|
||||
@ -3153,7 +3161,10 @@ class CObject(ObjectDescription):
|
||||
# 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)
|
||||
@ -3523,14 +3534,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)
|
||||
@ -3576,13 +3579,9 @@ class CDomain(Domain):
|
||||
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,
|
||||
|
@ -4455,7 +4455,7 @@ class Symbol:
|
||||
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)
|
||||
@ -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'
|
||||
@ -6808,7 +6809,10 @@ class CPPObject(ObjectDescription):
|
||||
# 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)
|
||||
@ -7083,7 +7087,6 @@ class CPPAliasObject(ObjectDescription):
|
||||
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()
|
||||
@ -7275,13 +7278,9 @@ class CPPDomain(Domain):
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user