From ac2f6022e779a5ae3efacc0fb3ec9673f5ef9d01 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Mon, 27 Oct 2025 10:48:38 +0100 Subject: [PATCH 1/5] feat(operator_doc): add supported file types for source operators --- .../documentation/generate_operators_doc.py | 49 +++++++++++++++++-- ...c_template.md => operator_doc_template.j2} | 6 ++- 2 files changed, 51 insertions(+), 4 deletions(-) rename src/ansys/dpf/core/documentation/{operator_doc_template.md => operator_doc_template.j2} (96%) diff --git a/src/ansys/dpf/core/documentation/generate_operators_doc.py b/src/ansys/dpf/core/documentation/generate_operators_doc.py index dd963af263e..cd0f583da27 100644 --- a/src/ansys/dpf/core/documentation/generate_operators_doc.py +++ b/src/ansys/dpf/core/documentation/generate_operators_doc.py @@ -347,7 +347,11 @@ def get_plugin_operators(server: dpf.AnyServerType, plugin_name: str) -> list[st def generate_operator_doc( - server: dpf.AnyServerType, operator_name: str, include_private: bool, output_path: Path + server: dpf.AnyServerType, + operator_name: str, + include_private: bool, + output_path: Path, + router_info: dict, ): """Write the Markdown documentation page for a given operator on a given DPF server. @@ -361,9 +365,23 @@ def generate_operator_doc( Whether to generate the documentation if the operator is private. output_path: Path to write the operator documentation at. + router_info: + Information about router operators. """ operator_info = fetch_doc_info(server, operator_name) + operator_info["is_router"] = operator_name in router_info["router_map"].keys() + supported_file_types = {} + if operator_info["is_router"]: + supported_keys = router_info["router_map"].get(operator_name, []) + for key in supported_keys: + if key in router_info["namespace_ext_map"]: + namespace = router_info["namespace_ext_map"][key] + if namespace not in supported_file_types: + supported_file_types[namespace] = [key] + else: + supported_file_types[namespace].append(key) + operator_info["supported_file_types"] = supported_file_types scripting_name = operator_info["scripting_info"]["scripting_name"] category: str = operator_info["scripting_info"]["category"] if scripting_name: @@ -374,7 +392,7 @@ def generate_operator_doc( file_name = file_name.replace("::", "_") if not include_private and operator_info["exposure"] == "private": return - template_path = Path(__file__).parent / "operator_doc_template.md" + template_path = Path(__file__).parent / "operator_doc_template.j2" spec_folder = output_path / Path("operator-specifications") category_dir = spec_folder / category spec_folder.mkdir(parents=True, exist_ok=True) @@ -493,6 +511,30 @@ def update_operator_index(docs_path: Path): index_file.write("\n") +def get_operator_routing_info(server: dpf.AnyServerType) -> dict: + """Get information about router operators. + + Parameters + ---------- + server: + DPF server to query for the operator routing map. + + Returns + ------- + routing_map: + A dictionary with three main keys: "aliases", "namespace_ext_map", and "router_map". + "aliases" is a dictionary of operator aliases. + "namespace_ext_map" is a dictionary mapping keys to namespaces. + "router_map" is a dictionary mapping operator names to lists of supported keys. + """ + dt_root: dpf.DataTree = dpf.dpf_operator.Operator( + name="info::router_discovery", + server=server, + ).eval() + router_info: dict = dt_root.to_dict() + return router_info + + def generate_operators_doc( output_path: Path, ansys_path: Path = None, @@ -531,8 +573,9 @@ def generate_operators_doc( operators = available_operator_names(server) else: operators = get_plugin_operators(server, desired_plugin) + router_info = get_operator_routing_info(server) for operator_name in operators: - generate_operator_doc(server, operator_name, include_private, output_path) + generate_operator_doc(server, operator_name, include_private, output_path, router_info) # Generate the toc tree update_toc_tree(output_path) # Generate the category index files diff --git a/src/ansys/dpf/core/documentation/operator_doc_template.md b/src/ansys/dpf/core/documentation/operator_doc_template.j2 similarity index 96% rename from src/ansys/dpf/core/documentation/operator_doc_template.md rename to src/ansys/dpf/core/documentation/operator_doc_template.j2 index 3476628f859..55e7906df43 100644 --- a/src/ansys/dpf/core/documentation/operator_doc_template.md +++ b/src/ansys/dpf/core/documentation/operator_doc_template.j2 @@ -11,7 +11,11 @@ license: {{ scripting_info.license }} ## Description {{ operator_description }} - +{% if is_router %} +## Supported file types +{% for namespace in supported_file_types | sort %} +- {{ namespace }}: {% for file_type in supported_file_types[namespace] %}{{ file_type }}{% endfor %}{% endfor %} +{% endif %} ## Inputs | Input | Name | Expected type(s) | Description | From 679929e0602d6152466c77fcd65a0bd015eb6d78 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Mon, 27 Oct 2025 11:42:48 +0100 Subject: [PATCH 2/5] feat(operator_doc): add supported file types for source operators --- src/ansys/dpf/core/documentation/generate_operators_doc.py | 4 +++- src/ansys/dpf/core/documentation/operator_doc_template.j2 | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/core/documentation/generate_operators_doc.py b/src/ansys/dpf/core/documentation/generate_operators_doc.py index cd0f583da27..37cab12e32f 100644 --- a/src/ansys/dpf/core/documentation/generate_operators_doc.py +++ b/src/ansys/dpf/core/documentation/generate_operators_doc.py @@ -373,7 +373,7 @@ def generate_operator_doc( operator_info["is_router"] = operator_name in router_info["router_map"].keys() supported_file_types = {} if operator_info["is_router"]: - supported_keys = router_info["router_map"].get(operator_name, []) + supported_keys = router_info["router_map"].get(operator_name, []).split(";") for key in supported_keys: if key in router_info["namespace_ext_map"]: namespace = router_info["namespace_ext_map"][key] @@ -381,6 +381,8 @@ def generate_operator_doc( supported_file_types[namespace] = [key] else: supported_file_types[namespace].append(key) + for namespace, supported_keys in supported_file_types.items(): + supported_file_types[namespace] = ", ".join(sorted(supported_keys)) operator_info["supported_file_types"] = supported_file_types scripting_name = operator_info["scripting_info"]["scripting_name"] category: str = operator_info["scripting_info"]["category"] diff --git a/src/ansys/dpf/core/documentation/operator_doc_template.j2 b/src/ansys/dpf/core/documentation/operator_doc_template.j2 index 55e7906df43..7470f00996c 100644 --- a/src/ansys/dpf/core/documentation/operator_doc_template.j2 +++ b/src/ansys/dpf/core/documentation/operator_doc_template.j2 @@ -13,8 +13,8 @@ license: {{ scripting_info.license }} {{ operator_description }} {% if is_router %} ## Supported file types -{% for namespace in supported_file_types | sort %} -- {{ namespace }}: {% for file_type in supported_file_types[namespace] %}{{ file_type }}{% endfor %}{% endfor %} +{% for namespace, supported_files in supported_file_types.items() | sort %} +- {{ namespace }}: {{ supported_files }} {% endfor %} {% endif %} ## Inputs From 589e9bfec0d3f270111165299de4b08bdf87d64a Mon Sep 17 00:00:00 2001 From: PProfizi Date: Mon, 27 Oct 2025 12:16:09 +0100 Subject: [PATCH 3/5] Fix packaging --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1aeda3fc963..e3e7401c949 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,5 +123,5 @@ where = ["src"] [tool.setuptools.package-data] "ansys.dpf.gatebin" = ["*.so", "*.dll"] -"ansys.dpf.core.documentation" = ["toc_template.j2", "operator_doc_template.md"] +"ansys.dpf.core.documentation" = ["toc_template.j2", "operator_doc_template.j2"] From 987413ef4db7b0be9baea55c1fe342ff62ef84e0 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Mon, 27 Oct 2025 12:20:03 +0100 Subject: [PATCH 4/5] Fix retro --- .../documentation/generate_operators_doc.py | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/ansys/dpf/core/documentation/generate_operators_doc.py b/src/ansys/dpf/core/documentation/generate_operators_doc.py index 37cab12e32f..527acd64fb6 100644 --- a/src/ansys/dpf/core/documentation/generate_operators_doc.py +++ b/src/ansys/dpf/core/documentation/generate_operators_doc.py @@ -351,7 +351,7 @@ def generate_operator_doc( operator_name: str, include_private: bool, output_path: Path, - router_info: dict, + router_info: dict = None, ): """Write the Markdown documentation page for a given operator on a given DPF server. @@ -370,19 +370,22 @@ def generate_operator_doc( """ operator_info = fetch_doc_info(server, operator_name) - operator_info["is_router"] = operator_name in router_info["router_map"].keys() supported_file_types = {} - if operator_info["is_router"]: - supported_keys = router_info["router_map"].get(operator_name, []).split(";") - for key in supported_keys: - if key in router_info["namespace_ext_map"]: - namespace = router_info["namespace_ext_map"][key] - if namespace not in supported_file_types: - supported_file_types[namespace] = [key] - else: - supported_file_types[namespace].append(key) - for namespace, supported_keys in supported_file_types.items(): - supported_file_types[namespace] = ", ".join(sorted(supported_keys)) + if router_info is not None: + operator_info["is_router"] = operator_name in router_info["router_map"].keys() + if operator_info["is_router"]: + supported_keys = router_info["router_map"].get(operator_name, []).split(";") + for key in supported_keys: + if key in router_info["namespace_ext_map"]: + namespace = router_info["namespace_ext_map"][key] + if namespace not in supported_file_types: + supported_file_types[namespace] = [key] + else: + supported_file_types[namespace].append(key) + for namespace, supported_keys in supported_file_types.items(): + supported_file_types[namespace] = ", ".join(sorted(supported_keys)) + else: + operator_info["is_router"] = False operator_info["supported_file_types"] = supported_file_types scripting_name = operator_info["scripting_info"]["scripting_name"] category: str = operator_info["scripting_info"]["category"] @@ -575,7 +578,10 @@ def generate_operators_doc( operators = available_operator_names(server) else: operators = get_plugin_operators(server, desired_plugin) - router_info = get_operator_routing_info(server) + if server.meet_version(required_version="11.0"): + router_info = get_operator_routing_info(server) + else: + router_info = None for operator_name in operators: generate_operator_doc(server, operator_name, include_private, output_path, router_info) # Generate the toc tree From 1bfde801fa58c3b4f6eb1c0f7150b0b36937eb2f Mon Sep 17 00:00:00 2001 From: Paul Profizi <100710998+PProfizi@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:25:39 +0100 Subject: [PATCH 5/5] Add explanation for the supported file types --- src/ansys/dpf/core/documentation/operator_doc_template.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ansys/dpf/core/documentation/operator_doc_template.j2 b/src/ansys/dpf/core/documentation/operator_doc_template.j2 index 7470f00996c..d0301d3cf8d 100644 --- a/src/ansys/dpf/core/documentation/operator_doc_template.j2 +++ b/src/ansys/dpf/core/documentation/operator_doc_template.j2 @@ -13,6 +13,8 @@ license: {{ scripting_info.license }} {{ operator_description }} {% if is_router %} ## Supported file types + +This operator supports the following keys ([file formats](../../index.md#overview-of-dpf)) for each listed namespace (plugin/solver): {% for namespace, supported_files in supported_file_types.items() | sort %} - {{ namespace }}: {{ supported_files }} {% endfor %} {% endif %}