Open grayfox88 opened 1 year ago
I agree, code inspection hits several walls:
python
interpreter execute the file. And if side-effects are not wrapped by a classic if __name__ == '__main__':
clause, they will be executedThe last point is the one I fear the most because users of py2puml may be executing some code when generating the documentation, causing unexpected consequences.
Some downsides of relying only on AST parsing:
py2puml
features will be harder because AST parsing relies on the visitor pattern (see https://docs.python.org/3/library/ast.html#ast.NodeVisitor, https://www.mattlayman.com/blog/2018/decipher-python-ast/), which makes the "visiting" code harder to write, understand and testGood summary @lucsorel , concerning the downside related to AST being harder to understand, I kind of agree but believe it is a matter of time before one gets used to it. On this matter I would recommend the excellent hands-on documentation Green Tree Snake.
I have been working during the past months on a version of py2puml using solely AST which I will send a pull request for as soon as it gives decent results. It is still on a Proof Of Concept stage and needs some bug fixing.
py2puml uses internally a mix of code inspection and Abstract Syntax Tree parsing. The whole code based should be refactored to use AST parsing only as it is more robust and straightforward.