sync: repair debug platform descriptions showing config-variable bullet#916
sync: repair debug platform descriptions showing config-variable bullet#916marcelveldt wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #916 +/- ##
=======================================
Coverage 99.24% 99.24%
=======================================
Files 191 191
Lines 14200 14200
=======================================
Hits 14093 14093
Misses 107 107
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a defensive repair in the component-catalog sync pipeline to prevent platform components (notably sensor.debug / text_sensor.debug) from shipping a raw “configuration variables” bullet as their description, and adds a regression guard + unit tests to keep the catalog clean until the upstream docs generator is fixed.
Changes:
- Add
_repair_field_bullet_descriptions()to detect “field-bullet-shaped” descriptions and replace/clear them duringbuild_catalog(). - Add a catalog regression check (
_check_no_field_bullet_descriptions) to fail CI if any component descriptions still match the bullet pattern. - Add a focused unit test module to pin the repair pass’s contract.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
script/sync_components.py |
Runs a new post-process pass that repairs bullet-shaped descriptions before MDX backfill. |
script/check_catalog.py |
Adds a new regression check to detect any remaining bullet-shaped component descriptions. |
tests/test_sync_components_field_bullet_repair.py |
Adds unit tests covering replacement/clearing behavior and non-matches. |
PR Review — sync: repair debug platform descriptions showing config-variable bulletTargeted, well-scoped workaround for a real upstream defect, with a regression guard and focused unit tests — exactly the right shape for a temporary patch. The main concern is the umbrella-resolution heuristic ( 🟡 Important1. Umbrella-by-stem heuristic is wrong for `.` ids (`script/sync_components.py`, L1057-1062)
Current diff only changes 2 entries (
Option 1 is the smallest change and matches the existing 🟢 Suggestions1. Regex duplicated between check_catalog and sync_components (`script/check_catalog.py`, L273-278)
Either import the sync-side pattern ( 2. Reaches into `catalog._components` private attribute (`script/check_catalog.py`, L286-288)
3. `esphome-docs#TBD` placeholder (`script/sync_components.py`, L1040-1042)The docstring says 4. Missing test for the `.` collision caseWhichever way the umbrella-by-stem behaviour lands (current heuristic, or a domain-restricted one per the warning above), add a test pinning what happens for Example shape: def test_does_not_pull_unrelated_bare_component_as_umbrella() -> None:
entries = [
{"id": "esphome", "description": "ESPHome core config block."},
{"id": "ota.esphome", "description": "- **port** (*Optional*): ..."},
]
_repair_field_bullet_descriptions(entries)
# ota.esphome must NOT inherit the bare `esphome` core description
assert entries[1]["description"] != "ESPHome core config block."Checklist
SummaryTargeted, well-scoped workaround for a real upstream defect, with a regression guard and focused unit tests — exactly the right shape for a temporary patch. The main concern is the umbrella-resolution heuristic ( To rebase specific severity levels, mention me: Automated review by Kōan4599a34 |
|
addressed the review feedback in 5da7466 + 7c173ff:
|
|
related unfinished pr esphome/esphome-docs#6618 |
The upstream esphome-docs schema scraper bakes the first `### Configuration variables` bullet into the `docs` field of platform components whose MDX section lacks a prose intro (`sensor.debug`, `text_sensor.debug`). That bullet then renders as the card / form description in the "Add Component" wizard. Detect the `- **<key>** (*Optional|Required*):` shape in the sync pipeline and substitute the bare-stem umbrella entry's description. Removable once esphome/esphome-docs `md_get_paragraph` is fixed.
- skip stem-based umbrella lookup for synthetic-umbrella domains (`ota`, `time`) — `ota.esphome`'s stem `esphome` would otherwise resolve to the unrelated core `esphome` component - drop the `#TBD` placeholder from the docstring - trim the test module docstring to a one-liner - add regression test pinning the umbrella-domain skip
Removes the duplicate regex declaration that could drift out of sync with the source-of-truth in `_repair_field_bullet_descriptions`. Switches the iteration to `catalog._by_id.values()` to match the private-access pattern used by neighbouring check functions.
7c173ff to
0b4d69b
Compare
|
@bdraco OK to merge ? The final fix will land when the schema is fixed upstream but this at least fixes the weirdness in the UI |
What does this implement/fix?
The
sensor.debugandtext_sensor.debugcards in the "Add Component" wizard render a raw config-variables bullet (- **free** (*Optional*): Reports the free heap size...) as their description instead of a real component description. Root cause is upstream inesphome/esphome-docsscript/schema_doc.py—md_get_paragraphskips titles but accepts the first### Configuration variablesbullet as the section paragraph when there's no prose between## <Platform>and the configuration-variables heading. That bullet ends up baked into the schema bundle as the platform component'sdocsfield.Add a small repair pass in the sync pipeline that detects the
- **<key>** (*Optional|Required*):shape and substitutes the bare-stem umbrella entry's description — so both cards now show the proper "Thedebugcomponent can be used to debug problems with ESPHome..." prose. Easy to rip out once the upstreammd_get_paragraphfix lands._repair_field_bullet_descriptionsinscript/sync_components.py, wired intobuild_catalogbefore the MDX backfillscript/check_catalog.py(_check_no_field_bullet_descriptions) so this can't silently come backtests/test_sync_components_field_bullet_repair.pypinning the contractcomponents.json— exactly 2 entries change:sensor.debugandtext_sensor.debugRelated issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.jsonhas not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.