Skip to content

Commit f4cefc2

Browse files
committed
Fixes
1 parent 17a15b9 commit f4cefc2

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ def extract_operator_description_update(content: str) -> str:
112112
Parameters
113113
----------
114114
content:
115-
The contents of the '*-upd.md' file.
115+
The contents of the '*_upd.md' file.
116116
117117
Returns
118118
-------
119119
description_update:
120120
The updated description to use for the operator.
121121
"""
122122
match = re.search(r"## Description\s*(.*?)\s*(?=## |\Z)", content, re.DOTALL)
123-
return match.group(0) if match else None
123+
return match.group(0) + os.linesep if match else None
124124

125125

126126
def replace_operator_description(original_documentation: str, new_description: str):
@@ -145,7 +145,7 @@ def replace_operator_description(original_documentation: str, new_description: s
145145

146146

147147
def update_operator_descriptions(docs_path: Path):
148-
"""Update operator descriptions based on '*-upd.md' files in DPF documentation sources.
148+
"""Update operator descriptions based on '*_upd.md' files in DPF documentation sources.
149149
150150
Parameters
151151
----------
@@ -154,12 +154,12 @@ def update_operator_descriptions(docs_path: Path):
154154
155155
"""
156156
all_md_files = {}
157-
specs_path = docs_path / "operator-specifications"
157+
specs_path = docs_path / Path("operator-specifications")
158158
# Walk through the target directory and all subdirectories
159159
for root, _, files in os.walk(specs_path):
160160
for file in files:
161161
if file.endswith(".md"):
162-
full_path = Path(root) / file
162+
full_path = Path(root) / Path(file)
163163
all_md_files[str(full_path)] = file # Store full path and just filename
164164

165165
for base_path, file_name in all_md_files.items():
@@ -170,8 +170,8 @@ def update_operator_descriptions(docs_path: Path):
170170
upd_file_name = f"{file_name[:-3]}_upd.md"
171171

172172
# Look for the update file in the same folder
173-
upd_path = Path(base_path).parent / upd_file_name
174-
if not upd_path.exists:
173+
upd_path = Path(base_path).parent / Path(upd_file_name)
174+
if not upd_path.exists():
175175
continue
176176

177177
# Load contents
@@ -351,14 +351,14 @@ def generate_operator_doc(
351351
if not include_private and operator_info["exposure"] == "private":
352352
return
353353
template_path = Path(__file__).parent / "operator_doc_template.md"
354-
spec_folder = output_path / "operator-specifications"
354+
spec_folder = output_path / Path("operator-specifications")
355355
category_dir = spec_folder / category
356356
spec_folder.mkdir(parents=True, exist_ok=True)
357357
if category is not None:
358358
category_dir.mkdir(parents=True, exist_ok=True) # Ensure all parent directories are created
359359
file_dir = category_dir
360360
else:
361-
file_dir = output_path / "operator-specifications"
361+
file_dir = spec_folder
362362
with Path.open(template_path, "r") as file:
363363
template = jinja2.Template(file.read())
364364

@@ -377,7 +377,7 @@ def generate_toc_tree(docs_path: Path):
377377
378378
"""
379379
data = []
380-
specs_path = docs_path / "operator-specifications"
380+
specs_path = docs_path / Path("operator-specifications")
381381
for folder in specs_path.iterdir():
382382
if folder.is_dir(): # Ensure 'folder' is a directory
383383
category = folder.name
@@ -394,18 +394,19 @@ def generate_toc_tree(docs_path: Path):
394394

395395
# Render the Jinja2 template
396396
template_path = Path(__file__).parent / "toc_template.j2"
397-
with Path.open(template_path, "r") as template_file:
397+
with template_path.open(mode="r") as template_file:
398398
template = jinja2.Template(template_file.read())
399399
output = template.render(data=data) # Pass 'data' as a named argument
400400

401401
# Write the rendered output to toc.yml at the operators_doc level
402-
with Path.open(docs_path / "toc.yml", "w") as file:
402+
toc_path = docs_path / Path("toc.yml")
403+
with toc_path.open(mode="w") as file:
403404
file.write(output)
404405

405406

406407
def generate_operators_doc(
407-
ansys_path: Path,
408408
output_path: Path,
409+
ansys_path: Path = None,
409410
include_composites: bool = False,
410411
include_sound: bool = False,
411412
include_private: bool = False,
@@ -420,10 +421,10 @@ def generate_operators_doc(
420421
421422
Parameters
422423
----------
423-
ansys_path:
424-
Path to an Ansys/DPF installation.
425424
output_path:
426425
Path to write the output files at.
426+
ansys_path:
427+
Path to an Ansys/DPF installation.
427428
include_composites:
428429
Whether to include operators of the Composites plugin.
429430
include_sound:
@@ -478,8 +479,8 @@ def run_with_args(): # pragma: nocover
478479
args = parser.parse_args()
479480

480481
generate_operators_doc(
481-
ansys_path=args.ansys_path,
482482
output_path=args.output_path,
483+
ansys_path=args.ansys_path,
483484
include_composites=args.include_composites,
484485
include_sound=args.include_sound,
485486
include_private=args.include_private,

0 commit comments

Comments
 (0)