Skip to content

Commit f657a5d

Browse files
committed
Initial component docs
1 parent 4f01110 commit f657a5d

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

chartlets.py/chartlets/component.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,30 @@
55

66
@dataclass(frozen=True)
77
class Component(ABC):
8+
"""Base class for components.
9+
Provides the common attributes that apply to all components.
10+
"""
811
# Common HTML properties
912
id: str | None = None
13+
"""HTML `id` property. Required for referring to this component."""
14+
1015
name: str | None = None
16+
"""HTML `name` property. Optional."""
17+
1118
value: bool | int | float | str | None = None
19+
"""HTML `value` property. Required for specific components."""
20+
1221
style: dict[str, Any] | None = None
22+
"""HTML `style` property. Optional."""
23+
1324
# We may add more here later
1425
#
1526
# Special non-HTML properties
1627
label: str | None = None
28+
"""Optional label used by many specific components."""
29+
1730
children: list["Component"] | None = None
31+
"""Optional children used by many specific components."""
1832

1933
@property
2034
def type(self):

chartlets.py/chartlets/components/box.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55

66
@dataclass(frozen=True)
77
class Box(Container):
8-
pass
8+
"""The Box component is a generic container for grouping other components.
9+
It's a fundamental building block. Think of it as an HTML `<div>` element.
10+
11+
Use the `style` attribute how to layout the box and its child components.
12+
"""
13+
14+
component: str | None = None
15+
"""The component to be used, e.g., `div` or `span`."""

chartlets.py/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ dev = [
6060
]
6161
doc = [
6262
"mkdocs",
63-
"mkdocs-material"
63+
"mkdocs-material",
64+
"mkdocstrings",
65+
"mkdocstrings-python"
6466
]
6567
demo = [
6668
"pyaml",

docs/components.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ module, e.g.
77
from chartlets.components import Checkbox
88
```
99

10-
- Box
11-
- Button
12-
- Checkbox
13-
- Dropdown
14-
- Plot
15-
- Typography
10+
::: chartlets.components.Box
11+
12+
::: chartlets.components.Button
13+
14+
::: chartlets.components.Checkbox
15+
16+
::: chartlets.components.Dropdown
17+
18+
::: chartlets.components.Typography
19+
20+
21+
::: chartlets.Component
22+

docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Extension.add_contrib_point("panels", Panel)
3838

3939
### 3. Load the extensions
4040

41-
Load the extensions that augments your application.
41+
Load the extensions that augment your application.
4242

4343
As an example, see [`server.py` of the demo](chartlets.py/chartlets/demo/server.py):
4444

mkdocs.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
site_name: chartlets
22

3+
plugins:
4+
- search
5+
- mkdocstrings:
6+
handlers:
7+
python:
8+
paths: [ "chartlets.py" ]
9+
options:
10+
show_source: false
11+
show_if_no_docstring: false
12+
show_root_heading: true
13+
heading_level: 2
14+
315
nav:
416
- Home: index.md
517
- Demo: demo.md
@@ -44,3 +56,4 @@ validation:
4456
absolute_links: warn
4557
unrecognized_links: warn
4658
anchors: warn
59+

0 commit comments

Comments
 (0)