Get doc AST node from python AST node. Parameters ---------- node : ast.AST The AST node. Returns ------- res : doc.AST The corresponding doc AST node.
(node)
| 158 | |
| 159 | |
| 160 | def to_doc(node): |
| 161 | """Get doc AST node from python AST node. |
| 162 | |
| 163 | Parameters |
| 164 | ---------- |
| 165 | node : ast.AST |
| 166 | The AST node. |
| 167 | |
| 168 | Returns |
| 169 | ------- |
| 170 | res : doc.AST |
| 171 | The corresponding doc AST node. |
| 172 | """ |
| 173 | if _is_atomic_type(node): |
| 174 | return node |
| 175 | if isinstance(node, tuple): |
| 176 | return tuple(to_doc(n) for n in node) |
| 177 | if isinstance(node, list): |
| 178 | return [to_doc(n) for n in node] |
| 179 | func = _get_registry_entry(node.__class__.__name__, "to_doc") |
| 180 | if not func: |
| 181 | raise NotImplementedError(f"to_doc is not implemented for: {node.__class__.__name__}") |
| 182 | return func(node) |
| 183 | |
| 184 | |
| 185 | def parse( |
no test coverage detected
searching dependent graphs…