Skip to content

Commit 31f778a

Browse files
committed
Fix(doc): Fix DPF operator doc update of the toc.yml
1 parent 1299992 commit 31f778a

File tree

2 files changed

+15
-36
lines changed

2 files changed

+15
-36
lines changed

src/ansys/dpf/core/documentation/generate_operators_doc.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ def generate_operator_doc(
374374
file.write(output)
375375

376376

377-
def generate_toc_tree(docs_path: Path):
378-
"""Write the global toc.yml file for the DPF documentation based on the operators found.
377+
def update_toc_tree(docs_path: Path):
378+
"""Update the global toc.yml file for the DPF documentation based on the operators found.
379379
380380
Parameters
381381
----------
@@ -391,7 +391,7 @@ def generate_toc_tree(docs_path: Path):
391391
operators = [] # Reset operators for each category
392392
for file in folder.iterdir():
393393
if (
394-
file.is_file() and file.suffix == ".md"
394+
file.is_file() and file.suffix == ".md" and not file.name.endswith("_upd.md")
395395
): # Ensure 'file' is a file with .md extension
396396
file_name = file.name
397397
file_path = f"{category}/{file_name}"
@@ -405,10 +405,18 @@ def generate_toc_tree(docs_path: Path):
405405
template = jinja2.Template(template_file.read())
406406
output = template.render(data=data) # Pass 'data' as a named argument
407407

408-
# Write the rendered output to toc.yml at the operators_doc level
408+
# Update the original toc.yml file with the rendered output for operator_specifications
409409
toc_path = docs_path / Path("toc.yml")
410+
with toc_path.open(mode="r") as file:
411+
original_toc = file.read()
412+
new_toc = re.sub(
413+
pattern=r"- name: Operator specifications\s*.*?(?=- name: Changelog|\Z)",
414+
repl=output,
415+
string=original_toc,
416+
flags=re.DOTALL,
417+
)
410418
with toc_path.open(mode="w") as file:
411-
file.write(output)
419+
file.write(new_toc)
412420

413421

414422
def generate_operators_doc(
@@ -452,7 +460,7 @@ def generate_operators_doc(
452460
for operator_name in operators:
453461
generate_operator_doc(server, operator_name, include_private, output_path)
454462
# Generate the toc tree
455-
generate_toc_tree(output_path)
463+
update_toc_tree(output_path)
456464
# Use update files in output_path
457465
update_operator_descriptions(output_path)
458466

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
- name: Introduction
2-
href: index.md
3-
- name: Getting started
4-
items:
5-
- name: Installation
6-
href: getting-started/installation.md
7-
- name: Licensing
8-
href: getting-started/licensing.md
9-
- name: Configuration
10-
href: getting-started/configuration.md
11-
- name: User guide
12-
items:
13-
- name: The server context
14-
href: user-guide/server-context.md
15-
- name: How to use data containers
16-
href: user-guide/using-data-containers.md
17-
- name: How to use operators
18-
href: user-guide/using-operators.md
19-
- name: Workflow examples for beginners
20-
href: user-guide/workflow-examples.md
21-
- name: Build local documentation
22-
href: user-guide/dpf-docs-local-preview.md
23-
- name: Core concepts
24-
items:
25-
- name: Available types
26-
href: core-concepts/dpf-types.md
27-
- name: Operator fundamentals
28-
href: core-concepts/operator.md
291
- name: Operator specifications
302
items:
313
- name: Operator specifications
@@ -36,5 +8,4 @@
368
- name: {{ operator.operator_name }}
379
href: operator-specifications/{{ operator.file_path }}{% endfor %}
3810
{% endfor %}
39-
- name: Changelog
40-
href: changelog/changelog.md
11+

0 commit comments

Comments
 (0)