mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
domains/cpp: pep8 fixes
This commit is contained in:
parent
7b9f03e383
commit
3bd21b96e6
@ -9,6 +9,23 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
from copy import deepcopy
|
||||
|
||||
from six import iteritems, text_type
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.locale import l_, _
|
||||
from sphinx.domains import Domain, ObjType
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.util.nodes import make_refnode
|
||||
from sphinx.util.compat import Directive
|
||||
from sphinx.util.pycompat import UnicodeMixin
|
||||
from sphinx.util.docfields import Field, GroupedField
|
||||
|
||||
|
||||
"""
|
||||
Important note on ids:
|
||||
Multiple id generation schemes are used due to backwards compatibility.
|
||||
@ -191,23 +208,6 @@
|
||||
nested-name
|
||||
"""
|
||||
|
||||
import re
|
||||
from copy import deepcopy
|
||||
|
||||
from six import iteritems, text_type
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.locale import l_, _
|
||||
from sphinx.domains import Domain, ObjType
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.util.nodes import make_refnode
|
||||
from sphinx.util.compat import Directive
|
||||
from sphinx.util.pycompat import UnicodeMixin
|
||||
from sphinx.util.docfields import Field, GroupedField
|
||||
|
||||
|
||||
_identifier_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*)\b')
|
||||
_whitespace_re = re.compile(r'\s+(?u)')
|
||||
_string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
|
||||
@ -238,9 +238,9 @@ _keywords = [
|
||||
'while', 'xor', 'xor_eq'
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
# Id v1 constants
|
||||
#-------------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_id_fundamental_v1 = {
|
||||
'char': 'c',
|
||||
@ -312,9 +312,9 @@ _id_operator_v1 = {
|
||||
'[]': 'subscript-operator'
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
# Id v2 constants
|
||||
#-------------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_id_prefix_v2 = '_CPPv2'
|
||||
_id_fundamental_v2 = {
|
||||
@ -1333,8 +1333,8 @@ class ASTDeclaratorParen(ASTBase):
|
||||
|
||||
def get_ptr_suffix_id_v1(self):
|
||||
raise NoOldIdError() # TODO: was this implemented before?
|
||||
return self.next.get_ptr_suffix_id_v2() \
|
||||
+ self.inner.get_ptr_suffix_id_v2()
|
||||
return self.next.get_ptr_suffix_id_v2() + \
|
||||
self.inner.get_ptr_suffix_id_v2()
|
||||
|
||||
# Id v2 ------------------------------------------------------------------
|
||||
|
||||
@ -1345,8 +1345,8 @@ class ASTDeclaratorParen(ASTBase):
|
||||
return self.inner.get_param_id_v2()
|
||||
|
||||
def get_ptr_suffix_id_v2(self):
|
||||
return self.inner.get_ptr_suffix_id_v2() \
|
||||
+ self.next.get_ptr_suffix_id_v2()
|
||||
return self.inner.get_ptr_suffix_id_v2() + \
|
||||
self.next.get_ptr_suffix_id_v2()
|
||||
|
||||
def get_type_id_v2(self, returnTypeId):
|
||||
# ReturnType (inner)next, so 'inner' returns everything outside
|
||||
@ -1434,7 +1434,7 @@ class ASTDecleratorNameParamQual(ASTBase):
|
||||
return self.declId is not None
|
||||
|
||||
def is_function_type(self):
|
||||
return self.paramQual != None
|
||||
return self.paramQual is not None
|
||||
|
||||
def __unicode__(self):
|
||||
res = []
|
||||
@ -1490,9 +1490,9 @@ class ASTType(ASTBase):
|
||||
res.append(self.name.get_id_v1())
|
||||
res.append(self.decl.get_param_id_v1())
|
||||
res.append(self.decl.get_modifiers_id_v1())
|
||||
if (self.declSpecs.leftSpecs.constexpr
|
||||
or (self.declSpecs.rightSpecs
|
||||
and self.declSpecs.rightSpecs.constexpr)):
|
||||
if (self.declSpecs.leftSpecs.constexpr or
|
||||
(self.declSpecs.rightSpecs and
|
||||
self.declSpecs.rightSpecs.constexpr)):
|
||||
res.append('CE')
|
||||
elif self.objectType == 'type': # just the name
|
||||
res.append(self.name.get_id_v1())
|
||||
@ -1616,10 +1616,10 @@ class ASTClass(ASTBase):
|
||||
|
||||
def get_id_v1(self):
|
||||
return self.name.get_id_v1()
|
||||
#name = _id_shortwords.get(self.name)
|
||||
#if name is not None:
|
||||
# name = _id_shortwords.get(self.name)
|
||||
# if name is not None:
|
||||
# return name
|
||||
#return self.name.replace(u' ', u'-')
|
||||
# return self.name.replace(u' ', u'-')
|
||||
|
||||
def get_id_v2(self):
|
||||
return _id_prefix_v2 + self.prefixedName.get_id_v2()
|
||||
@ -1886,11 +1886,11 @@ class DefinitionParser(object):
|
||||
try:
|
||||
type = self._parse_type(named=False)
|
||||
templateArgs.append(type)
|
||||
except DefinitionError as exType:
|
||||
except DefinitionError:
|
||||
self.pos = pos
|
||||
try:
|
||||
value = self._parse_expression(end=[',', '>'])
|
||||
except DefinitionError as exConstant:
|
||||
except DefinitionError:
|
||||
assert False # TODO: make nice error
|
||||
templateArgs.append(ASTTemplateArgConstant(value))
|
||||
self.skip_ws()
|
||||
@ -2112,7 +2112,7 @@ class DefinitionParser(object):
|
||||
"constexpr" (only for member_object and function_object)
|
||||
"""
|
||||
visibility = None
|
||||
leftSepcs = None
|
||||
leftSpecs = None
|
||||
rightSpecs = None
|
||||
if outer:
|
||||
self.skip_ws()
|
||||
@ -2436,13 +2436,13 @@ class CPPObject(ObjectDescription):
|
||||
signode['names'].append(name)
|
||||
else:
|
||||
pass
|
||||
#print("[CPP] non-unique name:", name)
|
||||
# print("[CPP] non-unique name:", name)
|
||||
for id in ids:
|
||||
if id: # is None when the element didn't exist in that version
|
||||
signode['ids'].append(id)
|
||||
signode['first'] = (not self.names)
|
||||
self.state.document.note_explicit_target(signode)
|
||||
if not name in objects:
|
||||
if name not in objects:
|
||||
objects.setdefault(name, (self.env.docname, ast))
|
||||
if ast.objectType == 'enumerator':
|
||||
# find the parent, if it exists && is an enum
|
||||
@ -2459,7 +2459,7 @@ class CPPObject(ObjectDescription):
|
||||
enumScope = ASTNestedName(parentAst.prefixedName.names[:-1])
|
||||
unscopedName = enumeratorName.prefix_nested_name(enumScope)
|
||||
txtUnscopedName = text_type(unscopedName).lstrip(':')
|
||||
if not txtUnscopedName in objects:
|
||||
if txtUnscopedName not in objects:
|
||||
objects.setdefault(txtUnscopedName,
|
||||
(self.env.docname, ast))
|
||||
# add the uninstantiated template if it doesn't exist
|
||||
@ -2753,7 +2753,7 @@ class CPPDomain(Domain):
|
||||
if parent and len(parent) > 0:
|
||||
parentScope = parent[-1].clone()
|
||||
else:
|
||||
#env.warn_node("C++ xref has no 'parent' set: %s" % target, node)
|
||||
# env.warn_node("C++ xref has no 'parent' set: %s" % target, node)
|
||||
parentScope = ASTNestedName([ASTNestedNameElementEmpty()])
|
||||
while len(parentScope.names) > 0:
|
||||
name = nameAst.prefix_nested_name(parentScope)
|
||||
|
Loading…
Reference in New Issue
Block a user