@@ -54,17 +54,17 @@ def terminal_writer(level: int, cursor_label: str) -> None:
5454 def output_ast_png (cursor : Cursor , max_depth : int , output_file_name : str = 'ast_graph' ) -> None :
5555 """ Output the abstract syntax tree to a .png. Set the starting node and the max depth.
5656
57- To save the abstract syntax tree as an png with a starting node and a depth u cann use the following command
57+ To save the abstract syntax tree as an png with a starting node and a depth u can use the following command
5858
5959 Example command: aviz.output_ast_png(ast.get_node_by_index(1), 2)
6060
6161 aviz -> instance of the Visualization class.
6262
6363 ast -> instance of the AST class.
6464
65- .get_node_by_index -> get a specific node by id ( use .output_ast_formatted to see node ids)
65+ .get_node_by_index -> get a specific node by id use ( .output_ast_formatted to see node ids)
6666
67- The number 2 is a example for the depth the graph will show
67+ The second parameter is the max depth the graph will show. The root node is depth 0, its children are depth 1 and so on.
6868
6969 :param cursor: The current node of the AST as a cursor object from libclang.
7070 :param max_depth: Maximal depth the graph displays.
@@ -84,7 +84,7 @@ def output_ast_png(cursor: Cursor, max_depth: int, output_file_name: str = 'ast_
8484
8585 @staticmethod
8686 def output_ast_formatted (ast : AST , cursor : Cursor , output_file_name : str = 'ast_formatted.txt' ) -> None :
87- """! Output the abstract syntax tree to a file.
87+ """ Output the abstract syntax tree to a file.
8888
8989 :param ast: ast object from AST class.
9090 :param cursor: The current node of the AST as a cursor object from libclang.
@@ -111,25 +111,24 @@ def file_writer(level: int, cursor_label: str) -> None:
111111def indent (level : int ) -> str :
112112 """ Create an indentation based on the level.
113113
114- :param level: int:
115-
114+ :param level: int: The current depth in the AST for indentation purposes.
115+ :returns: A string representing the indentation for the given level.
116116 """
117117 return '│ ' * level + '├── '
118118
119119
120120def newline () -> str :
121- """ Create a new line."""
121+ """ Creates a new line."""
122122 return '\n '
123123
124124
125125def _output_cursor_and_children (cursor : Cursor , ast : AST , writer : Callable [[int , str ], None ], level : int = 0 ) -> None :
126- """Generic function to output the cursor and its children with a specified writer.
126+ """ Generic function to output the cursor and its children with a specified writer.
127127
128128 :param cursor: The current node of the AST as a libclang cursor object.
129129 :param ast: AST object from the AST class.
130130 :param writer: Function that takes `level` and `cursor_label` and handles output.
131131 :param level: The current depth in the AST for indentation purposes. Default value = 0)
132-
133132 """
134133
135134 cursor_id = ast .get_node_id (cursor )
@@ -159,9 +158,7 @@ def _output_cursor_and_children_graphviz_digraph(cursor: Cursor, graph: Digraph,
159158 :param graph: Graphviz Digraph object where the nodes and edges will be added.
160159 :param max_d: Maximal depth.
161160 :param current_d: Current depth.
162- :param parent_node: Name of the parent node in the graph (None for the root node).
163- :param parent_node: str: (Default value = None)
164-
161+ :param parent_node: Name of the parent node in the graph (None for the root node). str: (Default value = None)
165162 """
166163
167164 if current_d > max_d :
0 commit comments