Skip to content

Commit 532cded

Browse files
committed
Refactor chart docs to use macros for class rendering
Replaced repetitive class documentation blocks in chart and type markdown files with Jinja macros for consistency and maintainability. Added docs/extras/macros/__init__.py to define macros for rendering class summaries and members. Updated mkdocs.yml to enable the macros plugin and set edit_uri. Improved theme palette configuration for better color scheme support. Added mkdocs-macros-plugin to documentation dependencies in pyproject.toml.
1 parent 1093cd1 commit 532cded

39 files changed

+134
-412
lines changed

docs/bar_chart.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
::: flet_charts.bar_chart.BarChart
2-
options:
3-
show_root_toc_entry: true
4-
extra:
5-
show_class_docstring: true
1+
---
2+
class_name: flet_charts.bar_chart.BarChart
3+
screenshot: assets/bar-chart-diagram.svg
4+
---
65

7-
![BarChart](assets/bar-chart-diagram.svg)
8-
9-
::: flet_charts.bar_chart.BarChart
10-
options:
11-
show_bases: true
12-
summary:
13-
attributes: true
14-
functions: true
6+
{{ class_summary(class_name, screenshot) }}
157

168
## Examples
179

@@ -35,7 +27,4 @@
3527
--8<-- "examples/charts_example/src/bar_chart/example_2.py"
3628
```
3729

38-
::: flet_charts.bar_chart.BarChart
39-
options:
40-
extra:
41-
show_children: true
30+
{{ class_members(class_name) }}

docs/bar_chart_group.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.bar_chart_group.BarChartGroup
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.bar_chart_group.BarChartGroup") }}

docs/bar_chart_rod.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.bar_chart_rod.BarChartRod
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.bar_chart_rod.BarChartRod") }}

docs/bar_chart_rod_stack_item.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.bar_chart_rod_stack_item.BarChartRodStackItem
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.bar_chart_rod_stack_item.BarChartRodStackItem") }}

docs/chart_axis.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.chart_axis.ChartAxis
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.chart_axis.ChartAxis") }}

docs/chart_axis_label.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.chart_axis.ChartAxisLabel
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.chart_axis.ChartAxisLabel") }}

docs/extras/macros/__init__.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def define_env(env):
2+
@env.macro
3+
def class_all_options(class_name, separate_signature=True):
4+
return f"""
5+
::: {class_name}
6+
options:
7+
show_root_toc_entry: true
8+
show_bases: true
9+
separate_signature: {str(separate_signature).lower()}
10+
extra:
11+
show_class_docstring: true
12+
show_children: true
13+
summary:
14+
attributes: true
15+
functions: true
16+
"""
17+
18+
@env.macro
19+
def class_summary(class_name, screenshot=None):
20+
control_name = class_name.split(".")[-1]
21+
screenshot_md = f"\n\n![{control_name}]({screenshot})\n\n" if screenshot else ""
22+
return f"""
23+
::: {class_name}
24+
options:
25+
show_root_toc_entry: true
26+
extra:
27+
show_class_docstring: true
28+
29+
{screenshot_md}
30+
31+
::: {class_name}
32+
options:
33+
show_bases: true
34+
summary:
35+
attributes: true
36+
functions: true
37+
"""
38+
39+
@env.macro
40+
def class_members(class_name):
41+
return f"""
42+
::: {class_name}
43+
options:
44+
extra:
45+
show_children: true
46+
"""

docs/line_chart.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
::: flet_charts.line_chart.LineChart
2-
options:
3-
show_root_toc_entry: true
4-
extra:
5-
show_class_docstring: true
1+
---
2+
class_name: flet_charts.line_chart.LineChart
3+
screenshot: assets/line-chart-diagram.svg
4+
---
65

7-
![LineChart](assets/line-chart-diagram.svg)
8-
9-
::: flet_charts.line_chart.LineChart
10-
options:
11-
show_bases: true
12-
summary:
13-
attributes: true
14-
functions: true
6+
{{ class_summary(class_name, screenshot) }}
157

168
## Examples
179

@@ -35,7 +27,4 @@
3527
--8<-- "examples/charts_example/src/line_chart/example_2.py"
3628
```
3729

38-
::: flet_charts.line_chart.LineChart
39-
options:
40-
extra:
41-
show_children: true
30+
{{ class_members(class_name) }}

docs/line_chart_data.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.line_chart_data.LineChartData
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.line_chart_data.LineChartData") }}

docs/line_chart_data_point.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
::: flet_charts.line_chart_data_point.LineChartDataPoint
2-
options:
3-
show_root_toc_entry: true
4-
show_bases: true
5-
extra:
6-
show_class_docstring: true
7-
show_children: true
8-
summary:
9-
attributes: true
10-
functions: true
1+
{{ class_all_options("flet_charts.line_chart_data_point.LineChartDataPoint") }}

0 commit comments

Comments
 (0)