diff --git a/pipeline/toctree.py b/pipeline/toctree.py index df278d93..f263d766 100644 --- a/pipeline/toctree.py +++ b/pipeline/toctree.py @@ -2,6 +2,7 @@ from typing import List from rstcloth import RstCloth +from pipeline.utils import count_instances def create_toc_tree_page(version:str, relative_path:List[str]): target_file = os.path.join("target", f"{version}/docs/{'/'.join(relative_path)}.rst") @@ -27,12 +28,13 @@ def create_toc_tree_page(version:str, relative_path:List[str]): new_relative_path.extend(relative_path) new_relative_path.append(sub_dir) create_toc_tree_page(version, new_relative_path) - if heading == "Instance libraries": - doc.note(content="The instance libraries are continuously extended and optimized. You can " - "request the registration of new instances or corrections\/extensions of existing " - "instances by raising an issue on `openMINDS_instances " - "`_.") + instances_count = count_instances(version) + doc.note(content=["The instance libraries are continuously extended and optimized.", + "You can request the registration of new instances or corrections\/extensions of existing", + "instances by raising an issue on `openMINDS_instances `_", + "", + f"The {version} version of openMINDS contains {instances_count} metadata instances in total."]) for link in links: doc.content(link) diff --git a/pipeline/utils.py b/pipeline/utils.py index b0696fd5..6b29e17a 100644 --- a/pipeline/utils.py +++ b/pipeline/utils.py @@ -22,6 +22,11 @@ def clone_sources(): shutil.rmtree("sources_instances") Repo.clone_from("https://github.com/openMetadataInitiative/openMINDS_instances.git", to_path="sources_instances", depth=1) + +def count_instances(version:str) -> int: + instances_sources = os.path.join(os.path.realpath("."), "sources_instances", "instances", version) + return sum(1 for _ in glob.iglob(os.path.join(instances_sources, '**', '*.jsonld'), recursive=True)) + class SchemaLoader(object): def __init__(self):