From dd0c12d8a40d5efeb02ae65026eea89861323756 Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Tue, 16 Dec 2025 18:41:17 +0100 Subject: [PATCH 1/3] use brick id as folder name for api-docs of bricks --- docs_generator/runner.py | 14 ++++++++++++++ pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs_generator/runner.py b/docs_generator/runner.py index 91ec555e..f76a64a4 100644 --- a/docs_generator/runner.py +++ b/docs_generator/runner.py @@ -8,9 +8,20 @@ from docs_generator.markdown_writer import generate_markdown import logging import ast +import yaml logger = logging.getLogger(__name__) +def get_brick_id_from_yaml(yaml_path): + try: + with open(yaml_path+"/brick_config.yaml", "r", encoding="utf-8") as f: + config = yaml.safe_load(f) + id = config.get("id", None) + return id.split(":")[1] if id and ":" in id else None + except Exception: + logger.warning("unable to get brick id") + return None + def process_app_bricks(src_root: str, output_dir: str): """Generate markdown API reference and example documentation for each brick in the app_bricks directory. @@ -107,6 +118,9 @@ def process_app_bricks(src_root: str, output_dir: str): else: all_docstrings = list(docstrings_by_name.values()) # Create output folder for this brick + brick_id = get_brick_id_from_yaml(folder_path) + if brick_id: + folder = brick_id brick_output_dir = os.path.join(output_dir, "arduino", "app_bricks", folder) os.makedirs(brick_output_dir, exist_ok=True) if all_docstrings: diff --git a/pyproject.toml b/pyproject.toml index 477f8080..b2f6f565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=77,<81", "wheel", "setuptools_scm>=8", "docstring_parser>=0.16", "msgpack>=1.0.0", "watchdog", "requests", "Pillow", "numpy"] +requires = ["setuptools>=77,<81", "wheel", "setuptools_scm>=8", "docstring_parser>=0.16", "msgpack>=1.0.0", "watchdog", "requests", "Pillow", "numpy", "pyyaml"] build-backend = "builder" backend-path = ["src/arduino/app_tools"] From 4f1e98dc2d2b58c1efd813d5da688813a4c38315 Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Tue, 16 Dec 2025 18:45:17 +0100 Subject: [PATCH 2/3] fix log --- docs_generator/runner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs_generator/runner.py b/docs_generator/runner.py index f76a64a4..2997142f 100644 --- a/docs_generator/runner.py +++ b/docs_generator/runner.py @@ -18,8 +18,8 @@ def get_brick_id_from_yaml(yaml_path): config = yaml.safe_load(f) id = config.get("id", None) return id.split(":")[1] if id and ":" in id else None - except Exception: - logger.warning("unable to get brick id") + except Exception as e: + logger.warning("unable to get brick id from yaml: %s", e) return None From b5abef60714a42c1df86dbb007fd70c135a9ba99 Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Tue, 16 Dec 2025 18:47:47 +0100 Subject: [PATCH 3/3] fix fmt --- docs_generator/runner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs_generator/runner.py b/docs_generator/runner.py index 2997142f..32a15191 100644 --- a/docs_generator/runner.py +++ b/docs_generator/runner.py @@ -12,9 +12,10 @@ logger = logging.getLogger(__name__) + def get_brick_id_from_yaml(yaml_path): try: - with open(yaml_path+"/brick_config.yaml", "r", encoding="utf-8") as f: + with open(yaml_path + "/brick_config.yaml", "r", encoding="utf-8") as f: config = yaml.safe_load(f) id = config.get("id", None) return id.split(":")[1] if id and ":" in id else None