-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
schema gen support starlight migration #6119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| JSON_CV_TYPE_SCHEMA = "schema" | ||||||||||||||||||||||||||||||||||||||||||||||
| JSON_ACTION = "action" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| DOCS_ROOT = Path(".") / "src" / "content" / "docs" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| args = None | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -395,20 +397,20 @@ def encode_doxygen(value): | |||||||||||||||||||||||||||||||||||||||||||||
| def get_md_file_ref(md_file, ref): | ||||||||||||||||||||||||||||||||||||||||||||||
| # This should mimic the docref short code, see /themes/esphome-theme/layouts/shortcodes/docref.html | ||||||||||||||||||||||||||||||||||||||||||||||
| if ref.startswith("/"): | ||||||||||||||||||||||||||||||||||||||||||||||
| md_parent = Path(".") / "content" | ||||||||||||||||||||||||||||||||||||||||||||||
| md_parent = DOCS_ROOT | ||||||||||||||||||||||||||||||||||||||||||||||
| ref = ref[1:] | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| md_parent = md_file.parent | ||||||||||||||||||||||||||||||||||||||||||||||
| if ref.endswith("/"): | ||||||||||||||||||||||||||||||||||||||||||||||
| ref = ref[:-1] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_path = md_parent / (ref + ".md") | ||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_path = md_parent / (ref + ".mdx") | ||||||||||||||||||||||||||||||||||||||||||||||
| if ref_md_path.exists(): | ||||||||||||||||||||||||||||||||||||||||||||||
| return ref_md_path | ||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_default = md_parent / ref / "_index.md" | ||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_default = md_parent / ref / "_index.mdx" | ||||||||||||||||||||||||||||||||||||||||||||||
| if ref_md_default.exists(): | ||||||||||||||||||||||||||||||||||||||||||||||
| return ref_md_default | ||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_default = Path(".") / "content" / "components" / (ref + ".md") | ||||||||||||||||||||||||||||||||||||||||||||||
| ref_md_default = DOCS_ROOT / "components" / (ref + ".mdx") | ||||||||||||||||||||||||||||||||||||||||||||||
| if ref_md_default.exists(): | ||||||||||||||||||||||||||||||||||||||||||||||
| return ref_md_default | ||||||||||||||||||||||||||||||||||||||||||||||
| return md_file # go nowhere | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+407
to
416
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check the actual MDX files in the docs structure
find src/content/docs -type f -name "*index.mdx" 2>/dev/null | head -30Repository: esphome/esphome-docs Length of output: 1439 🏁 Script executed: # Check for _index.mdx files specifically
find src/content/docs -type f -name "_index.mdx" 2>/dev/null | head -30Repository: esphome/esphome-docs Length of output: 46 🏁 Script executed: # Get context around lines 407-416, 765, and 787 in script/schema_doc.py
sed -n '400,420p' script/schema_doc.pyRepository: esphome/esphome-docs Length of output: 662 🏁 Script executed: # Check line 765 context
sed -n '760,770p' script/schema_doc.pyRepository: esphome/esphome-docs Length of output: 449 🏁 Script executed: # Check line 787 context
sed -n '780,795p' script/schema_doc.pyRepository: esphome/esphome-docs Length of output: 827 🏁 Script executed: # Search for where file_name is assigned before line 787
sed -n '700,790p' script/schema_doc.py | grep -n "file_name"Repository: esphome/esphome-docs Length of output: 218 🏁 Script executed: # Get broader context around the file processing loop
sed -n '680,810p' script/schema_doc.pyRepository: esphome/esphome-docs Length of output: 4850 Update The codebase uses Update all three locations to use the Proposed fixesLine 410: - ref_md_default = md_parent / ref / "_index.mdx"
+ ref_md_default = md_parent / ref / "index.mdx"Line 787: - if file_name == "_index" and content_folder == "components":
+ if file_name == "index" and content_folder == "components":Line 797: - if file_name == "_index":
+ if file_name == "index":📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -745,22 +747,22 @@ def oddities_titles(folder, file, title): | |||||||||||||||||||||||||||||||||||||||||||||
| core = esphome_json["core"] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| md_files = [] | ||||||||||||||||||||||||||||||||||||||||||||||
| for root, _, files in os.walk(Path(".") / "content" / "components"): | ||||||||||||||||||||||||||||||||||||||||||||||
| for root, _, files in os.walk(DOCS_ROOT / "components"): | ||||||||||||||||||||||||||||||||||||||||||||||
| for file in files: | ||||||||||||||||||||||||||||||||||||||||||||||
| if file.endswith(".md"): | ||||||||||||||||||||||||||||||||||||||||||||||
| if file.endswith(".mdx"): | ||||||||||||||||||||||||||||||||||||||||||||||
| fullpath = Path(root, file) | ||||||||||||||||||||||||||||||||||||||||||||||
| md_files.append(fullpath) | ||||||||||||||||||||||||||||||||||||||||||||||
| md_files.append(Path(".") / "content" / "automations" / "actions.md") | ||||||||||||||||||||||||||||||||||||||||||||||
| md_files.append(DOCS_ROOT / "automations" / "actions.mdx") | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fill_anchors( | ||||||||||||||||||||||||||||||||||||||||||||||
| md_files | ||||||||||||||||||||||||||||||||||||||||||||||
| + [ | ||||||||||||||||||||||||||||||||||||||||||||||
| # config-lambda, config-templatable | ||||||||||||||||||||||||||||||||||||||||||||||
| Path(".") / "content" / "automations" / "templates.md", | ||||||||||||||||||||||||||||||||||||||||||||||
| DOCS_ROOT / "automations" / "templates.mdx", | ||||||||||||||||||||||||||||||||||||||||||||||
| # config-id, config-pin_schema | ||||||||||||||||||||||||||||||||||||||||||||||
| Path(".") / "content" / "guides" / "configuration-types.md", | ||||||||||||||||||||||||||||||||||||||||||||||
| DOCS_ROOT / "guides" / "configuration-types.mdx", | ||||||||||||||||||||||||||||||||||||||||||||||
| # api-rest | ||||||||||||||||||||||||||||||||||||||||||||||
| Path(".") / "content" / "web-api" / "_index.md", | ||||||||||||||||||||||||||||||||||||||||||||||
| DOCS_ROOT / "web-api" / "index.mdx", | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -953,10 +955,14 @@ def oddities_titles(folder, file, title): | |||||||||||||||||||||||||||||||||||||||||||||
| schema = json_config[config_component]["schemas"].get( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"{platform_name.upper()}_SCHEMA" | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| elif platform_name: | ||||||||||||||||||||||||||||||||||||||||||||||
| schema = json_config[f"{config_component}.{platform_name}"][ | ||||||||||||||||||||||||||||||||||||||||||||||
| "schemas" | ||||||||||||||||||||||||||||||||||||||||||||||
| ].get("CONFIG_SCHEMA") | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| print( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"{md_file}:{index} {config_component} unknown component type" | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| schema = None | ||||||||||||||||||||||||||||||||||||||||||||||
| if schema: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL generation in
SeeAlso.md()andconvert_links_and_shortcodesis broken by the new path depth.DOCS_ROOTnow resolves toPosixPath("src/content/docs")(3 parts), so doc files have paths likesrc/content/docs/components/sensor.mdxwith parts('src', 'content', 'docs', 'components', 'sensor.mdx').Both
SeeAlso.md()(line 75) andconvert_links_and_shortcodes(line 452) use the hardcodedparts[1:-1]slice, which was designed for a 1-level prefix (content/):parts[1:-1]content/components/sensor.md('components',)/components/sensor✓src/content/docs/components/sensor.mdx('content', 'docs', 'components')/content/docs/components/sensor✗This will cause all "See also" links and relative
docrefshortcode URLs written into the schema JSON to be incorrect. Fix by making the URL slice relative toDOCS_ROOT:🐛 Proposed fix — derive URL relative to `DOCS_ROOT`
Apply to
SeeAlso.md()(line 75):Apply to
convert_links_and_shortcodes(line 452):🤖 Prompt for AI Agents