소스 검색

Add usage section to README

Arkadiusz Ryś 2 년 전
부모
커밋
bfa8335a70
1개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 24 1
      README.md

+ 24 - 1
README.md

@@ -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