Skip to content

Commit c23af0b

Browse files
committed
Update black formatting
1 parent 176d75f commit c23af0b

File tree

4 files changed

+132
-130
lines changed

4 files changed

+132
-130
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 125 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ def set_location_info(thing, location):
266266

267267
def _split_namespace(namestack):
268268
"""
269-
Given a list of name elements, find the namespace portion
270-
and return that as a string
269+
Given a list of name elements, find the namespace portion
270+
and return that as a string
271271
272-
:rtype: Tuple[str, list]
272+
:rtype: Tuple[str, list]
273273
"""
274274
# TODO: this should be using tokens instead of nhack
275275

@@ -293,9 +293,9 @@ def _split_namespace(namestack):
293293

294294
def _iter_ns_str_reversed(namespace):
295295
"""
296-
Take a namespace string, and yield successively smaller portions
297-
of it (ex foo::bar::baz::, foo::bar::, foo::). The last item yielded
298-
will always be an empty string
296+
Take a namespace string, and yield successively smaller portions
297+
of it (ex foo::bar::baz::, foo::bar::, foo::). The last item yielded
298+
will always be an empty string
299299
"""
300300
if namespace:
301301
parts = namespace.split("::")
@@ -334,13 +334,13 @@ def __init__(self, msg, tok=None):
334334

335335
class CppTemplateParam(dict):
336336
"""
337-
Dictionary that contains the following:
337+
Dictionary that contains the following:
338338
339-
- ``decltype`` - If True, this is a decltype
340-
- ``param`` - Parameter value or typename
341-
- ``params`` - Only present if a template specialization. Is a list of
342-
:class:`.CppTemplateParam`
343-
- ``...`` - If True, indicates a parameter pack
339+
- ``decltype`` - If True, this is a decltype
340+
- ``param`` - Parameter value or typename
341+
- ``params`` - Only present if a template specialization. Is a list of
342+
:class:`.CppTemplateParam`
343+
- ``...`` - If True, indicates a parameter pack
344344
"""
345345

346346
def __init__(self):
@@ -370,17 +370,17 @@ def __str__(self):
370370

371371
class CppBaseDecl(dict):
372372
"""
373-
Dictionary that contains the following
374-
375-
- ``access`` - Anything in supportedAccessSpecifier
376-
- ``class`` - Name of the type, along with template specializations
377-
- ``decl_name`` - Name of the type only
378-
- ``decl_params`` - Only present if a template specialization (Foo<int>).
379-
Is a list of :class:`.CppTemplateParam`.
380-
- ``decltype`` - True/False indicates a decltype, the contents are in
381-
``decl_name``
382-
- ``virtual`` - True/False indicates virtual inheritance
383-
- ``...`` - True/False indicates a parameter pack
373+
Dictionary that contains the following
374+
375+
- ``access`` - Anything in supportedAccessSpecifier
376+
- ``class`` - Name of the type, along with template specializations
377+
- ``decl_name`` - Name of the type only
378+
- ``decl_params`` - Only present if a template specialization (Foo<int>).
379+
Is a list of :class:`.CppTemplateParam`.
380+
- ``decltype`` - True/False indicates a decltype, the contents are in
381+
``decl_name``
382+
- ``virtual`` - True/False indicates virtual inheritance
383+
- ``...`` - True/False indicates a parameter pack
384384
385385
"""
386386

@@ -599,50 +599,50 @@ def _parse_cpp_base(stack, default_access):
599599

600600
class CppClass(dict):
601601
"""
602-
Dictionary that contains at least the following keys:
603-
604-
* ``name`` - Name of the class
605-
* ``doxygen`` - Doxygen comments associated with the class if they exist
606-
* ``inherits`` - List of Classes that this one inherits. Values are
607-
:class:`.CppBaseDecl`
608-
* ``methods`` - Dictionary where keys are from supportedAccessSpecifier
609-
and values are a lists of :class:`.CppMethod`
610-
* ``namespace`` - Namespace of class
611-
* ``properties`` - Dictionary where keys are from supportedAccessSpecifier
612-
and values are lists of :class:`.CppVariable`
613-
* ``enums`` - Dictionary where keys are from supportedAccessSpecifier and
614-
values are lists of :class:`.CppEnum`
615-
* ``nested_classes`` - Classes and structs defined within this class
616-
* ``final`` - True if final
617-
* ``abstract`` - True if abstract
618-
* ``using`` - Using directives in this class scope: key is name for lookup,
619-
value is :class:`.CppVariable`
620-
* ``parent`` - If not None, the class that this class is nested in
621-
622-
An example of how this could look is as follows::
623-
602+
Dictionary that contains at least the following keys:
603+
604+
* ``name`` - Name of the class
605+
* ``doxygen`` - Doxygen comments associated with the class if they exist
606+
* ``inherits`` - List of Classes that this one inherits. Values are
607+
:class:`.CppBaseDecl`
608+
* ``methods`` - Dictionary where keys are from supportedAccessSpecifier
609+
and values are a lists of :class:`.CppMethod`
610+
* ``namespace`` - Namespace of class
611+
* ``properties`` - Dictionary where keys are from supportedAccessSpecifier
612+
and values are lists of :class:`.CppVariable`
613+
* ``enums`` - Dictionary where keys are from supportedAccessSpecifier and
614+
values are lists of :class:`.CppEnum`
615+
* ``nested_classes`` - Classes and structs defined within this class
616+
* ``final`` - True if final
617+
* ``abstract`` - True if abstract
618+
* ``using`` - Using directives in this class scope: key is name for lookup,
619+
value is :class:`.CppVariable`
620+
* ``parent`` - If not None, the class that this class is nested in
621+
622+
An example of how this could look is as follows::
623+
624+
{
625+
'name': ""
626+
'inherits':[]
627+
'methods':
624628
{
625-
'name': ""
626-
'inherits':[]
627-
'methods':
628-
{
629-
'public':[],
630-
'protected':[],
631-
'private':[]
632-
},
633-
'properties':
634-
{
635-
'public':[],
636-
'protected':[],
637-
'private':[]
638-
},
639-
'enums':
640-
{
641-
'public':[],
642-
'protected':[],
643-
'private':[]
644-
}
629+
'public':[],
630+
'protected':[],
631+
'private':[]
632+
},
633+
'properties':
634+
{
635+
'public':[],
636+
'protected':[],
637+
'private':[]
638+
},
639+
'enums':
640+
{
641+
'public':[],
642+
'protected':[],
643+
'private':[]
645644
}
645+
}
646646
"""
647647

648648
def get_all_methods(self):
@@ -837,11 +837,11 @@ def __str__(self):
837837

838838
class CppUnion(CppClass):
839839
"""
840-
Dictionary that contains at least the following keys:
840+
Dictionary that contains at least the following keys:
841841
842-
* ``name`` - Name of the union
843-
* ``doxygen`` - Doxygen comments associated with the union if they exist
844-
* ``members`` - List of members of the union
842+
* ``name`` - Name of the union
843+
* ``doxygen`` - Doxygen comments associated with the union if they exist
844+
* ``members`` - List of members of the union
845845
"""
846846

847847
def __init__(self, nameStack, doxygen, location):
@@ -953,13 +953,13 @@ def _params_helper2(self, params):
953953

954954
class CppMethod(_CppMethod):
955955
"""
956-
Dictionary that contains at least the following keys:
956+
Dictionary that contains at least the following keys:
957957
958-
* ``rtnType`` - Return type of the method (ex. "int")
959-
* ``name`` - Name of the method
960-
* ``doxygen`` - Doxygen comments associated with the method if they exist
961-
* ``parameters`` - List of :class:`.CppVariable`
962-
* ``parent`` - If not None, the class this method belongs to
958+
* ``rtnType`` - Return type of the method (ex. "int")
959+
* ``name`` - Name of the method
960+
* ``doxygen`` - Doxygen comments associated with the method if they exist
961+
* ``parameters`` - List of :class:`.CppVariable`
962+
* ``parent`` - If not None, the class this method belongs to
963963
"""
964964

