diff --git a/tools/mkdocs/generator.py b/tools/mkdocs/generator.py index 6943b1f..0a8c528 100644 --- a/tools/mkdocs/generator.py +++ b/tools/mkdocs/generator.py @@ -10,6 +10,8 @@ import validators CLUSTER_PATH = "../../clusters" SITE_PATH = "./site/docs" +GALAXY_PATH = "../../galaxies" + FILES_TO_IGNORE = [] # if you want to skip a specific cluster in the generation @@ -63,6 +65,7 @@ class Galaxy: def __init__( self, cluster_list: List[dict], authors, description, name, json_file_name ): + self.cluster_list = cluster_list self.authors = authors self.description = description @@ -203,7 +206,9 @@ class Cluster: if meta not in excluded_meta: self.entry += f" | {meta} | {self.meta[meta]} |\n" - def get_related_clusters(self, cluster_dict, depth=-1, visited=None, level=1): + def get_related_clusters( + self, cluster_dict, depth=-1, visited=None, level=1, related_private_clusters={} + ): global public_relations_count global private_relations_count global private_clusters @@ -234,21 +239,31 @@ class Cluster: private_relations_count += 1 if dest_uuid not in private_clusters: private_clusters.append(dest_uuid) - related_clusters.append( - ( - self, - Cluster( - value="Private Cluster", - uuid=dest_uuid, - date=None, - description=None, - related_list=None, - meta=None, - galaxie=None, - ), - level, + if dest_uuid in related_private_clusters: + related_clusters.append( + ( + self, + related_private_clusters[dest_uuid], + level, + ) ) - ) + else: + related_clusters.append( + ( + self, + Cluster( + value="Private Cluster", + uuid=dest_uuid, + date=None, + description=None, + related_list=None, + meta=None, + galaxie=None, + ), + level, + ) + ) + related_private_clusters[dest_uuid] = related_clusters[-1][1] continue related_cluster = cluster_dict[dest_uuid] @@ -265,7 +280,13 @@ class Cluster: if cluster["dest-uuid"] in cluster_dict: related_clusters += cluster_dict[ cluster["dest-uuid"] - ].get_related_clusters(cluster_dict, new_depth, visited, level + 1) + ].get_related_clusters( + cluster_dict, + new_depth, + visited, + level + 1, + related_private_clusters, + ) if empty_uuids > 0: empty_uuids_dict[self.value] = empty_uuids @@ -370,9 +391,9 @@ class Cluster: def create_index(galaxies): index_output = INTRO - index_output += STATISTICS for galaxie in galaxies: index_output += f"- [{galaxie.name}](./{galaxie.json_file_name}/index.md)\n" + index_output += STATISTICS index_output += CONTRIBUTING return index_output @@ -482,8 +503,21 @@ def create_statistics(cluster_dict): return statistic_output +def get_deprecated_galaxy_files(): + deprecated_galaxy_files = [] + for f in os.listdir(GALAXY_PATH): + with open(os.path.join(GALAXY_PATH, f)) as fr: + galaxy_json = json.load(fr) + if "namespace" in galaxy_json and galaxy_json["namespace"] == "deprecated": + deprecated_galaxy_files.append(f) + + return deprecated_galaxy_files + + def main(): start_time = time.time() + + FILES_TO_IGNORE.extend(get_deprecated_galaxy_files()) galaxies_fnames = [] for f in os.listdir(CLUSTER_PATH): if ".json" in f and f not in FILES_TO_IGNORE: