From 1a5ccd23a21774ac382bc7e60d7e0ed43bc43978 Mon Sep 17 00:00:00 2001 From: niclas Date: Tue, 5 Mar 2024 12:40:17 +0100 Subject: [PATCH] Add [graph] cluster description --- tools/mkdocs/generator.py | 2 +- .../site/docs/01_attachements/javascripts/graph.js | 7 ++++--- tools/mkdocs/utils/helper.py | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/mkdocs/generator.py b/tools/mkdocs/generator.py index 34bd3cd..e3fddd3 100644 --- a/tools/mkdocs/generator.py +++ b/tools/mkdocs/generator.py @@ -24,7 +24,7 @@ def write_relations_table(cluster): if cluster.relationships: print(f"Writing {cluster.uuid}.md") with open(os.path.join(relation_path, f"{cluster.uuid}.md"), "w") as index: - index.write(generate_relations_table(cluster.relationships)) + index.write(generate_relations_table(cluster)) def get_cluster_relationships(cluster_data): diff --git a/tools/mkdocs/site/docs/01_attachements/javascripts/graph.js b/tools/mkdocs/site/docs/01_attachements/javascripts/graph.js index 1e6d2ff..7b6a682 100644 --- a/tools/mkdocs/site/docs/01_attachements/javascripts/graph.js +++ b/tools/mkdocs/site/docs/01_attachements/javascripts/graph.js @@ -119,8 +119,9 @@ document$.subscribe(function () { })); let header = document.querySelector('h1').textContent; - const parentUUID = header.replace(/\s+/g, '-').charAt(0).toLowerCase() + header.replace(/\s+/g, '-').slice(1); - const Parent_Node = nodes.find(node => node.id.includes(parentUUID)); + // const parentUUID = header.replace(/\s+/g, '-').charAt(0).toLowerCase() + header.replace(/\s+/g, '-').slice(1); + // console.log("Parent UUID: " + parentUUID); + const Parent_Node = nodes.find(node => node.id.includes(header)); var links = data.map(d => ({ source: d.source, target: d.target })); @@ -140,7 +141,7 @@ document$.subscribe(function () { var simulation = d3.forceSimulation(nodes) .force("link", d3.forceLink(links).id(d => d.id).distance(linkDistance)) - .force("charge", d3.forceManyBody().strength(-50).distanceMax(500)) + .force("charge", d3.forceManyBody().strength(-70)) .force("center", d3.forceCenter(width / 2, height / 2)) .alphaDecay(0.05); // A lower value, adjust as needed diff --git a/tools/mkdocs/utils/helper.py b/tools/mkdocs/utils/helper.py index 73c257b..1d05705 100644 --- a/tools/mkdocs/utils/helper.py +++ b/tools/mkdocs/utils/helper.py @@ -67,8 +67,11 @@ def galaxy_transform_to_link(galaxy): return f"[{galaxy.galaxy_name}](../../{galaxy_folder}/index.md)" -def generate_relations_table(relationships): - markdown = "|Cluster A | Galaxy A | Cluster B | Galaxy B | Level { .graph } |\n" +def generate_relations_table(cluster): + relationships = cluster.relationships + markdown = f"# {cluster.value} \n\n" + markdown += f"{cluster.description} \n\n" + markdown += "|Cluster A | Galaxy A | Cluster B | Galaxy B | Level { .graph } |\n" markdown += "| --- | --- | --- | --- | --- |\n" for from_cluster, to_cluster, level in relationships: from_galaxy = from_cluster.galaxy @@ -76,5 +79,5 @@ def generate_relations_table(relationships): to_galaxy = to_cluster.galaxy markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {cluster_transform_to_link(to_cluster, uuid=True)} | {galaxy_transform_to_link(to_galaxy)} | {level}\n" else: - markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {to_cluster.value} | Unknown | {level}\n" + markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {to_cluster.value} ({to_cluster.uuid}) | Unknown | {level}\n" return markdown