965965
def show(self):
@@ -1173,18 +1173,18 @@ def init(self):
11731173

11741174
class CppVariable(_CppVariable):
11751175
"""
1176-
Dictionary that contains at least the following keys:
1177-
1178-
* ``type`` - Type for the variable (ex. "const string &")
1179-
* ``name`` - Name of the variable (ex. "numItems")
1180-
* ``namespace`` - Namespace
1181-
* ``desc`` - If a method/function parameter, doxygen description for this parameter (optional)
1182-
* ``doxygen`` - If a normal property/variable, doxygen description for this
1183-
* ``default`` - Default value of the variable, this key will only
1184-
exist if there is a default value
1185-
* ``extern`` - True if its an extern, False if not
1186-
* ``parent`` - If not None, either the class this is a property of, or the
1187-
method this variable is a parameter in
1176+
Dictionary that contains at least the following keys:
1177+
1178+
* ``type`` - Type for the variable (ex. "const string &")
1179+
* ``name`` - Name of the variable (ex. "numItems")
1180+
* ``namespace`` - Namespace
1181+
* ``desc`` - If a method/function parameter, doxygen description for this parameter (optional)
1182+
* ``doxygen`` - If a normal property/variable, doxygen description for this
1183+
* ``default`` - Default value of the variable, this key will only
1184+
exist if there is a default value
1185+
* ``extern`` - True if its an extern, False if not
1186+
* ``parent`` - If not None, either the class this is a property of, or the
1187+
method this variable is a parameter in
11881188
"""
11891189

11901190
Vars = []
@@ -1308,7 +1308,7 @@ class _CppEnum(dict):
13081308
def resolve_enum_values(self, values):
13091309
"""Evaluates the values list of dictionaries passed in and figures out what the enum value
13101310
for each enum is editing in place:
1311-
1311+
13121312
Example
13131313
From: [{'name': 'ORANGE'},
13141314
{'name': 'RED'},
@@ -1365,9 +1365,9 @@ class CppEnum(_CppEnum):
13651365
13661366
* ``name`` - Name of the enum (ex. "ItemState")
13671367
* ``namespace`` - Namespace containing the enum
1368-
* ``values`` - List of values. The values are a dictionary with
1368+
* ``values`` - List of values. The values are a dictionary with
13691369
the following key/values:
1370-
1370+
13711371
- ``name`` - name of the key (ex. "PARSING_HEADER"),
13721372
- ``value`` - Specified value of the enum, this key will only exist
13731373
if a value for a given enum value was defined
@@ -1385,11 +1385,11 @@ def __init__(self, name, doxygen, location):
13851385

13861386

13871387
class _CppPreprocessorLiteral(dict):
1388-
""" Implementation for #pragmas, #defines and #includes, contains the
1389-
following keys:
1388+
"""Implementation for #pragmas, #defines and #includes, contains the
1389+
following keys:
13901390
1391-
* ``value`` the value literal of the preprocessor item
1392-
* ``line_number`` line number at which the item was found
1391+
* ``value`` the value literal of the preprocessor item
1392+
* ``line_number`` line number at which the item was found
13931393
"""
13941394

13951395
def __init__(self, macro, location):
@@ -2638,7 +2638,7 @@ def show(self):
26382638

