Skip to content

Commit c6ac5f0

Browse files
committed
Restructure output
1 parent e84339c commit c6ac5f0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.ci/generate_operators_doc.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
from pathlib import Path
3+
import shutil
34

45
from jinja2 import Template
56

@@ -118,18 +119,31 @@ def get_plugin_operators(server, plugin_name):
118119

119120
def generate_operator_doc(server, operator_name, include_private):
120121
operator_info = fetch_doc_info(server, operator_name)
122+
scripting_name = operator_info["scripting_info"]["scripting_name"]
123+
category = operator_info["scripting_info"]["category"]
124+
if scripting_name:
125+
file_name = scripting_name
126+
else:
127+
file_name = operator_name
128+
if "::" in file_name:
129+
file_name = file_name.replace("::", "_")
121130
if not include_private and operator_info["exposure"] == "private":
122131
return
123132
script_path = Path(__file__)
124133
root_dir = script_path.parent.parent
125134
template_dir = Path(root_dir) / "doc" / "source" / "operators_doc"
135+
category_dir = Path(template_dir) / category
136+
if not category_dir.exists() and category is not None:
137+
category_dir.mkdir()
138+
if category is not None:
139+
file_dir = category_dir
140+
else:
141+
file_dir = template_dir
126142
with Path.open(Path(template_dir) / "operator_doc_template.md", "r") as file:
127143
template = Template(file.read())
128144

129145
output = template.render(operator_info)
130-
if "::" in operator_name:
131-
operator_name = operator_name.replace("::", "_")
132-
with Path.open(Path(template_dir) / f"{operator_name}.md", "w") as file:
146+
with Path.open(Path(file_dir) / f"{file_name}.md", "w") as file:
133147
file.write(output)
134148

135149

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ instance/
7070
doc/_build/
7171

7272
# Operators documentation
73-
doc/source/operators_doc/*.md
73+
doc/source/operators_doc/**/*
7474
!doc/source/operators_doc/operator_doc_template.md
7575

7676
# PyBuilder

0 commit comments

Comments
 (0)