Add help text for dock property

This commit is contained in:
Darren Burns
2022-04-25 16:53:08 +01:00
parent d9fd240212
commit 79ab5f17f4
3 changed files with 32 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
}
.list-item {
dock: ac2 2;
height: 8;
min-width: 80;
background: dark_blue;

View File

@@ -352,3 +352,32 @@ def docks_property_help_text(
).get_by_context(context)
],
)
def dock_property_help_text(
property_name: str, context: StylingContext | None
) -> HelpText:
property_name = _contextualize_property_name(property_name, context)
return HelpText(
summary=f"Invalid value for [i]{property_name}[/] property",
bullets=[
Bullet("The value must be one of the defined docks"),
*ContextSpecificBullets(
inline=[],
css=[
Bullet(
"Define a dock using the [i]docks[/] property",
examples=[
Example("docks: [u]lhs[/]=left/2;"),
],
),
Bullet(
"Then attach a widget to a defined dock using the [i]dock[/] property",
examples=[
Example("dock: [scope.key][u]lhs[/][/];"),
],
),
],
).get_by_context(context),
],
)

View File

@@ -15,6 +15,7 @@ from ._help_text import (
border_property_help_text,
layout_property_help_text,
docks_property_help_text,
dock_property_help_text,
)
from .constants import (
VALID_ALIGN_HORIZONTAL,
@@ -553,7 +554,7 @@ class StylesBuilder:
self.error(
name,
tokens[1],
f"unexpected tokens in dock declaration",
dock_property_help_text(name, context="css"),
)
self.styles._rules["dock"] = tokens[0].value if tokens else ""