Skip to content

Commit 439fedf

Browse files
committed
Add "output_path" argument
1 parent 463e583 commit 439fedf

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

.ci/generate_operators_doc.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def get_plugin_operators(server, plugin_name):
138138
return plugin_operators
139139

140140

141-
def generate_operator_doc(server, operator_name, include_private):
141+
def generate_operator_doc(server, operator_name, include_private, output_path):
142142
operator_info = fetch_doc_info(server, operator_name)
143143
scripting_name = operator_info["scripting_info"]["scripting_name"]
144144
category = operator_info["scripting_info"]["category"]
@@ -153,12 +153,14 @@ def generate_operator_doc(server, operator_name, include_private):
153153
script_path = Path(__file__)
154154
root_dir = script_path.parent.parent
155155
template_dir = Path(root_dir) / "doc" / "source" / "operators_doc" / "operator-specifications"
156-
category_dir = Path(template_dir) / category
156+
spec_folder = Path(output_path) / "operator-specifications"
157+
category_dir = spec_folder / category
158+
spec_folder.mkdir(parents=True, exist_ok=True)
157159
if category is not None:
158160
category_dir.mkdir(parents=True, exist_ok=True) # Ensure all parent directories are created
159161
file_dir = category_dir
160162
else:
161-
file_dir = template_dir
163+
file_dir = Path(output_path) / "operator-specifications"
162164
with Path.open(Path(template_dir) / "operator_doc_template.md", "r") as file:
163165
template = Template(file.read())
164166

@@ -168,10 +170,9 @@ def generate_operator_doc(server, operator_name, include_private):
168170

169171

170172
def generate_toc_tree(docs_path):
171-
# Target the operator-specifications folder for iteration
172-
# operator_specs_path = docs_path / "operator-specifications"
173173
data = []
174-
for folder in docs_path.iterdir():
174+
specs_path = docs_path / "operator-specifications"
175+
for folder in specs_path.iterdir():
175176
if folder.is_dir(): # Ensure 'folder' is a directory
176177
category = folder.name
177178
operators = [] # Reset operators for each category
@@ -186,7 +187,10 @@ def generate_toc_tree(docs_path):
186187
data.append({"category": category, "operators": operators})
187188

188189
# Render the Jinja2 template
189-
template_path = docs_path / "toc_template.j2"
190+
script_path = Path(__file__)
191+
root_dir = script_path.parent.parent
192+
template_dir = Path(root_dir) / "doc" / "source" / "operators_doc" / "operator-specifications"
193+
template_path = template_dir / "toc_template.j2"
190194
with Path.open(template_path, "r") as template_file:
191195
template = Template(template_file.read())
192196
output = template.render(data=data) # Pass 'data' as a named argument
@@ -203,31 +207,29 @@ def main():
203207
parser.add_argument(
204208
"--ansys_path", default=None, help="Path to Ansys DPF Server installation directory"
205209
)
210+
parser.add_argument("--output_path", default=None, help="Path to output directory")
206211
parser.add_argument("--include_private", action="store_true", help="Include private operators")
207212
parser.add_argument(
208213
"--include_composites", action="store_true", help="Include composites operators"
209214
)
210215
parser.add_argument("--include_sound", action="store_true", help="Include sound operators")
211216
args = parser.parse_args()
212217
desired_plugin = args.plugin
218+
output_path = (
219+
args.output_path
220+
if args.output_path
221+
else (Path(__file__).parent.parent / "doc" / "source" / "operators_doc")
222+
)
213223

214224
server = initialize_server(args.ansys_path, args.include_composites, args.include_sound)
215225
if desired_plugin is None:
216226
operators = available_operator_names(server)
217227
else:
218228
operators = get_plugin_operators(server, desired_plugin)
219229
for operator_name in operators:
220-
generate_operator_doc(server, operator_name, args.include_private)
221-
222-
docs_path = (
223-
Path(__file__).parent.parent
224-
/ "doc"
225-
/ "source"
226-
/ "operators_doc"
227-
/ "operator-specifications"
228-
)
229-
print(docs_path)
230-
generate_toc_tree(docs_path)
230+
generate_operator_doc(server, operator_name, args.include_private, output_path)
231+
print(output_path)
232+
generate_toc_tree(Path(output_path))
231233

232234

233235
if __name__ == "__main__":

0 commit comments

Comments
 (0)