Docs conventions

From flet-dev/flet · View interactive version

Docs conventions is an AI agent skill from the GitHub repository flet-dev/flet. Use when writing or reviewing Flet documentation, including Python docstrings (Google style, reST roles, admonitions), Markdown docs (cross-references, images, code examples), and sidebar navigation.

How to use this skill

Skill file

Documentation Conventions

Docs live in website/docs/. Docusaurus renders them as the website.

Python Docstrings

Use Google style docstrings with sections: Args:, Returns:, Raises:, Note:, Example:, Warning:.

Cross-references

reST roles

Prefer these in Python docstrings. CrocoDocs renders them as links in

the API docs and they keep authoring terse when the auto-derived label is acceptable.

Supported roles: :class:, :attr:, :meth:, :func:, :data:, :mod:

"""
If a parent is a :class:`~flet.ResponsiveRow`, this property determines
how many virtual columns the control spans.

See :attr:`value` or :attr:`flet.Text.size` for the current selection.

Calls :meth:`flet.Page.update` after modifying controls.
"""

Rules:

For plain class references like :class:flet.Page`` and extension references like

:class:flet_map.Map``, the website strips leading public package aliases automatically,

so they display as inline code Page and Map.

Not supported:

Xrefs

Reference-style Markdown links of the form [label][key], where key is the

fully-qualified dotted symbol path (same form as reST role targets).

Use as the default form for linking to API symbols from Markdown docs

(.md / .mdx).

Examples:

Class: [`Page`][flet.Page]
Attribute: [`route`][flet.Page.route]
Method: [`Page.update()`][flet.Page.update]
Extension: [`Video.controls`][flet_video.Video.controls]
Plain text: [the route attribute][flet.Page.route]

When to prefer over the other forms:

Rules:

Markdown links

Fallback for cases xrefs cannot cover:

Use relative .md paths with dot-format anchors.

Examples:

Control: [`Page`](../controls/page.md)
Type: [`DragTargetEvent.global_position`](../types/dragtargetevent.md#flet.DragTargetEvent.global_position)
Plain text: [route](../controls/page.md#flet.Page.route)
Method: [`Page.update()`](../controls/page.md#flet.Page.update)

Admonitions in docstrings

Google-style section headers render as Docusaurus admonitions:

"""
Note:
    Has effect only if the direct parent is a :class:`~flet.Column`.

Warning:
    This property is deprecated. Use :attr:`new_prop` instead.

Example:
    Setting up a basic layout:
    ``ft.Column(controls=[ft.Text("Hello")])``
"""

Supported kinds: Note, Warning, Danger, Tip, Info.

Unsupported kinds (e.g. Limitation, Example) are normalized to note.

Empty admonitions are skipped.

Admonitions

:::note
Basic note without title.
:::

:::warning[Important]
Warning with a custom title.
:::

Supported types: note, info, tip, warning, danger.

Front matter

---
class_name: "flet.Container"
examples: "controls/container"
example_images: "test-images/examples/material/golden/macos/container"
example_media: "examples/controls/container/media"
title: "Container"
---

Images

Use the CrocoDocs Image component. Paths without ../ are resolved against /docs/:

import {Image} from '@site/src/components/crocodocs';

<Image src={frontMatter.example_images + '/image_for_docs.png'} width="55%" />

For absolute paths (one-off assets in static/):

<Image src="/docs/assets/controls/charts/bar-chart-diagram.svg" width="65%" />

Code examples

import {CodeExample} from '@site/src/components/crocodocs';

<CodeExample path={frontMatter.examples + '/example_1.py'} />

Paths are relative to the configured examples_root (sdk/python/examples/).

Inline HTML

Use <kbd>...</kbd> in Python docstrings for keyboard keys, for example

<kbd>Enter</kbd> or <kbd>Shift</kbd>. CrocoDocs preserves this tag in API

docs.

Sidebar Navigation

Edit website/sidebars.yml to change navigation structure:

docs:
  Reference:
    Controls:
      _generated_index:
        title: Controls
        slug: /controls
        description: Browse the complete catalog of controls available in Flet.
      Core:
        _generated_index:
          title: Core controls
          slug: /controls/core
          description: ...
        Column: controls/column.md
      Material:
        _generated_index: ...
        AlertDialog: controls/alertdialog.md
      Cupertino:
        _generated_index: ...
        CupertinoButton: controls/cupertinobutton.md
      Shadcn:
        _index: controls/shadcnui/index.md
        Button: controls/shadcnui/button.md
      Extensions:
        _generated_index: ...
        Charts: ...

Reference → Controls has five folders, in this order: Core, Material, Cupertino, Shadcn and Extensions (Extensions always last). Core, Material, Cupertino and Extensions use _generated_index (a card grid); Shadcn has its own overview page via _index. When adding a control, keep entries alphabetical inside the folder and pick the folder from where the control's Python class lives:

Sub-controls (controls that can only be used inside a specific parent control, e.g. DataCell, TableColumn, MenuItem) get their own page, nested under the parent's entry with _index pointing at the parent page. One page documents exactly one class; never add a second class's ClassSummary/ClassMembers to a page.

Sidebar folders only affect navigation: doc URLs come from file paths, so a page stays at /docs/controls/<name> whichever folder lists it. Do not move doc files into core/, material/ or cupertino/ subdirectories.

After editing, regenerate sidebars.js:

cd website && yarn crocodocs:generate
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.