Skip to content

docs(events): document every State setting and make the Events and State pages easier to skim - #855

Merged
JuroOravec merged 1 commit into
mainfrom
docs/state-settings
Nov 24, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
docs/state-settings

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Closes #852

What changed

Event state (docs_site/content/events/state.md)

  • New "State settings" section: a table of all five settings, then one subsection each for _public, _model, _storage, _max_bytes and _max_age. Each one covers what it does, its default, the values it accepts, what happens on an invalid value, a short example, and a link to its API reference row.
  • A short handler example now follows "A handler receives them through its state parameter".
  • "Keep State small" is now its own subsection.
  • The refresh example reads State values into local names first.
  • The input-binding section moved further down as "Bind State to inputs".
  • Renamed headings: "Store values in State", "Access State in handlers", and verb headings for the settings. Every heading is 24 characters or fewer.
  • The State token is defined at its first use.

Server events (docs_site/content/events/index.md): "Set a signing secret" now has three subsections, "Use Django's secret key", "Rotate a secret" and "Rotate during a deploy". The deploy rotation is written as numbered steps.

API reference

  • The Component.State and Component.Events docstrings each get an Attributes: section, one row per setting (type, default, meaning, link to the guide).
  • Events lists _guard, _context, _csrf, _methods, _debounce, _throttle, and _render_inputs (marked experimental).
  • The docs site now gives each Attributes: row its own anchor, such as #citry-component-state-max-age, so the guide can link to it. A row whose name is also a rendered member gets no second anchor, so ids stay unique. Tests for both cases are in docs_site/tests/test_reference.py.

Links

  • versioning.md ("State token lifetime"), security.md, performance/caching.md, performance/cache-backends.md, advanced/subclassing.md, the migration guides and the 1.0.0 upgrade guide link to the new sections instead of repeating them.
  • Links to renamed anchors are updated in docs_site/content. The archived docs_site/versions/* stay as they are. CHANGELOG.md links only to anchors that still exist.

Writing rule: docs/best-practices/writing-docs.md, "Write short headings", now uses "Pass every input" versus "Access State in handlers" as an example.

Where the docs follow the code instead of the issue

The issue says the _max_age clock restarts on every server event. In the code, Citry issues a new token, and so restarts the clock, only when it renders the component or when a call changes State (including browser writes). A call that does neither keeps the old token and its expiry (_resign_state in ext/events/dispatcher.py). The page says this.

Follow-ups

  • The Events settings have API reference rows, but no guide section of their own yet. _guard and _context are taught in Security, _csrf in "Use your own token", and _methods, _debounce and _throttle only through the matching @event(...) options.

Checks

  • python -m docs_site build-check: 0 errors, 0 warnings, 31 info. The info lines are the same heading_length notes as on main; none is on the Events pages.
  • pytest docs_site/tests docs_site/examples: 1278 passed, 10 skipped. That run came before the last round of review edits, which changed only page text and docstrings. After them, docs_site/tests/test_reference.py passed again.
  • ruff check and ruff format --check pass on the changed Python files.
  • Reviewed by a separate docs-cold-reader pass and by an independent technical and prose review. Their findings are folded in.

Versioning and changelog

Docs only, plus docstring edits and docs-site build code (not a published package). Nothing changes behavior covered by the 1.x promise: the PR documents setting names that versioning.md already covers. No changelog entry.

🤖 Generated with Claude Code

…ate pages easier to skim

- Event state page: new "State settings" section with a table and one
  subsection per setting (_public, _model, _storage, _max_bytes,
  _max_age): what it does, default, accepted values, invalid values,
  example. Headings renamed to say what each section helps with; the
  input-binding section moved down; the handler example reads State
  into local names first.
- Server events page: "Set a signing secret" split into Django, rotation
  and deploy subsections, with the deploy rotation as numbered steps.
- API reference: Attributes sections in the Component.State and
  Component.Events docstrings, and the docs site gives each Attributes
  row its own anchor (skipped when a member already has that name).
- Other pages link the new sections instead of repeating them; links to
  renamed anchors are updated.
- writing-docs.md: a heading that gives an instruction must still name
  its subject.

Closes #852

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 0fb31b1 into main Nov 24, 2026
34 checks passed
@JuroOravec
JuroOravec deleted the docs/state-settings branch November 24, 2026 14:03
JuroOravec added a commit that referenced this pull request Nov 24, 2026
…enewal

#855 turned the State guide into a "State settings" section with one
subsection per setting. The renewal text now lives in the `_max_age`
subsection, in that format, and the other pages keep #855's wording
with the renewal facts added.

Conflicts resolved:

- docs_site/content/events/state.md: #855's structure and anchors win.
  The "Set State lifetime" subsection says when a token is renewed, what
  does not renew it, and what a renewal sends; the "Choose where data
  lives" row says a call in the second half of the lifetime gets a new
  token.
- docs_site/content/security.md: points to the `_max_age` subsection
  for the setting and keeps the renewal and replay explanation.
- docs_site/content/about/versioning.md, docs_site/content/performance/
  cache-backends.md: #855's text plus the renewal sentence.
- packages/py/citry/citry/component.py: the State docstring keeps #855's
  per-setting list and its `_max_age` entry gains the renewal sentence.

Wording fix: a token reaches server and proxy logs only for a handler
that opts into GET (`methods=("GET",)` or `_methods`) and declares
`state`; handlers use POST by default. security.md, design section 7.1,
and the State token row in trust_boundaries.md now say so.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

docs(events): document every State setting, and make the Events and State pages easier to skim

1 participant