Skip to content

docs: inject example headings dynamically from pyproject.toml metadata#6544

Merged
FeodorFitsner merged 35 commits into
mainfrom
inesa/control-examples-from-folder
Jun 3, 2026
Merged

docs: inject example headings dynamically from pyproject.toml metadata#6544
FeodorFitsner merged 35 commits into
mainfrom
inesa/control-examples-from-folder

Conversation

@InesaFitsner
Copy link
Copy Markdown
Contributor

Description

  • Adds a beforeDefaultRemarkPlugins remark plugin that injects ### headings (and optional descriptions) before each at build time, sourcing content from [tool.flet.metadata] in each example's pyproject.toml

  • Extends crocodocs generator to include title, description, and displayTitle in the examples metadata JSON

  • Removes all static ### headers and inline description paragraphs from doc pages across controls/, types/, services/ — injected dynamically instead

  • TOC entries work correctly (plugin runs in beforeDefaultRemarkPlugins, before Docusaurus's built-in TOC extraction)

  • Supports display_title = false opt-out for examples with hand-written headings

  • Handles [code][api_ref_id] cross-references in descriptions (compatible with remark-api-links)

  • Injects inline examples replacing "see these/this" links in DataCell, DataRow, DataColumn, CupertinoDialogAction, DragTarget, ReorderableListView

Test code

# Minimal test/reproduction code for reviewers, if applicable.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • I have performed a self-review of my own code.
  • My code follows the style guidelines of this project.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • New and existing tests pass locally with my changes.
  • I have made corresponding documentation changes, if applicable.
  • I have added changelog entries for user-facing changes, if applicable.
  • I have updated release guide pages and website/sidebars.yml for breaking changes, removals, and deprecations, if applicable.

Screenshots

Additional details

InesaFitsner and others added 29 commits June 1, 2026 11:37
Replace static ### headers before <CodeExample> blocks with a Docusaurus
remark plugin (remark-inject-example-headings) that reads titles from
examples-metadata.json at build time. The metadata generator (generate.py)
now includes the title from [tool.flet.metadata] in each example's entry.

Running in beforeDefaultRemarkPlugins so injected headings are picked up
by Docusaurus TOC extraction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous pass only covered website/docs/controls/*.md; this extends
it to subdirectories (ads, colorpickers, camera, etc.) by switching to
rglob. Also fixes the script itself to use rglob for future runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends the scan from website/docs/controls/ to all of website/docs/ so
types/, services/, tutorials/, and cookbook/ are covered too.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…chart headings

Add [tool.flet.metadata].description to 6 chart examples (matplotlib bar chart,
toolbar, plotly line/bar/pie/box). The remark plugin now injects a description
paragraph after the heading when the metadata has one. Static ### headers and
description paragraphs removed from matplotlibchart.md, matplotlibchartwithtoolbar.md,
and plotlychart.md so they no longer duplicate the injected content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… headings

Add multi-paragraph descriptions with inline-code links to assist_chips
and filter_chips pyproject.toml files. Remove static ### headers and
description paragraphs from chip.md.

Upgrades the remark plugin's inline parser to handle [`code`](url) links
and multi-paragraph descriptions (blank-line separated). Keeps hasPrecedingH3
as a safety net for any remaining static ### headers in other docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add descriptions for infinite_scrolling and programmatic_scroll examples.
Also correct titles from verbose "Column infinite scrolling" / "Column
programmatic scroll" to the shorter "Infinite scrolling" / "Scrolling
programmatically" used as section headings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Nested themes 1 -> "Inherited and overridden theme"
Nested themes 2 -> "Page, dark and light themes"
Nested themes 3 -> "Theme mode toggle"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mples

Inject the same CodeExample blocks from cupertinoalertdialog.md directly
instead of linking to that page's Examples section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add titles and descriptions for spacing, adaptive_row_heights, and
sortable_and_selectable examples. Title for spacing updated to
"Horizontal margin and column spacing" and sortable_and_selectable to
"Sortable columns and selectable rows" to match the former static headers.
Static ### headers and descriptions removed from datatable/index.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace 'see these' links with inline CodeExample blocks matching
datatable/index.md. The remark plugin will inject headings and
descriptions from pyproject.toml automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ach); update title in pyproject.toml

dismissible.md uses a static ### header with rich description (admonition,
blockquote, bold text) which is complex to express in plain TOML strings.
The pyproject.toml title is still set for gallery use; hasPrecedingH3 in the
remark plugin skips auto-injection for this example.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y_title=false in pyproject.toml

Title injection is now on by default for all examples. Set display_title=false
in [tool.flet.metadata] to suppress injection for a specific example (used by
dismissible/remove_on_dismiss_declarative which has a hand-written heading with
rich description in the doc page).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the inline Examples sections from DataCell, DataColumn, and DataRow docs (deleted multiple CodeExample/Image blocks), leaving only the ClassAll component. Also remove a redundant "### CodeEditor" heading from the CodeEditor page. This cleans up duplicated example content and relies on centralized/example assets elsewhere.
- draggable.md: uncomment CodeExample blocks, remove static ### header
- dragtarget.md: replace 'see these' link with inline CodeExample blocks,
  add examples/example_images frontmatter, switch ClassAll to
  ClassSummary+ClassMembers so description appears above examples

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ct.toml, inject from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… pyproject.toml, inject from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l, inject from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…m metadata

- Extend remark plugin to handle hardcoded CodeExample paths (not just
  frontMatter.examples + '/subfolder/') via HARDCODED_PATH_RE
- Move title+description to adaptive_navigation/pyproject.toml
- Remove static ### header and description from navigationbar/index.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ect from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…etadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…data

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace inline backtick reference with a Sphinx cross-reference (:class:`~flet.Radio`) in RadioGroup docstring to improve documentation linking. Remove the redundant "Examples" section from the radiogroup docs page to clean up generated docs; no behavioral changes.
…, inject title from metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gin for [`code`][ref_id] links

- Remove all static ### headers and descriptions from video/index.md
- Add descriptions (with API cross-references) to all 8 video example pyproject.toml files
- Extend remark plugin parseInline to handle [`code`][ref_id] pattern by emitting
  the text+inlineCode+text triplet that remark-api-links expects for link resolution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nject from metadata

Convert hardcoded path="..." to path={'...'} so HARDCODED_PATH_RE in the
remark plugin can resolve the metadata key and inject the title.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @InesaFitsner, your pull request is larger than the review limit of 150000 diff characters

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 2, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: d0f3a89
Status:🚫  Build failed.

View logs

Static headers have been cleaned up; remark plugin handles injection going forward.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread sdk/python/examples/controls/core/column/programmatic_scroll/pyproject.toml Outdated
Comment thread sdk/python/examples/extensions/video/button_bars/pyproject.toml Outdated
@InesaFitsner InesaFitsner changed the title docs: inject example headings dynamically from pyproject.toml metadataInesa/control examples from folder docs: inject example headings dynamically from pyproject.toml metadata Jun 2, 2026
InesaFitsner and others added 3 commits June 2, 2026 16:12
Renames the [tool.flet.metadata] field from `description` to `docs_intro`
across all 32 pyproject.toml files, updates the generate.py reader and
remark-inject-example-headings plugin accordingly, and regenerates the
examples-metadata.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le> tag

Instead of reading display_title from [tool.flet.metadata] and storing
displayTitle in examples-metadata.json, the remark plugin now reads a
displayTitle={false} JSX attribute directly from the <CodeExample> element.
Applied to the dismissible remove_on_dismiss_declarative example.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
[tool.flet.metadata]
title = "Featured views"
title = "Managed views — full app with NavigationRail"
docs_intro = "Complete app with [NavigationRail](../controls/navigationrail), stacked project views, and tabbed settings — all using `manage_views=True`."
Copy link
Copy Markdown
Contributor

@FeodorFitsner FeodorFitsner Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using [flet.NavigationRail] or (../controls/navigationrail.md).

InesaFitsner and others added 2 commits June 3, 2026 10:05
…intro

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, not flat file)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@FeodorFitsner FeodorFitsner merged commit a4c0481 into main Jun 3, 2026
38 checks passed
@FeodorFitsner FeodorFitsner deleted the inesa/control-examples-from-folder branch June 3, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants