diff --git a/examples/readme.md b/examples/readme.md new file mode 100644 index 0000000..92a0c3f --- /dev/null +++ b/examples/readme.md @@ -0,0 +1,25 @@ +# Example gallery +## Example 01 +![](ex01.png) + +[Source](ex01.yml) + + +## Example 02 +![](ex02.png) + +[Source](ex02.yml) + + +## Example 03 +![](ex03.png) + +[Source](ex03.yml) + + +## Example 04 +![](ex04.png) + +[Source](ex04.yml) + + diff --git a/readme.md b/readme.md index 2395ee7..6aba0a7 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,9 @@ WireViz is a simple yet flexible, YAML-based markup language for documenting cab _Note_: WireViz is not designed to represent the complete wiring of a system. Its main aim is to document the construction of individual wires and harnesses. -## Demo +## Examples + +### Demo 01 [WireViz input file](examples/demo01.yml): @@ -61,15 +63,20 @@ Output file: ![Sample output diagram](examples/demo01.png) -[Example 2](examples/demo02.yml) +### Demo 02 ![](examples/demo02.png) +[Source](examples/demo02.yml) + +### More examples + +See the [example gallery](examples/) and included readme file. + ## Status This is very much a [work in progress](todo.md). - ## License GNU GPLv3 diff --git a/src/batch.py b/src/batch.py index f36356e..19bc386 100644 --- a/src/batch.py +++ b/src/batch.py @@ -1,11 +1,21 @@ import wireviz +import os -# TODO: make examples (progressively more complex), batch process all of them -for i in range(1,3): - fn = '../examples/demo{:02d}.yml'.format(i) - print(fn) - wireviz.parse(fn) -for i in range(1,5): - fn = '../examples/ex{:02d}.yml'.format(i) - print(fn) - wireviz.parse(fn) +readme = '../examples/readme.md' +readme = os.path.abspath(readme) + +with open(readme, 'w') as file: + file.write('# Example gallery\n') + for i in range(1,3): + fn = '../examples/demo{:02d}.yml'.format(i) + print(fn) + wireviz.parse(fn) + + for i in range(1,5): + fn = '../examples/ex{:02d}.yml'.format(i) + print(fn) + wireviz.parse(fn) + + file.write('## Example {:02d}\n'.format(i)) + file.write('![](ex{:02d}.png)\n\n'.format(i)) + file.write('[Source](ex{:02d}.yml)\n\n\n'.format(i))