mirror of
https://github.com/esphome/esphome.git
synced 2025-09-05 21:02:20 +01:00
[core] Move docs url generator to helpers.py (#10056)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -87,7 +87,7 @@ from esphome.core import (
|
||||
TimePeriodNanoseconds,
|
||||
TimePeriodSeconds,
|
||||
)
|
||||
from esphome.helpers import add_class_to_obj, list_starts_with
|
||||
from esphome.helpers import add_class_to_obj, docs_url, list_starts_with
|
||||
from esphome.schema_extractors import (
|
||||
SCHEMA_EXTRACT,
|
||||
schema_extractor,
|
||||
@@ -666,14 +666,6 @@ def only_with_framework(
|
||||
if suggestions is None:
|
||||
suggestions = {}
|
||||
|
||||
version = Version.parse(ESPHOME_VERSION)
|
||||
if version.is_beta:
|
||||
docs_format = "https://beta.esphome.io/components/{path}"
|
||||
elif version.is_dev:
|
||||
docs_format = "https://next.esphome.io/components/{path}"
|
||||
else:
|
||||
docs_format = "https://esphome.io/components/{path}"
|
||||
|
||||
def validator_(obj):
|
||||
if CORE.target_framework not in frameworks:
|
||||
err_str = f"This feature is only available with framework(s) {', '.join([framework.value for framework in frameworks])}"
|
||||
@@ -681,7 +673,7 @@ def only_with_framework(
|
||||
(component, docs_path) = suggestion
|
||||
err_str += f"\nPlease use '{component}'"
|
||||
if docs_path:
|
||||
err_str += f": {docs_format.format(path=docs_path)}"
|
||||
err_str += f": {docs_url(path=f'components/{docs_path}')}"
|
||||
raise Invalid(err_str)
|
||||
return obj
|
||||
|
||||
|
Reference in New Issue
Block a user