Add parse_file() function and use it in build_examples.py
This commit is contained in:
parent
5d84bb86eb
commit
7060c38f07
@ -15,7 +15,7 @@ if demos:
|
|||||||
for i in range(1,demos+1):
|
for i in range(1,demos+1):
|
||||||
fn = '../../examples/demo{:02d}.yml'.format(i)
|
fn = '../../examples/demo{:02d}.yml'.format(i)
|
||||||
print(fn)
|
print(fn)
|
||||||
wireviz.parse(fn, generate_bom=True)
|
wireviz.parse_file(fn, generate_bom=True)
|
||||||
|
|
||||||
if examples:
|
if examples:
|
||||||
with open(os.path.abspath('../../examples/readme.md'), 'w') as file:
|
with open(os.path.abspath('../../examples/readme.md'), 'w') as file:
|
||||||
@ -23,7 +23,7 @@ if examples:
|
|||||||
for i in range(1,examples+1):
|
for i in range(1,examples+1):
|
||||||
fn = '../../examples/ex{:02d}.yml'.format(i)
|
fn = '../../examples/ex{:02d}.yml'.format(i)
|
||||||
print(fn)
|
print(fn)
|
||||||
wireviz.parse(fn, generate_bom=True)
|
wireviz.parse_file(fn, generate_bom=True)
|
||||||
|
|
||||||
file.write('## Example {:02d}\n'.format(i))
|
file.write('## Example {:02d}\n'.format(i))
|
||||||
file.write('\n\n'.format(i))
|
file.write('\n\n'.format(i))
|
||||||
@ -35,7 +35,7 @@ if tutorials:
|
|||||||
for i in range(1,tutorials+1):
|
for i in range(1,tutorials+1):
|
||||||
fn = '../../tutorial/tutorial{:02d}.yml'.format(i)
|
fn = '../../tutorial/tutorial{:02d}.yml'.format(i)
|
||||||
print(fn)
|
print(fn)
|
||||||
wireviz.parse(fn, generate_bom=True)
|
wireviz.parse_file(fn, generate_bom=True)
|
||||||
|
|
||||||
with open(os.path.abspath('../../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info:
|
with open(os.path.abspath('../../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info:
|
||||||
for line in info:
|
for line in info:
|
||||||
|
|||||||
@ -618,6 +618,18 @@ def parse(yaml_input, file_out=None, generate_bom=False):
|
|||||||
|
|
||||||
h.output(filename=file_out, format=('png','svg'), gen_bom=generate_bom, view=False)
|
h.output(filename=file_out, format=('png','svg'), gen_bom=generate_bom, view=False)
|
||||||
|
|
||||||
|
def parse_file(yaml_file, file_out=None, generate_bom=False):
|
||||||
|
with open(yaml_file, 'r') as file:
|
||||||
|
yaml_input = file.read()
|
||||||
|
|
||||||
|
if not file_out:
|
||||||
|
fn, fext = os.path.splitext(yaml_file)
|
||||||
|
file_out = fn
|
||||||
|
file_out = os.path.abspath(file_out)
|
||||||
|
|
||||||
|
parse(yaml_input, file_out=file_out, generate_bom=generate_bom)
|
||||||
|
|
||||||
|
|
||||||
def parse_cmdline():
|
def parse_cmdline():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Generate cable and wiring harness documentation from YAML descriptions'
|
description='Generate cable and wiring harness documentation from YAML descriptions'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user