|
1 | 1 | import argparse |
2 | 2 | from pathlib import Path |
| 3 | +import shutil |
3 | 4 |
|
4 | 5 | from jinja2 import Template |
5 | 6 |
|
@@ -118,18 +119,31 @@ def get_plugin_operators(server, plugin_name): |
118 | 119 |
|
119 | 120 | def generate_operator_doc(server, operator_name, include_private): |
120 | 121 | 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("::", "_") |
121 | 130 | if not include_private and operator_info["exposure"] == "private": |
122 | 131 | return |
123 | 132 | script_path = Path(__file__) |
124 | 133 | root_dir = script_path.parent.parent |
125 | 134 | 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 |
126 | 142 | with Path.open(Path(template_dir) / "operator_doc_template.md", "r") as file: |
127 | 143 | template = Template(file.read()) |
128 | 144 |
|
129 | 145 | 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: |
133 | 147 | file.write(output) |
134 | 148 |
|
135 | 149 |
|
|
0 commit comments