diff --git a/custom_components/adaptive_lighting/docs_gen.py b/custom_components/adaptive_lighting/docs_gen.py index 8681da4b..9a10a68b 100644 --- a/custom_components/adaptive_lighting/docs_gen.py +++ b/custom_components/adaptive_lighting/docs_gen.py @@ -1,61 +1,12 @@ """Documentation generation utilities for Adaptive Lighting. -Provides functions to extract sections from README.md and transform -content for the documentation site. Used by markdown-code-runner -to generate documentation pages from README content. +Provides functions to transform content for the documentation site. +Used by markdown-code-runner to generate documentation pages from README content. """ from __future__ import annotations import re -from pathlib import Path - -# Path to README relative to this module -_MODULE_DIR = Path(__file__).parent -README_PATH = _MODULE_DIR.parent.parent / "README.md" - - -def readme_section(section_name: str, *, strip_heading: bool = True) -> str: - """Extract a marked section from README.md. - - Sections are marked with HTML comments: - - content - - - Args: - section_name: The name of the section to extract - strip_heading: If True, remove the first heading from the section - - Returns: - The content between the section markers - - Raises: - ValueError: If the section is not found in README.md - - """ - content = README_PATH.read_text() - - start_marker = f"" - end_marker = f"" - - start_idx = content.find(start_marker) - if start_idx == -1: - msg = f"Section '{section_name}' not found in README.md" - raise ValueError(msg) - - end_idx = content.find(end_marker, start_idx) - if end_idx == -1: - msg = f"End marker for section '{section_name}' not found" - raise ValueError(msg) - - section = content[start_idx + len(start_marker) : end_idx].strip() - - if strip_heading: - # Remove first heading (# or ## or ###) - section = re.sub(r"^#{1,3}\s+[^\n]+\n+", "", section, count=1) - - return _transform_readme_links(section) def _transform_readme_links(content: str) -> str: diff --git a/docs/advanced/brightness-modes.md b/docs/advanced/brightness-modes.md index b735a583..10408fb2 100644 --- a/docs/advanced/brightness-modes.md +++ b/docs/advanced/brightness-modes.md @@ -19,8 +19,7 @@ Adaptive Lighting supports three brightness modes: ## Detailed Explanation - - + @@ -90,8 +89,7 @@ adaptive_lighting: These graphs show how brightness changes throughout the day based on calculated values: - - + diff --git a/docs/advanced/manual-control.md b/docs/advanced/manual-control.md index 157e081e..36720f3c 100644 --- a/docs/advanced/manual-control.md +++ b/docs/advanced/manual-control.md @@ -9,8 +9,7 @@ Adaptive Lighting is designed to work seamlessly with manual adjustments, detect ## How It Works - - + diff --git a/docs/automation-examples.md b/docs/automation-examples.md index e8ed0e7d..e2d136f6 100644 --- a/docs/automation-examples.md +++ b/docs/automation-examples.md @@ -7,8 +7,8 @@ icon: lucide/bot Real-world automation examples showing how to integrate Adaptive Lighting with your Home Assistant setup. - - + + diff --git a/docs/configuration.md b/docs/configuration.md index 622c1416..21c7028e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -85,8 +85,8 @@ All configuration options are listed below with their default values. These opti ## Full Configuration Example - - + + diff --git a/docs/index.md b/docs/index.md index 28820274..bc3acebe 100644 --- a/docs/index.md +++ b/docs/index.md @@ -26,8 +26,8 @@ By automatically adapting the settings of your lights throughout the day, Adapti ## Features - - + + diff --git a/docs/see-also.md b/docs/see-also.md index 8c1a2613..5b06fcae 100644 --- a/docs/see-also.md +++ b/docs/see-also.md @@ -9,8 +9,8 @@ Resources, tutorials, and related projects for Adaptive Lighting. ## Tutorials & Articles - - + + diff --git a/docs/services.md b/docs/services.md index 5b0ccf58..306aa7c3 100644 --- a/docs/services.md +++ b/docs/services.md @@ -112,13 +112,11 @@ data: ## adaptive_lighting.change_switch_settings - - + + -#### `adaptive_lighting.change_switch_settings` - `adaptive_lighting.change_switch_settings` (new in 1.7.0) Change any of the above configuration options of Adaptive Lighting (such as `sunrise_time` or `prefer_rgb_color`) with a service call directly from your script/automation. > [!WARNING] diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 4e33e24c..22374949 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -9,8 +9,8 @@ This guide covers common issues and their solutions when using Adaptive Lighting ## Enable Debug Logging - - + + @@ -30,8 +30,8 @@ After the issue occurs, create a new issue report with the log (`/config/home-as ## Common Problems & Solutions - - + + diff --git a/pyproject.toml b/pyproject.toml index 7021ac48..bdaf9acf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ requires-python = ">=3.12" docs = [ "astral", "homeassistant", - "markdown-code-runner", + "markdown-code-runner>=2.7.0", "markdown-gfm-admonition", "pandas", "shinylive", diff --git a/uv.lock b/uv.lock index 5dd33777..57564ac4 100644 --- a/uv.lock +++ b/uv.lock @@ -109,7 +109,7 @@ dev = [ docs = [ { name = "astral" }, { name = "homeassistant" }, - { name = "markdown-code-runner" }, + { name = "markdown-code-runner", specifier = ">=2.7.0" }, { name = "markdown-gfm-admonition" }, { name = "pandas" }, { name = "shinylive" }, @@ -2790,11 +2790,11 @@ wheels = [ [[package]] name = "markdown-code-runner" -version = "2.4.0" +version = "2.7.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/34/91/6b7030f873b0c49f38131c7a5ac9432238cf1e1cd47104c05b07cf5c32ed/markdown_code_runner-2.4.0.tar.gz", hash = "sha256:7d6229c437f0c71e5c0442585663af4bfe4beacddf884a64ea8c09fd5dbc31dd", size = 19072, upload-time = "2025-08-23T19:07:41.78Z" } +sdist = { url = "https://files.pythonhosted.org/packages/28/d1/2a7753e05dcc711552721048a34341b63a6a2b09e70ac738c7a4c81ca414/markdown_code_runner-2.7.0.tar.gz", hash = "sha256:b36f9314839c0db3ee5e5d644e1b4471454af8f624eb15bd5a5d68dbc6430afe", size = 99832, upload-time = "2026-01-24T21:20:04.772Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/98/3c/8857763070aa0f39591b012f92ab40bd5fe906914085e925eb117e28f306/markdown_code_runner-2.4.0-py3-none-any.whl", hash = "sha256:5be62e75ab35188b37f2d440c19b6683df68615ea24bed4955d95a745e56b483", size = 12292, upload-time = "2025-08-23T19:07:40.972Z" }, + { url = "https://files.pythonhosted.org/packages/cf/92/9d7fa0567cf3d38b551bb1a30c177285e0e42ae2b10c16946af7e8a38e73/markdown_code_runner-2.7.0-py3-none-any.whl", hash = "sha256:fad5d5fbad9c49687141ab9c39ed7e054f857b97aa79d11f031de157afd21c20", size = 14692, upload-time = "2026-01-24T21:20:03.382Z" }, ] [[package]]