doc: update

This commit is contained in:
Ferrari Martino Giordano
2024-03-20 16:06:04 +01:00
parent 6ea27eb5ab
commit 1bf403a339
6 changed files with 78 additions and 18 deletions
+6 -3
View File
@@ -4,14 +4,12 @@ Main entry point for the MARTe Autodoc project"
Author: Martino Ferrari
Email: martinogiordano.ferrari@iter.org
"""
import json
import logging
import os
import sys
from argparse import ArgumentParser
from MARTe.StandardParser import ParseException, StandardParser
import autodoc
__version__ = "0.0.0"
@@ -36,6 +34,7 @@ def __args__():
default="ERROR",
help="Logging level (default: `ERROR`)",
)
parser.add_argument("--build", help="build output flag", default=True)
parser.add_argument("--version", action="version", version=__version__)
parser.add_argument(
"-d", "--destination", help="Destination folder", type=str, default="."
@@ -53,6 +52,8 @@ def main():
sys.exit(1)
config = {}
if args.type == "marte":
from MARTe.StandardParser import ParseException, StandardParser
parser = StandardParser()
try:
config = parser.parse_file(args.filename)
@@ -65,6 +66,8 @@ def main():
logging.error(f"Sometihng went wrong with file `{args.filename}`")
sys.exit(1)
else:
import json
with open(args.filename, "r") as file:
config = json.load(file)
if not config:
+10 -8
View File
@@ -53,6 +53,7 @@ def __doc_application__(label, app):
def document(fname, args, config):
"""Document MARTe object."""
doc.set_path(os.path.join(args.destination, fname))
doc.set_config(args)
if not os.path.isdir(doc.path()):
os.mkdir(doc.path())
now = datetime.now() # current date and time
@@ -79,11 +80,12 @@ def document(fname, args, config):
logging.info(f"Saving markdown: {fpath}")
with open(fpath, "w") as file:
file.write(mddoc)
logging.info(f"Generating html: {outpath}.html")
os.system(
f"pandoc --css pandoc/styling.css --resource-path={doc.path()} --embed-resource --to html5 -s {fpath} -o {outpath}.html"
)
logging.info(f"Generating pdf: {outpath}.pdf")
os.system(
f"pandoc -H pandoc/disable_float.tex --resource-path={doc.path()} -s {fpath} -o {outpath}.pdf"
)
if doc.build():
logging.info(f"Generating html: {outpath}.html")
os.system(
f"pandoc --css pandoc/styling.css --resource-path={doc.path()} --embed-resource --to html5 -s {fpath} -o {outpath}.html"
)
logging.info(f"Generating pdf: {outpath}.pdf")
os.system(
f"pandoc -H pandoc/disable_float.tex --resource-path={doc.path()} -s {fpath} -o {outpath}.pdf"
)
+16
View File
@@ -1,6 +1,7 @@
import logging
__PATH__ = "."
__CONFIG__ = None
def signal(obj, label, type):
@@ -84,3 +85,18 @@ def path():
def set_path(path):
global __PATH__
__PATH__ = path
def set_config(config):
global __CONFIG__
__CONFIG__ = config
def config():
global __CONFIG__
return __CONFIG__
def build():
global __CONFIG__
return str(__CONFIG__.build).upper() == "TRUE"
+6 -5
View File
@@ -620,9 +620,10 @@ def __state_simple_graph__(label, state, app):
def doc_state(label, state, app):
fname = f"{label[1:]}"
src_path = __state_full_graph__(label, state, app)
os.system(f"dot -Tsvg -o{os.path.join(doc.path(), fname)}_full.svg {src_path}")
src_path = __state_simple_graph__(label, state, app)
os.system(f"dot -Tsvg -o{os.path.join(doc.path(), fname)}.svg {src_path}")
if doc.build():
logging.info(f"Building svg grpah {fname}")
src_path = __state_full_graph__(label, state, app)
os.system(f"dot -Tsvg -o{os.path.join(doc.path(), fname)}_full.svg {src_path}")
src_path = __state_simple_graph__(label, state, app)
os.system(f"dot -Tsvg -o{os.path.join(doc.path(), fname)}.svg {src_path}")
return f"![{fname} state]({fname}.svg)" + "{width=100% height=90%}\n"
+3 -2
View File
@@ -38,7 +38,8 @@ def doc_state_machine(name, obj):
with open(gpath + ".dot", "w") as f:
f.write(graph)
logging.info(f"Converting state machine graph: {gpath}.svg")
os.system(f"dot -Tsvg -o{gpath}.svg {gpath}.dot")
if common.build():
logging.info(f"Converting state machine graph: {gpath}.svg")
os.system(f"dot -Tsvg -o{gpath}.svg {gpath}.dot")
return f"![{name}]({name}.svg)" + "{width=90%}\n"