Auto-generate example gallery

This commit is contained in:
Daniel Rojas 2020-05-30 11:51:32 +02:00
parent 8aeabd03c3
commit d86ec0ad68
3 changed files with 54 additions and 12 deletions

25
examples/readme.md Normal file
View File

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

View File

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

View File

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