Skip to content

Commit b3447ff

Browse files
committed
[clang_utils.py] documentation changes
1 parent 53b2884 commit b3447ff

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

bindings/python/scripts/clang_utils.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ def getmembers_static(object, predicate=None):
99
"""
1010

1111
"""
12-
- `getmembers` from the inspect module triggers execution, which leads to errors when types are not satisfied.
13-
- So we define a custom function based on the one in the inspect module.
14-
- It replaces `getattr_static` with `getattr_static` to solve the issue.
12+
- `getmembers` function (from the inspect module) triggers execution instead of doing static analysis.
13+
- This leads to errors, particularly on properties of classes in cindex.py, which causes segmentation errors or raises an Exception if a particular condition is not satisfied.
14+
- To curb this, we need a fetch the members statically.
15+
- The inspect module doesn't provide a function to do so. So we define a custom function based on the one in the inspect module.
16+
17+
diff: We replace the `getattr` function call with a `getattr_static` function call in the function definition.
1518
"""
1619

1720
if inspect.isclass(object):
@@ -103,7 +106,8 @@ def __init__(self, cursor_type: clang.Type):
103106

104107
# Docstring template for the classes
105108
class_docstring = """
106-
{class_name} class utilities
109+
- {class_name} class utilities.
110+
- {description}
107111
108112
`check_functions_dict`:
109113
- Functions that begin with "is_" i.e., checking functions
@@ -116,6 +120,15 @@ def __init__(self, cursor_type: clang.Type):
116120
- A list of two-tuples: (property_name: str, property_value: property)
117121
"""
118122

119-
CursorKindUtils.__doc__ = class_docstring.format(class_name="CursorKind")
120-
CursorUtils.__doc__ = class_docstring.format(class_name="Cursor")
121-
TypeUtils.__doc__ = class_docstring.format(class_name="Type")
123+
CursorKindUtils.__doc__ = class_docstring.format(
124+
class_name="CursorKind",
125+
description="A CursorKind describes the kind of entity that a cursor points to.",
126+
)
127+
CursorUtils.__doc__ = class_docstring.format(
128+
class_name="Cursor",
129+
description="The Cursor class represents a reference to an element within the AST. It acts as a kind of iterator.",
130+
)
131+
TypeUtils.__doc__ = class_docstring.format(
132+
class_name="Type",
133+
description="The Type class represents the type of an element in the abstract syntax tree.",
134+
)

0 commit comments

Comments
 (0)