mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
cpp domain: minor PEP8 cleanup
This commit is contained in:
parent
7aa43488ea
commit
80144f19f5
@ -141,7 +141,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import traceback
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from six import iteritems, text_type
|
from six import iteritems, text_type
|
||||||
@ -319,7 +318,7 @@ class ASTBase(UnicodeMixin):
|
|||||||
|
|
||||||
|
|
||||||
def _verify_description_mode(mode):
|
def _verify_description_mode(mode):
|
||||||
if not mode in ('lastIsName', 'noneIsName', 'markType', 'param'):
|
if mode not in ('lastIsName', 'noneIsName', 'markType', 'param'):
|
||||||
raise Exception("Description mode '%s' is invalid." % mode)
|
raise Exception("Description mode '%s' is invalid." % mode)
|
||||||
|
|
||||||
|
|
||||||
@ -328,7 +327,7 @@ class ASTOperatorBuildIn(ASTBase):
|
|||||||
self.op = op
|
self.op = op
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
if not self.op in _id_operator:
|
if self.op not in _id_operator:
|
||||||
raise Exception('Internal error: Build-in operator "%s" can not '
|
raise Exception('Internal error: Build-in operator "%s" can not '
|
||||||
'be mapped to an id.' % self.op)
|
'be mapped to an id.' % self.op)
|
||||||
return _id_operator[self.op]
|
return _id_operator[self.op]
|
||||||
@ -532,7 +531,7 @@ class ASTTrailingTypeSpecFundamental(ASTBase):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
if not self.name in _id_fundamental:
|
if self.name not in _id_fundamental:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Semi-internal error: Fundamental type "%s" can not be mapped '
|
'Semi-internal error: Fundamental type "%s" can not be mapped '
|
||||||
'to an id. Is it a true fundamental type? If not so, the '
|
'to an id. Is it a true fundamental type? If not so, the '
|
||||||
@ -866,7 +865,7 @@ class ASTDeclerator(ASTBase):
|
|||||||
isinstance(self.ptrOps[-1], ASTPtrOpParamPack)):
|
isinstance(self.ptrOps[-1], ASTPtrOpParamPack)):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return self.declId != None
|
return self.declId is not None
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
res = []
|
res = []
|
||||||
@ -1190,8 +1189,7 @@ class DefinitionParser(object):
|
|||||||
self.fail(
|
self.fail(
|
||||||
'Could not find end of constant '
|
'Could not find end of constant '
|
||||||
'template argument.')
|
'template argument.')
|
||||||
value = self.definition[
|
value = self.definition[startPos:self.pos].strip()
|
||||||
startPos:self.pos].strip()
|
|
||||||
templateArgs.append(ASTTemplateArgConstant(value))
|
templateArgs.append(ASTTemplateArgConstant(value))
|
||||||
self.skip_ws()
|
self.skip_ws()
|
||||||
if self.skip_string('>'):
|
if self.skip_string('>'):
|
||||||
@ -1422,7 +1420,7 @@ class DefinitionParser(object):
|
|||||||
|
|
||||||
def _parse_declerator(self, named, paramMode=None, typed=True):
|
def _parse_declerator(self, named, paramMode=None, typed=True):
|
||||||
if paramMode:
|
if paramMode:
|
||||||
if not paramMode in ('type', 'function'):
|
if paramMode not in ('type', 'function'):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Internal error, unknown paramMode '%s'." % paramMode)
|
"Internal error, unknown paramMode '%s'." % paramMode)
|
||||||
ptrOps = []
|
ptrOps = []
|
||||||
@ -1493,7 +1491,7 @@ class DefinitionParser(object):
|
|||||||
if outer == 'member':
|
if outer == 'member':
|
||||||
value = self.read_rest().strip()
|
value = self.read_rest().strip()
|
||||||
return ASTInitializer(value)
|
return ASTInitializer(value)
|
||||||
elif outer == None: # function parameter
|
elif outer is None: # function parameter
|
||||||
symbols = []
|
symbols = []
|
||||||
startPos = self.pos
|
startPos = self.pos
|
||||||
self.skip_ws()
|
self.skip_ws()
|
||||||
@ -1528,7 +1526,7 @@ class DefinitionParser(object):
|
|||||||
doesn't need to name the arguments
|
doesn't need to name the arguments
|
||||||
"""
|
"""
|
||||||
if outer: # always named
|
if outer: # always named
|
||||||
if not outer in ('type', 'member', 'function'):
|
if outer not in ('type', 'member', 'function'):
|
||||||
raise Exception('Internal error, unknown outer "%s".' % outer)
|
raise Exception('Internal error, unknown outer "%s".' % outer)
|
||||||
assert not named
|
assert not named
|
||||||
|
|
||||||
@ -1652,12 +1650,12 @@ class CPPObject(ObjectDescription):
|
|||||||
if theid not in self.state.document.ids:
|
if theid not in self.state.document.ids:
|
||||||
# the name is not unique, the first one will win
|
# the name is not unique, the first one will win
|
||||||
objects = self.env.domaindata['cpp']['objects']
|
objects = self.env.domaindata['cpp']['objects']
|
||||||
if not name in objects:
|
if name not in objects:
|
||||||
signode['names'].append(name)
|
signode['names'].append(name)
|
||||||
signode['ids'].append(theid)
|
signode['ids'].append(theid)
|
||||||
signode['first'] = (not self.names)
|
signode['first'] = (not self.names)
|
||||||
self.state.document.note_explicit_target(signode)
|
self.state.document.note_explicit_target(signode)
|
||||||
if not name in objects:
|
if name not in objects:
|
||||||
objects.setdefault(name,
|
objects.setdefault(name,
|
||||||
(self.env.docname, ast.objectType, theid))
|
(self.env.docname, ast.objectType, theid))
|
||||||
# add the uninstantiated template if it doesn't exist
|
# add the uninstantiated template if it doesn't exist
|
||||||
|
Loading…
Reference in New Issue
Block a user