Get original python AST node from doc AST node. Parameters ---------- node : doc.AST The doc AST node. Returns ------- res : ast.AST The corresponding AST node.
(node)
| 133 | |
| 134 | |
| 135 | def from_doc(node): |
| 136 | """Get original python AST node from doc AST node. |
| 137 | |
| 138 | Parameters |
| 139 | ---------- |
| 140 | node : doc.AST |
| 141 | The doc AST node. |
| 142 | |
| 143 | Returns |
| 144 | ------- |
| 145 | res : ast.AST |
| 146 | The corresponding AST node. |
| 147 | """ |
| 148 | if _is_atomic_type(node): |
| 149 | return node |
| 150 | if isinstance(node, tuple): |
| 151 | return tuple(from_doc(n) for n in node) |
| 152 | if isinstance(node, list): |
| 153 | return [from_doc(n) for n in node] |
| 154 | func = _get_registry_entry(node.__class__.__name__, "from_doc") |
| 155 | if not func: |
| 156 | raise NotImplementedError(f"from_doc is not implemented for: {node.__class__.__name__}") |
| 157 | return func(node) |
| 158 | |
| 159 | |
| 160 | def to_doc(node): |
no test coverage detected
searching dependent graphs…