26392639
def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
26402640
"""Create the parsed C++ header file parse tree
2641-
2641+
26422642
headerFileName - Name of the file to parse OR actual file contents (depends on argType)
26432643
argType - Indicates how to interpret headerFileName as a file string or file name
26442644
kwargs - Supports the following keywords
@@ -3045,7 +3045,8 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
30453045
)
30463046

30473047
raise_exc(
3048-
CppParseError(msg), e,
3048+
CppParseError(msg),
3049+
e,
30493050
)
30503051

30513052
self.finalize()
@@ -3172,16 +3173,16 @@ def _discard_contents(self, start_type, end_type):
31723173

31733174
def _discard_ctor_initializer(self):
31743175
"""
3175-
ctor_initializer: ":" mem_initializer_list
3176+
ctor_initializer: ":" mem_initializer_list
3177+
3178+
mem_initializer_list: mem_initializer ["..."]
3179+
| mem_initializer "," mem_initializer_list ["..."]
31763180
3177-
mem_initializer_list: mem_initializer ["..."]
3178-
| mem_initializer "," mem_initializer_list ["..."]
3181+
mem_initializer: mem_initializer_id "(" [expression_list] ")"
3182+
| mem_initializer_id braced_init_list
31793183
3180-
mem_initializer: mem_initializer_id "(" [expression_list] ")"
3181-
| mem_initializer_id braced_init_list
3182-
3183-
mem_initializer_id: class_or_decltype
3184-
| IDENTIFIER
3184+
mem_initializer_id: class_or_decltype
3185+
| IDENTIFIER
31853186
"""
31863187
debug_print("discarding ctor intializer")
31873188
# all of this is discarded.. the challenge is to determine
@@ -3451,19 +3452,19 @@ def _parse_attribute_specifier_seq(self, tok):
34513452

34523453
def _parse_enum(self):
34533454
"""
3454-
opaque_enum_declaration: enum_key [attribute_specifier_seq] IDENTIFIER [enum_base] ";"
3455-
3456-
enum_specifier: enum_head "{" [enumerator_list] "}"
3457-
| enum_head "{" enumerator_list "," "}"
3458-
3459-
enum_head: enum_key [attribute_specifier_seq] [IDENTIFIER] [enum_base]
3460-
| enum_key [attribute_specifier_seq] nested_name_specifier IDENTIFIER [enum_base]
3461-
3462-
enum_key: "enum"
3463-
| "enum" "class"
3464-
| "enum" "struct"
3465-
3466-
enum_base: ":" type_specifier_seq
3455+
opaque_enum_declaration: enum_key [attribute_specifier_seq] IDENTIFIER [enum_base] ";"
3456+
3457+
enum_specifier: enum_head "{" [enumerator_list] "}"
3458+
| enum_head "{" enumerator_list "," "}"
3459+
3460+
enum_head: enum_key [attribute_specifier_seq] [IDENTIFIER] [enum_base]
3461+
| enum_key [attribute_specifier_seq] nested_name_specifier IDENTIFIER [enum_base]
3462+
3463+
enum_key: "enum"
3464+
| "enum" "class"
3465+
| "enum" "struct"
3466+
3467+
enum_base: ":" type_specifier_seq
34673468
"""
34683469
debug_print("parsing enum")
34693470

@@ -3573,13 +3574,13 @@ def _install_enum(self, newEnum, instancesData):
35733574

35743575
def _parse_enumerator_list(self, values):
35753576
"""
3576-
enumerator_list: enumerator_definition
3577-
| enumerator_list "," enumerator_definition
3578-
3579-
enumerator_definition: enumerator
3580-
| enumerator "=" constant_expression
3581-
3582-
enumerator: IDENTIFIER
3577+
enumerator_list: enumerator_definition
3578+
| enumerator_list "," enumerator_definition
3579+
3580+
enumerator_definition: enumerator
3581+
| enumerator "=" constant_expression
3582+
3583+
enumerator: IDENTIFIER
35833584
"""
35843585
while True:
35853586
name_tok = self._next_token_must_be("}", "NAME")

CppHeaderParser/doxygen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def extract_doxygen_method_params(doxystr):
22
"""
3-
Given a doxygen string for a method, extract parameter descriptions
3+
Given a doxygen string for a method, extract parameter descriptions
44
"""
55
doxyVarDesc = {}
66
doxyLines = doxystr.split("\n")

CppHeaderParser/lexer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def current_location(self):
142142

143143
def get_doxygen(self):
144144
"""
145-
This should be called after the first element of something has
146-
been consumed.
145+
This should be called after the first element of something has
146+
been consumed.
147147
148-
It will lookahead for comments that come after the item, if prior
149-
comments don't exist.
148+
It will lookahead for comments that come after the item, if prior
149+
comments don't exist.
150150
"""
151151

152152
# Assumption: This function is either called at the beginning of a

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy