diff --git a/autodoc/autodoc.py b/autodoc/autodoc.py index ca0699b..e2ecc4d 100644 --- a/autodoc/autodoc.py +++ b/autodoc/autodoc.py @@ -1,7 +1,6 @@ """ Autodoc functions """ -import logging import os import common as doc diff --git a/autodoc/doc_state.py b/autodoc/doc_state.py index 53e40a7..e972359 100644 --- a/autodoc/doc_state.py +++ b/autodoc/doc_state.py @@ -88,80 +88,118 @@ def __doc_triggered_iogam__(name, obj, edges, thread): return node, edges +__set_keys__ = ( + "Alias", + "Type", + "DataSource", + "NumberOfElements", + "NumberOfDimensions", + "Ranges", +) + + def __doc_iogam__(id, obj, edges, thread): node = "" if "InputSignals" in obj and "OutputSignals" in obj: inputs, outputs = obj["InputSignals"], obj["OutputSignals"] output_names = list(outputs.keys()) input_names = list(inputs.keys()) - j = 0 input_size = 0 output_size = 0 - i = 0 - irow = "" - orow = "" + out_i = 0 + in_i = 0 counter = 0 - while i < len(inputs) and j < len(outputs): - irelcount = 0 - orelcount = 0 + while in_i < len(inputs) and out_i < len(outputs): + irows = [] + orows = [] bold = False - while input_size <= output_size and i < len(inputs): - in_label = input_names[i] + while input_size <= output_size and in_i < len(inputs): + in_label = input_names[in_i] input = inputs[in_label] - if irow: - irow += " | " input_size += doc.signal_byte_size(input) - i += 1 + in_i += 1 alias = doc.signal_alias(in_label, input) mtype = doc.signal_type(input) if mtype[2]: bold = True - irow += f" {doc.type_to_string(mtype)}" + irow = f"{doc.type_to_string(mtype)}" + for key, val in input.items(): + if key not in __set_keys__: + bold = True + irow += f"
{key}: {val}" datasrc = input["DataSource"] edges.append( doc.edge( doc.signal(datasrc, alias, mtype), - doc.signal(f"{id}_{counter}", f"{irelcount}", mtype), + doc.signal(f"{id}_{counter}", f"{len(irows)}", mtype), thread, ) ) - irelcount += 1 - while output_size < input_size and j < len(outputs): - out_label = output_names[j] + irows.append(irow) + while output_size < input_size and out_i < len(outputs): + out_label = output_names[out_i] output = outputs[out_label] output_size += doc.signal_byte_size(output) - if orow: - orow += " | " - j += 1 + out_i += 1 alias = doc.signal_alias(out_label, output) mtype = doc.signal_type(output) if mtype[2]: bold = True - orow += f" {doc.type_to_string(mtype)}" + orow = f"{doc.type_to_string(mtype)}" + for key, val in output.items(): + if key not in __set_keys__: + bold = True + orow += f"
{key}: {val}" datasrc = output["DataSource"] edges.append( doc.edge( - doc.signal(f"{id}_{counter}", f"{orelcount}", mtype), + doc.signal(f"{id}_{counter}", f"{len(orows)}", mtype), doc.signal(datasrc, alias, mtype), thread, ) ) - orelcount += 1 + orows.append(orow) fill = "#fff" - fsize = 14.0 - if bold or irelcount > 1 or orelcount > 1: + total = max(len(orows), len(irows)) + if bold or total > 1: fill = "#333" + bold = True else: - irow = f" " - orow = f"" fill = "#666" - fsize = 0.0 - node += f'{id}_{counter} [tooltip=" IOGAM::{id} " label="' - node += "{ {" + irow + "} | {" + orow + "} }" - node += f'", fillcolor="{fill}", color="#666", style=filled,' - node += f' fontcolor="#fff", fontsize={fsize}, height=0, width=0];\n' - irow = "" - orow = "" + + inode = f"{id}_{counter} [shape=plaintext," + inode += f'tooltip=" IOGAM::{id} ", label=<' + inode += "" + + if bold: + for i in range(total): + inode += "" + if i < len(irows): + inode += f'" + if i < len(orows): + inode += f'
len(irows): + inode += f' rowspan="{len(orows)}"' + inode += ">" + inode += '' + inode += irows[i] + inode += " {l}" + if inputs: + node += inputs + '"];' else: node = "" @@ -233,7 +286,8 @@ def __doc_events__(id, obj, edges, thread): else: nodes += f"{fn} " nodes += "
>];\n" - nodes += f" {id} -> {id}_{event_id}_{msg_id} [arrowhead=box];\n" + nodes += f" {id}:e -> {id}_{event_id}_{msg_id}:w" + nodes += " [arrowhead=box, constraint=true];\n" return nodes, edges @@ -370,20 +424,23 @@ def __process_ds__(name, obj, edges): for sig in sigs: if sig not in order: lost.append(sig) - node = f'{name} [label="{name}\n{cls} | ' + node = f"{name} [shape=plaintext; label=<" + node += ( + '\n' + ) + node += f"\n" for i, sig_name in enumerate(order): - if i > 0: - node += " | " + node += f'\n" for sig_name in lost: logging.warning(f"Lost signal {name}:{sig_name}") - if node: - node += " | " + node += f'\n" + node += "
{name}
{cls}
' sig_type = sigs[sig_name] - node += f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})" - + node += f"{sig_name} ({doc.type_to_string(sig_type)})" + node += "
' sig_type = sigs[sig_name] - node += f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})" - node += '", color=blue];\n' + node += f"{sig_name} ({doc.type_to_string(sig_type)})" + node += "
>, color=blue];\n" if not multi_thread and node: node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n" return node, edges @@ -398,6 +455,7 @@ def __process_edges__(edges, datasources): trg_sig = doc.format_name(target[1]) a = f"{src_obj}" b = f"{trg_obj}" + ranked = True if src_obj in datasources: a += f":{src_sig}" else: @@ -410,7 +468,8 @@ def __process_edges__(edges, datasources): in_type = doc.type_to_string(source[2]) out_type = doc.type_to_string(target[2]) mtype = in_type if in_type == out_type else f"{in_type} -> {out_type}" - arrows += f'{a} -> {b} [tooltip=" {mtype} ", labelfloat=false];\n' + arrows += f'{a}:e -> {b}:w [tooltip=" {mtype} ", labelfloat=false' + arrows += f", constraint={ranked}];\n" return arrows @@ -418,8 +477,8 @@ def doc_state(label, state, app): global __PATH__ mdstate = "" graph = f"digraph {label[1:]}" + "{\n" - graph += "ranksep = 1;\n" - graph += "nodesep = 0.5;\n" + graph += "ranksep = 2;\n" + graph += "nodesep = 0.05;\n" graph += "rankdir = LR;\n" graph += "node [shape=Mrecord];\n" graph += f"label={label[1:]}>;\n"