Skip to content

✨ Add a steps component#293

Open
chrisjsewell wants to merge 3 commits into
mainfrom
brief/18-steps
Open

✨ Add a steps component#293
chrisjsewell wants to merge 3 commits into
mainfrom
brief/18-steps

Conversation

@chrisjsewell

@chrisjsewell chrisjsewell commented Jul 16, 2026

Copy link
Copy Markdown
Member

Adds steps/step directives for numbered procedures (install guides, tutorials) — one of the most-copied custom CSS snippets across Sphinx sites, now built in. CSS-only: circular markers and a connecting rail via counter(list-item), no JavaScript, no numbers baked into the doctree.

.. steps::

   .. step:: Install the package

      Content

   .. step:: Configure it

      Content

Design

  • The doctree is a real ordered list (enumerated_list/list_item subclassed as steps_list): assistive tech announces position and count, translations and reordering can never desync the numbering, and LaTeX/text/man degrade to genuine numbered lists honouring :start: (all built and verified; gettext extracts each step title exactly once).
  • :start: maps to native <ol start> — the CSS counter(list-item) follows it by definition; :color: selects from the palette via a generated utility family (data-driven; one rule per design.toml colour, locked by the structural count test).
  • role="list" is emitted on the HTML <ol> (delegating visitor patching the writer's own output, so start/enumtype handling stays version-proof) — WebKit/VoiceOver drop list semantics on list-style: none otherwise.
  • The list-style reset uses a doubled-class selector to out-rank Sphinx basic.css's ol.arabic rule — review caught the double-numbering this caused on every theme, verified fixed by computed-style probes under alabaster and furo.
  • Hyperlink targets between steps are kept (tabs policy) — docutils relocates the id onto the following item and :ref: resolves (review caught the silent drop; now tested).
  • Step titles are optional rubrics; non-step children and orphan steps warn (design.steps, suppressible).
  • RTL-safe via logical properties (marker and rail flip sides, verified computed + screenshot); dark-theme rail tint derives from the palette.

Verification

  • Chromium probes: single marker, role="list", start fidelity, correct marker positioning nested inside cards/grids/dropdowns
  • Five-builder sweep (html/latex/text/man/gettext) with LaTeX compiled to PDF
  • Full test/lint/type matrix green; docs -nW; artifact regenerated through the generator pipeline with the count test extended for the new family

Add a `steps` container and `step` item directive for numbered,
visually-connected procedures (install guides, tutorials), a commonly
hand-rolled CSS snippet.

The doctree is a real ordered list (`enumerated_list` of `list_item`),
so the numbering is semantic: assistive technology announces the step
count/position and non-HTML builders degrade to a plain numbered list.
The visible circular markers and connecting rail are drawn purely with
CSS in `style/steps.css`; the marker number is `counter(list-item)`, the
built-in list counter, so it honours the `<ol start="N">` offset with no
number baked into the doctree — translations and re-ordering can never
desynchronise it. No JavaScript is involved.

`steps` takes `start` (offset), `color` (semantic marker colour) and
`class`; `step` takes an optional title (a `rubric`, as for tab labels)
plus `class`/`class-title`/`class-content`. A `step` outside `steps`, or
a non-`step` child of `steps`, warns (`design.steps`), mirroring tabs.

The `.sd-steps-<colour>` marker variants are generated data-driven from
the palette in `style/design.toml` (new `gen_steps` family, registered
in the `ASSEMBLY` cascade after `steps.css`); the structural count test
is extended accordingly. Markers/rail take their colour from the
semantic palette so themes retint them automatically, and use logical
properties for RTL.
Address review of the `steps` component:

- B1 (double numbering): Sphinx's `basic.css` sets `ol.arabic {list-style:
  decimal}` at specificity (0,1,1), which beat the plain `.sd-steps`
  (0,1,0) rule, so the native "N." marker rendered beside the circular
  one on every theme (basic.css ships with all of them). Raise the reset
  to `.sd-steps.sd-steps {list-style: none}` (0,2,0) so it wins
  independent of stylesheet load order. Regenerated the artifact.
  Verified in Chromium: computed `list-style-type` is `none` under both
  alabaster and furo.
- M2 (dropped targets): keep `nodes.target` children of `steps`, matching
  the tab-set policy — a target renders fine and docutils PropagateTargets
  relocates its id onto the following step, so `:ref:` still resolves.
- m3 (list semantics): removing the native marker makes WebKit/VoiceOver
  drop the list role, so `steps` now emits a `steps_list` node whose HTML
  visitor delegates to the writer's `visit_enumerated_list` and injects
  `role="list"`; non-HTML builders render it as a plain enumerated_list.
  Verified role="list" in HTML and unchanged text/LaTeX numbered output.

Tests added for the target reference, the list role and the non-HTML
degradation; doctree fixtures updated for the new node type.
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.94%. Comparing base (4f66f32) to head (920152c).

Files with missing lines Patch % Lines
sphinx_design/steps.py 98.63% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #293      +/-   ##
==========================================
+ Coverage   92.63%   92.94%   +0.31%     
==========================================
  Files          13       14       +1     
  Lines        1371     1446      +75     
==========================================
+ Hits         1270     1344      +74     
- Misses        101      102       +1     
Flag Coverage Δ
pytests 92.94% <98.66%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant