|
|
@@ -13,4 +13,27 @@ https://msdl.uantwerpen.be/git/jexelmans/drawio2oml
|
|
|
## Dependencies
|
|
|
|
|
|
Only the Python 3 standard library.
|
|
|
-Developed with Python 3.10.
|
|
|
+Developed with Python 3.10.
|
|
|
+
|
|
|
+## Using
|
|
|
+
|
|
|
+Parsing a diagram is as simple as the following snippet:
|
|
|
+
|
|
|
+ from drawio2py import parser
|
|
|
+ from drawio2py.abstract_syntax import DrawIOFile
|
|
|
+
|
|
|
+ abstract_syntax: DrawIOFile = parser.Parser.parse("diagram.drawio")
|
|
|
+
|
|
|
+Once in the Python memory structure the diagram can be traversed like a tree.
|
|
|
+The annotated class type `DrawIOFile` and its structure can be explored in the [abstract syntax file][asf].
|
|
|
+You can even output the corresponding, uncompressed, diagram:
|
|
|
+
|
|
|
+ from drawio2py import generator
|
|
|
+ from pathlib import Path
|
|
|
+
|
|
|
+ with Path("diagram.drawio").open(mode="wb") as output_file:
|
|
|
+ generator.generate(abstract_syntax, output_file)
|
|
|
+
|
|
|
+Here `abstract_syntax` refers to the previous snippet.
|
|
|
+
|
|
|
+[asf]: ./drawio2py/abstract_syntax.py
|