Skip to content

Commit e1b2069

Browse files
fix: use brick ID as folder name for api-docs (#43)
1 parent 163a756 commit e1b2069

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs_generator/runner.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@
88
from docs_generator.markdown_writer import generate_markdown
99
import logging
1010
import ast
11+
import yaml
1112

1213
logger = logging.getLogger(__name__)
1314

1415

16+
def get_brick_id_from_yaml(yaml_path):
17+
try:
18+
with open(yaml_path + "/brick_config.yaml", "r", encoding="utf-8") as f:
19+
config = yaml.safe_load(f)
20+
id = config.get("id", None)
21+
return id.split(":")[1] if id and ":" in id else None
22+
except Exception as e:
23+
logger.warning("unable to get brick id from yaml: %s", e)
24+
return None
25+
26+
1527
def process_app_bricks(src_root: str, output_dir: str):
1628
"""Generate markdown API reference and example documentation for each brick in the app_bricks directory.
1729
@@ -107,6 +119,9 @@ def process_app_bricks(src_root: str, output_dir: str):
107119
else:
108120
all_docstrings = list(docstrings_by_name.values())
109121
# Create output folder for this brick
122+
brick_id = get_brick_id_from_yaml(folder_path)
123+
if brick_id:
124+
folder = brick_id
110125
brick_output_dir = os.path.join(output_dir, "arduino", "app_bricks", folder)
111126
os.makedirs(brick_output_dir, exist_ok=True)
112127
if all_docstrings:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=77,<81", "wheel", "setuptools_scm>=8", "docstring_parser>=0.16", "msgpack>=1.0.0", "watchdog", "requests", "Pillow", "numpy"]
2+
requires = ["setuptools>=77,<81", "wheel", "setuptools_scm>=8", "docstring_parser>=0.16", "msgpack>=1.0.0", "watchdog", "requests", "Pillow", "numpy", "pyyaml"]
33
build-backend = "builder"
44
backend-path = ["src/arduino/app_tools"]
55

0 commit comments

Comments
 (0)