Skip to content
Snippets Groups Projects
Commit 40e4fb0a authored by Pieter Donker's avatar Pieter Donker
Browse files

Task #893: now default help, and documentation of one or more peripheral and system

parent 7d8bbfbb
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ if __name__ == "__main__":
# Parse command line arguments
parser = argparse.ArgumentParser(description="""
=Args demo=\r
=Args demo=
system and peripheral config command line parser arguments
""")
parser.add_argument('-p','--peripheral', nargs='*', default=[], help="peripheral names separated by spaces")
......@@ -86,6 +86,9 @@ if __name__ == "__main__":
parser.add_argument('-v','--verbosity', default='INFO', help="verbosity level can be [ERROR | WARNING | INFO | DEBUG]")
args = parser.parse_args()
if not args.peripheral and not args.system:
parser.print_help()
unit_logger.set_stdout_log_level(args.verbosity)
logger.debug("Used arguments: {}".format(args))
......
......@@ -34,6 +34,7 @@ import argparse
import subprocess
import traceback
import yaml
import time
from subprocess import CalledProcessError
from pylatex import Document, Section, Subsection, Command, Package, Tabular, MultiColumn, MultiRow, SmallText, LargeText
from pylatex.utils import italic, bold, NoEscape, verbatim, escape_latex
......@@ -45,6 +46,7 @@ import common as cm
def main():
try:
for systemname in args.system:
try:
system_filename = "./systems/{}.system.yaml".format(systemname)
config = yaml.load(open(system_filename, "r"))
name = config['system_name']
......@@ -52,21 +54,35 @@ def main():
system = System(system_filename)
documentation.add(config['system_name'], system)
documentation.generate_pdf()
del documentation
del system
time.sleep(1.0)
except CalledProcessError:
pass
for peripheralname in args.peripheral:
try:
peripheral_filename = "./peripherals/{}.peripheral.yaml".format(peripheralname)
logger.info("Load peripheral(s) from '%s'", peripheral_filename)
config = yaml.load(open(peripheral_filename, "r"))
name = config['hdl_library_name']
for peripheral_config in config['peripherals']:
peripheral = Peripheral(peripheral_config)
logger.info(" read peripheral '%s'" % peripheral.component_name())
peripheral.eval_peripheral()
documentation = Documentation(name)
peripheral = Peripheral(peripheral_filename)
peripheral.eval_peripheral()
documentation.add(config['hdl_library_name'], peripheral)
documentation.generate_pdf()
except IOError:
logger.error("config file '{}' does not exist".format(filename))
del documentation
del system
time.sleep(1.0)
except CalledProcessError:
pass
except IOError:
logger.error("config file '{}' does not exist".format(filename))
class Documentation(object):
""" make documentation for system or peripheral(s)
"""
......@@ -121,7 +137,7 @@ class Documentation(object):
def add_peripheral(self, header, data):
""" add a peripheral to the document """
self.add_section(data.get_name(), data.get_description() )
self.add_section(data.name(), data.get_description() )
def add_system(self, header, data):
""" add a system to the document """
......@@ -310,6 +326,9 @@ if __name__ == "__main__":
parser.add_argument('-v','--verbosity', default='INFO', help="verbosity level can be [ERROR | WARNING | INFO | DEBUG]")
args = parser.parse_args()
if not args.peripheral and not args.system:
parser.print_help()
unit_logger.set_stdout_log_level(args.verbosity)
logger.debug("Used arguments: {}".format(args))
......
......@@ -413,6 +413,9 @@ if __name__ == "__main__":
parser.add_argument('-v','--verbosity', default='INFO', help="verbosity = [INFO | DEBUG]")
args = parser.parse_args()
if not args.peripheral and not args.system:
parser.print_help()
unit_logger.set_stdout_log_level(args.verbosity)
logger.debug("Used arguments: {}".format(args))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment