Skip to content

feat(docs): widget catalogue site via xtask + astro/starlight (#52) - #54

Merged
unhappychoice merged 2 commits into
mainfrom
feat/docs-site-52
Apr 22, 2026
Merged

unhappychoice merged 2 commits into
mainfrom
feat/docs-site-52

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

Closes #52.

Summary

  • Declare option schemas and sample output directly on Fetcher / RealtimeFetcher / Renderer traits so widget metadata lives next to the implementing code (no docs drift). Populated for every built-in fetcher; renderer option schemas cover ascii_art + simple.
  • New xtask workspace crate (cargo xtask) reads the built-in registries and writes per-widget Markdown pages — overview, one page per fetcher, one per renderer — with inline previews rendered via ratatui TestBackend and converted to cell-wrapped HTML spans so block glyphs don't drift columns in the browser.
  • docs-site/ — Astro 5 + Starlight 0.37 under /splashboard/. Generated reference pages are gitignored; only handwritten content (landing, 404, .splash-snapshot CSS) is checked in.
  • .github/workflows/docs.yml builds via xtask → npm → astro on every push to main and deploys via actions/deploy-pages.

Test plan

  • cargo test --workspace — 287 + 12 + 2 passing
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo fmt --all --check clean
  • cargo xtask regenerates 48 reference MDs from the live registries
  • cd docs-site && npm ci && npm run build → 50 pages (index + 404 + 1 matrix + 30 fetchers + 17 renderers), pagefind + sitemap wired up
  • One-time GitHub setting: Settings → Pages → Source: GitHub Actions (required before the workflow can deploy)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added comprehensive documentation site with automatic GitHub Pages deployment
    • Fetchers and renderers now expose configurable options with descriptions and defaults
    • All fetchers and renderers provide sample outputs for preview/documentation purposes
  • Chores

    • Converted project to Cargo workspace structure
    • Added documentation generation tooling (xtask) to maintain reference docs in sync with code

unhappychoice and others added 2 commits April 22, 2026 11:52
…enderer

Adds two trait methods, each with sensible defaults, so widget metadata lives
next to the code that implements it instead of drifting in prose:

- `option_schemas()` on `Fetcher` / `RealtimeFetcher` / `Renderer` returns a
  `&[OptionSchema]` describing what the widget accepts from `[widget.options]`
  (name, type hint, required, default, description). Populated for the clock
  family and ascii_art / simple renderers.
- `sample_body(shape)` on both fetcher traits returns a representative
  `Body` for previewing the widget without executing it. Populated for every
  built-in fetcher; `read_store` falls through to a shape-level canonical
  fallback in `samples::canonical_sample`.

Library exposure comes along with this: `src/lib.rs` now re-exports every
module so downstream tooling (xtask, future CLI preview subcommand) can reach
registries and samples via `splashboard::…`. `main.rs` becomes a thin binary
that imports from the library.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Introduces the docs surface for issue #52:

- `xtask` workspace crate with `cargo xtask` alias (.cargo/config.toml).
  Reads the built-in fetcher / renderer registries and writes one Markdown
  page per widget under `docs-site/src/content/docs/reference/` — overview,
  per-fetcher, per-renderer — plus inline HTML previews. Previews render
  each `(fetcher, shape, renderer)` triple through a ratatui `TestBackend`,
  converting the resulting `Buffer` to cell-wrapped spans so column
  alignment survives the browser's rendering of block glyphs. Sample
  payloads come from each fetcher's own `sample_body(shape)` override; this
  crate only handles layout and HTML conversion.

- `docs-site/` — Astro 5 + Starlight 0.37, scaffolded for GitHub Pages
  under `/splashboard/`. Generated reference pages are gitignored so the
  repo only carries handwritten content (landing + 404 + custom CSS);
  `cargo xtask` regenerates them on demand. `@astrojs/sitemap` pinned to
  3.7.0 via overrides because 3.7.1 pulls zod v4 which collides with the
  rest of the stack.

- `.github/workflows/docs.yml` — builds the site on every push to `main`
  (and on manual dispatch), then publishes via the official
  `actions/deploy-pages` flow. Requires Settings → Pages → Source to be
  set to "GitHub Actions" one time.

Closes #52.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request establishes a comprehensive documentation site infrastructure for splashboard. It converts the repository to a Cargo workspace, adds an xtask utility crate that generates reference documentation from live registries, introduces trait methods for declaring widget options and providing sample previews, and sets up an Astro + Starlight site deployed to GitHub Pages via CI/CD.

Changes

Cohort / File(s) Summary
Workspace & Configuration
.cargo/config.toml, Cargo.toml
Added Cargo workspace structure with root and xtask crate; added xtask CLI alias for convenience.
Library Entrypoint & Module Visibility
src/lib.rs, src/main.rs
Created new src/lib.rs exporting all public modules; updated src/main.rs to use splashboard:: module paths for workspace integration.
Core Infrastructure
src/options.rs, src/samples.rs
Added OptionSchema struct for declarative widget option metadata; introduced samples.rs module with helper functions to construct sample payloads for all shape types and a canonical fallback function.
Trait & Registry Extensions
src/fetcher/mod.rs, src/render/mod.rs
Extended Fetcher, RealtimeFetcher, and Renderer traits with option_schemas() and sample_body() methods (both with defaults); added Registry::sorted() to both fetcher and renderer registries for deterministic enumeration.
Fetcher Sample & Option Implementations
src/fetcher/clock/*, src/fetcher/git/*, src/fetcher/system.rs, src/fetcher/static_text.rs, src/fetcher/stub.rs
Implemented sample_body() across all fetchers (clock: countdown/derived/mod/ratio/state/sunrise/timezones; git: blame_heatmap/commits_activity/contributors/latest_tag/recent_commits/stash_count/status/worktrees; system fetchers; static text; stubs); added option_schemas() declarations to clock variants and system fetchers.
Renderer Option Implementations
src/render/ascii_art.rs, src/render/text.rs
Implemented option_schemas() for ASCII art and text renderers with their supported styling/alignment options.
Documentation Site Setup
docs-site/package.json, docs-site/astro.config.mjs, docs-site/tsconfig.json, docs-site/.gitignore
Added Node.js project configuration for Astro + Starlight site with GitHub Pages base path; configured TypeScript and ignored build artifacts and generated reference content.
Documentation Content
docs-site/src/content.config.ts, docs-site/src/content/docs/*, docs-site/src/styles/snapshot.css
Defined Astro content collections; added 404 and index documentation pages with navigation; created CSS styling for terminal snapshot rendering in documentation.
Documentation Workflow
.github/workflows/docs.yml
Added GitHub Actions workflow to build Astro site and deploy to GitHub Pages on pushes to main, with built-in concurrency control.
xtask Tooling Crate
xtask/Cargo.toml, xtask/src/main.rs
Created workspace-scoped utility crate with CLI interface accepting --out directory argument (defaults to docs-site reference path).
Matrix & Reference Generator
xtask/src/gen_matrix.rs
Implemented primary documentation generator that reads built-in fetcher/renderer registries and writes matrix.md (overview), per-fetcher reference pages, and per-renderer reference pages with option tables, compatibility matrices, and preview snippets.
HTML Snapshot Converter
xtask/src/html_snapshot.rs
Added buffer-to-HTML converter that transforms ratatui terminal buffers into inline <pre class="splash-snapshot"> fragments with per-cell <span> styling for color-preserving snapshot rendering.
Preview Generator
xtask/src/snapshots.rs
Implemented preview generator that samples each fetcher across compatible renderers, renders payloads via ratatui test backend, converts output to HTML, and collects config snippets for documentation embedding.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as cargo xtask
    participant Matrix as gen_matrix
    participant Fetchers as Fetcher Registry
    participant Renderers as Renderer Registry
    participant Snapshots as snapshots
    participant RTerm as ratatui Terminal
    participant HTML as html_snapshot
    participant Docs as docs-site/reference

    CLI->>Matrix: run(out_path)
    Matrix->>Fetchers: get all registered fetchers
    Matrix->>Renderers: get all registered renderers
    Matrix->>Docs: write matrix.md overview
    
    loop For each fetcher
        Matrix->>Fetchers: get option_schemas & shapes
        Matrix->>Docs: write fetcher/<name>.md (schema table)
        Matrix->>Snapshots: previews_for(fetcher, renderers)
        
        loop For each supported shape
            Snapshots->>Fetchers: sample_body(shape)
            Snapshots->>Renderers: find compatible renderers
            
            loop For each compatible renderer
                Snapshots->>RTerm: render sample via TestBackend
                RTerm->>HTML: convert Buffer to HTML
                HTML->>Snapshots: <pre class="splash-snapshot">
                Snapshots->>Docs: embed preview + config in reference page
            end
        end
    end
    
    loop For each renderer
        Matrix->>Renderers: get option_schemas
        Matrix->>Docs: write renderer/<name>.md (schema table)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Thumping through the code with glee,
A docs site blooms for all to see!
From snapshot-HTML to matrices true,
The xtask rabbit renders the view!
cargo xtask hops, the reference pages sing,
And every fetcher finds its widget-showcase thing! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.95% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a widget catalogue documentation site using xtask, Astro, and Starlight.
Linked Issues check ✅ Passed The pull request fully implements the objectives from #52: trait methods for option schemas and samples, xtask crate for matrix/snapshot generation, Astro+Starlight docs site, GitHub Actions workflow, and HTML snapshot previews with color preservation.
Out of Scope Changes check ✅ Passed All changes are directly aligned with PR objectives. The workspace restructuring (lib.rs, main.rs refactor) and trait additions on Fetcher/Renderer enable the documentation generation pipeline and are necessary for the xtask implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/docs-site-52

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (6)
docs-site/src/styles/snapshot.css (1)

5-5: Remote Google Fonts import adds a third-party runtime dependency.

Importing from fonts.googleapis.com at runtime means every docs visitor hits Google, which can be a privacy/GDPR concern for a GitHub Pages site and also breaks offline/air-gapped viewing. Consider self-hosting JetBrains Mono (e.g., via @fontsource/jetbrains-mono) so the font ships with the built site and no third-party request is made.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-site/src/styles/snapshot.css` at line 5, The CSS currently pulls
JetBrains Mono from Google via the `@import` URL in snapshot.css, creating a
third-party runtime dependency; remove that remote `@import` and instead self-host
the font (for example install `@fontsource/jetbrains-mono` and import it from the
package in your build entry or main stylesheet), then update snapshot.css to
reference "JetBrains Mono" in font-family without the external URL; locate the
`@import` line in snapshot.css and replace the external import with the local
package import and ensure any build/asset pipeline copies the font into the site
bundle so no fonts.googleapis.com requests occur.
src/fetcher/clock/derived.rs (1)

54-59: Sample doesn't reflect the default Kind.

Options::kind defaults to Kind::TimeOfDay (which produces "morning"/"afternoon"/"evening"/"night"), but the preview sample shows "day 113 of 2026" — output of Kind::DayOfYear. Readers landing on the docs page for the default configuration will see a sample that doesn't match what they'd actually get out of the box.

Consider using "afternoon" (or similar time_of_day output) so the preview matches the no-config behavior, or pick the most visually interesting kind and document that kind is set to day_of_year in the preview.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/clock/derived.rs` around lines 54 - 59, The sample_body
implementation currently returns a DayOfYear string ("day 113 of 2026") which
mismatches the default Options::kind (Kind::TimeOfDay); update the Shape::Lines
branch in sample_body (function sample_body, pattern Shape::Lines, call
samples::lines) to return a TimeOfDay-style sample such as "afternoon" (e.g.,
samples::lines(&["afternoon"])), or alternatively change the preview code to
explicitly document that the sample uses Kind::DayOfYear if you intend to keep
the current sample.
src/render/mod.rs (1)

197-203: Minor: prefer iterator-chain sort.

Per coding guidelines ("Prefer map, filter, reduce over imperative loops"), this can be expressed more idiomatically, though the current form is fine.

♻️ Optional refactor
-    pub fn sorted(&self) -> Vec<Arc<dyn Renderer>> {
-        let mut entries: Vec<_> = self.renderers.values().cloned().collect();
-        entries.sort_by(|a, b| a.name().cmp(b.name()));
-        entries
-    }
+    pub fn sorted(&self) -> Vec<Arc<dyn Renderer>> {
+        let mut entries: Vec<_> = self.renderers.values().cloned().collect();
+        entries.sort_by_key(|r| r.name().to_string());
+        entries
+    }

As per coding guidelines: "Prefer map, filter, reduce over imperative loops in Rust code".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/render/mod.rs` around lines 197 - 203, The sorted() method currently
collects into a Vec then sorts imperatively; change it to an iterator-chain
using itertools so it's more idiomatic: use
self.renderers.values().cloned().sorted_by_key(|r| r.name()).collect() (requires
adding use itertools::Itertools) or alternatively use
collect().into_iter().sorted_by_key(...) from Itertools; update the sorted()
implementation accordingly referencing the sorted() function and the renderers
field.
docs-site/package.json (1)

18-20: Document the @astrojs/sitemap pin.

The overrides pin to 3.7.0 has no accompanying comment explaining why a specific version is required (peer/resolution conflict with Starlight 0.37? a regression in a newer sitemap?). A brief note here (or in a nearby doc) will prevent the next maintainer from silently bumping it and reintroducing the problem.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-site/package.json` around lines 18 - 20, The package.json overrides
entry pins "@astrojs/sitemap": "3.7.0" but lacks any explanatory comment; update
the docs/package.json area to add a short comment (or nearby README note)
explaining why the sitemap package is pinned (e.g., peer resolution conflict
with Starlight 0.37 or a regression in newer sitemap versions), referencing the
exact override key "@astrojs/sitemap": "3.7.0" and including reproduction
details or links to the issue/PR so future maintainers understand why it must
not be bumped silently.
.github/workflows/docs.yml (1)

16-18: Consider cancel-in-progress: false for the Pages deploy group.

GitHub's own Pages starter workflows recommend not cancelling in-progress deploy runs, because cancelling after upload-pages-artifact / during deploy-pages can leave the site in an inconsistent state or trip the Pages API. Rapid-fire pushes will still queue and only the latest artifact wins, just more safely. Build-only cancellation is fine, but for a single combined pages group this is usually set to false.

 concurrency:
   group: pages
-  cancel-in-progress: true
+  cancel-in-progress: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/docs.yml around lines 16 - 18, The concurrency block
currently sets cancel-in-progress: true for the GitHub Actions concurrency group
named "pages"; change the key cancel-in-progress to false so the pages deploy
group does not cancel in-progress runs (i.e., update the concurrency.group
"pages" entry to use cancel-in-progress: false) to avoid leaving Pages
deployments in an inconsistent state when upload-pages-artifact / deploy-pages
are in-flight.
xtask/src/html_snapshot.rs (1)

17-26: Avoid the per-cell Cell::clone().

Only immutable reads (cell_style(&cell), cell.symbol()) are needed; a reference is enough and avoids an allocation-per-cell on larger buffers.

♻️ Suggested change
-        for x in 0..area.width {
-            let cell = buf[(x, y)].clone();
-            let style = cell_style(&cell);
+        for x in 0..area.width {
+            let cell = &buf[(x, y)];
+            let style = cell_style(cell);
             if Some(style) != run_style {
                 flush_run(&mut out, run_style.as_ref(), &run_cells);
                 run_cells.clear();
                 run_style = Some(style);
             }
             run_cells.push(cell.symbol().to_string());
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@xtask/src/html_snapshot.rs` around lines 17 - 26, The loop is cloning each
Cell unnecessarily; change let cell = buf[(x, y)].clone() to borrow the cell
(let cell = &buf[(x, y)]) and update subsequent calls to use the reference
(cell_style(&cell) stays the same, cell.symbol() stays the same) so you avoid an
allocation-per-cell; ensure run_cells.push(...) still accepts the symbol
(convert to String as before) and that flush_run(&mut out, run_style.as_ref(),
&run_cells) continues to work with run_style and run_cells unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fetcher/git/commits_activity.rs`:
- Around line 40-49: The sample for Shape::Lines in sample_body currently uses
the text "42 commits this month" which doesn't match render_body's real output;
update the Shape::Lines arm inside fn sample_body to emit a string following the
actual format (e.g., "42 commits in the last 52 weeks" or use the WEEKS constant
if available) so docs previews match render_body's "{total} commits in the last
{WEEKS} weeks" output.

In `@src/fetcher/git/latest_tag.rs`:
- Around line 34-44: In sample_body (function sample_body) the Entries branch
emits an entry with key "short" but the real build() uses "commit"; update the
Entries sample in sample_body (Shape::Entries) to use the key "commit" with the
same short-hash value and ensure the entry order/keys match the real output
["tag","commit","date"] so docs previews reflect the actual payload shape.

In `@src/fetcher/git/status.rs`:
- Around line 34-46: The Lines sample in sample_body (Shape::Lines branch using
samples::lines) uses a different glyph set than the real output from
format_line; update the sample to match format_line's runtime string (e.g.,
"main ↑2 ↓0 · clean") or generate the sample by calling format_line (or the same
helper that format_line uses) so documentation previews reflect actual output;
modify sample_body's Shape::Lines case accordingly and keep PayloadStatus/other
sample values consistent with format_line's inputs.

In `@src/fetcher/git/worktrees.rs`:
- Around line 30-44: The sample_body implementation in sample_body
(Shape::Entries and Shape::Lines) doesn't match the real render_body/format_line
schema: replace the samples::entries call so entries use worktree id as the key
(e.g. "(main)") and values formatted as "<branch> @ <path>" (e.g. "main @
/repo") to mirror Entry { key = worktree id, value = "<branch> @ <path>" }, and
update the Shape::Lines samples::lines strings to the same format used by
format_line ("<id> (<branch>) @ <path>") so both Entries and Lines snapshots
reflect actual output; adjust the array items for samples::entries and
samples::lines in sample_body accordingly.

In `@src/fetcher/mod.rs`:
- Around line 92-98: The default sample_body currently returns
samples::canonical_sample for any non-image Shape even if that Shape is not
advertised by the Fetcher; change sample_body(&self, shape: Shape) to first
check whether shape is contained in self.shapes() and only then return
samples::canonical_sample(shape), otherwise return None; apply the same pattern
to the other default sample helper implementations referenced in the review so
they all enforce membership in shapes() before returning a sample.

In `@xtask/src/main.rs`:
- Around line 1-15: Update the crate-level doc comment to remove "future work"
wording and state that HTML snapshot/preview generation is implemented in this
crate: reference the html_snapshot and snapshots modules and the gen_matrix code
path that emits <pre class="splash-snapshot"> fragments via buffer_to_html;
change the prose to say previews/HTML production are produced here (at
build/xtask time) and briefly mention the modules responsible (html_snapshot,
snapshots, gen_matrix/buffer_to_html) so the comment accurately reflects current
behavior.

---

Nitpick comments:
In @.github/workflows/docs.yml:
- Around line 16-18: The concurrency block currently sets cancel-in-progress:
true for the GitHub Actions concurrency group named "pages"; change the key
cancel-in-progress to false so the pages deploy group does not cancel
in-progress runs (i.e., update the concurrency.group "pages" entry to use
cancel-in-progress: false) to avoid leaving Pages deployments in an inconsistent
state when upload-pages-artifact / deploy-pages are in-flight.

In `@docs-site/package.json`:
- Around line 18-20: The package.json overrides entry pins "@astrojs/sitemap":
"3.7.0" but lacks any explanatory comment; update the docs/package.json area to
add a short comment (or nearby README note) explaining why the sitemap package
is pinned (e.g., peer resolution conflict with Starlight 0.37 or a regression in
newer sitemap versions), referencing the exact override key "@astrojs/sitemap":
"3.7.0" and including reproduction details or links to the issue/PR so future
maintainers understand why it must not be bumped silently.

In `@docs-site/src/styles/snapshot.css`:
- Line 5: The CSS currently pulls JetBrains Mono from Google via the `@import` URL
in snapshot.css, creating a third-party runtime dependency; remove that remote
`@import` and instead self-host the font (for example install
`@fontsource/jetbrains-mono` and import it from the package in your build entry or
main stylesheet), then update snapshot.css to reference "JetBrains Mono" in
font-family without the external URL; locate the `@import` line in snapshot.css
and replace the external import with the local package import and ensure any
build/asset pipeline copies the font into the site bundle so no
fonts.googleapis.com requests occur.

In `@src/fetcher/clock/derived.rs`:
- Around line 54-59: The sample_body implementation currently returns a
DayOfYear string ("day 113 of 2026") which mismatches the default Options::kind
(Kind::TimeOfDay); update the Shape::Lines branch in sample_body (function
sample_body, pattern Shape::Lines, call samples::lines) to return a
TimeOfDay-style sample such as "afternoon" (e.g.,
samples::lines(&["afternoon"])), or alternatively change the preview code to
explicitly document that the sample uses Kind::DayOfYear if you intend to keep
the current sample.

In `@src/render/mod.rs`:
- Around line 197-203: The sorted() method currently collects into a Vec then
sorts imperatively; change it to an iterator-chain using itertools so it's more
idiomatic: use self.renderers.values().cloned().sorted_by_key(|r|
r.name()).collect() (requires adding use itertools::Itertools) or alternatively
use collect().into_iter().sorted_by_key(...) from Itertools; update the sorted()
implementation accordingly referencing the sorted() function and the renderers
field.

In `@xtask/src/html_snapshot.rs`:
- Around line 17-26: The loop is cloning each Cell unnecessarily; change let
cell = buf[(x, y)].clone() to borrow the cell (let cell = &buf[(x, y)]) and
update subsequent calls to use the reference (cell_style(&cell) stays the same,
cell.symbol() stays the same) so you avoid an allocation-per-cell; ensure
run_cells.push(...) still accepts the symbol (convert to String as before) and
that flush_run(&mut out, run_style.as_ref(), &run_cells) continues to work with
run_style and run_cells unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7b539ab-87d0-4af0-8729-55794207cd52

📥 Commits

Reviewing files that changed from the base of the PR and between f54ed10 and 6d1dc9f.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • docs-site/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (42)
  • .cargo/config.toml
  • .github/workflows/docs.yml
  • Cargo.toml
  • docs-site/.gitignore
  • docs-site/astro.config.mjs
  • docs-site/package.json
  • docs-site/src/content.config.ts
  • docs-site/src/content/docs/404.md
  • docs-site/src/content/docs/index.md
  • docs-site/src/styles/snapshot.css
  • docs-site/tsconfig.json
  • src/fetcher/clock/countdown.rs
  • src/fetcher/clock/derived.rs
  • src/fetcher/clock/mod.rs
  • src/fetcher/clock/ratio.rs
  • src/fetcher/clock/state.rs
  • src/fetcher/clock/sunrise.rs
  • src/fetcher/clock/timezones.rs
  • src/fetcher/git/blame_heatmap.rs
  • src/fetcher/git/commits_activity.rs
  • src/fetcher/git/contributors.rs
  • src/fetcher/git/latest_tag.rs
  • src/fetcher/git/recent_commits.rs
  • src/fetcher/git/stash_count.rs
  • src/fetcher/git/status.rs
  • src/fetcher/git/worktrees.rs
  • src/fetcher/mod.rs
  • src/fetcher/static_text.rs
  • src/fetcher/stub.rs
  • src/fetcher/system.rs
  • src/lib.rs
  • src/main.rs
  • src/options.rs
  • src/render/ascii_art.rs
  • src/render/mod.rs
  • src/render/text.rs
  • src/samples.rs
  • xtask/Cargo.toml
  • xtask/src/gen_matrix.rs
  • xtask/src/html_snapshot.rs
  • xtask/src/main.rs
  • xtask/src/snapshots.rs

Comment on lines +40 to +49
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Heatmap => samples::heatmap_grid(7, 14),
Shape::NumberSeries => samples::number_series(&[
2, 5, 3, 8, 4, 9, 6, 11, 7, 3, 4, 6, 2, 5, 8, 10, 7, 4, 9, 6,
]),
Shape::Lines => samples::lines(&["42 commits this month"]),
_ => return None,
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Lines sample phrasing drifts from real output.

render_body emits "{total} commits in the last {WEEKS} weeks" (52 weeks), while the sample says "42 commits this month". Consider matching the real format so docs previews represent actual output.

♻️ Suggested tweak
-            Shape::Lines => samples::lines(&["42 commits this month"]),
+            Shape::Lines => samples::lines(&["128 commits in the last 52 weeks"]),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Heatmap => samples::heatmap_grid(7, 14),
Shape::NumberSeries => samples::number_series(&[
2, 5, 3, 8, 4, 9, 6, 11, 7, 3, 4, 6, 2, 5, 8, 10, 7, 4, 9, 6,
]),
Shape::Lines => samples::lines(&["42 commits this month"]),
_ => return None,
})
}
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Heatmap => samples::heatmap_grid(7, 14),
Shape::NumberSeries => samples::number_series(&[
2, 5, 3, 8, 4, 9, 6, 11, 7, 3, 4, 6, 2, 5, 8, 10, 7, 4, 9, 6,
]),
Shape::Lines => samples::lines(&["128 commits in the last 52 weeks"]),
_ => return None,
})
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/git/commits_activity.rs` around lines 40 - 49, The sample for
Shape::Lines in sample_body currently uses the text "42 commits this month"
which doesn't match render_body's real output; update the Shape::Lines arm
inside fn sample_body to emit a string following the actual format (e.g., "42
commits in the last 52 weeks" or use the WEEKS constant if available) so docs
previews match render_body's "{total} commits in the last {WEEKS} weeks" output.

Comment on lines +34 to +44
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Lines => samples::lines(&["v1.2.3"]),
Shape::Entries => samples::entries(&[
("tag", "v1.2.3"),
("short", "a1b2c3d"),
("date", "2026-04-14"),
]),
_ => return None,
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

sample_body entry key diverges from real fetch output.

The real build() emits entry keys ["tag", "commit", "date"] (line 59 uses entry("commit", &tag.short_hash) and the test at line 151 asserts exactly that order/keys), but the sample here emits "short" instead of "commit". Docs previews generated from sample_body will therefore misrepresent the actual payload shape that renderers/configs see at runtime.

Proposed fix
             Shape::Entries => samples::entries(&[
                 ("tag", "v1.2.3"),
-                ("short", "a1b2c3d"),
+                ("commit", "a1b2c3d"),
                 ("date", "2026-04-14"),
             ]),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/git/latest_tag.rs` around lines 34 - 44, In sample_body (function
sample_body) the Entries branch emits an entry with key "short" but the real
build() uses "commit"; update the Entries sample in sample_body (Shape::Entries)
to use the key "commit" with the same short-hash value and ensure the entry
order/keys match the real output ["tag","commit","date"] so docs previews
reflect the actual payload shape.

Comment thread src/fetcher/git/status.rs
Comment on lines +34 to +46
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Entries => samples::entries(&[
("branch", "main"),
("ahead", "2"),
("modified", "3"),
("untracked", "1"),
]),
Shape::Lines => samples::lines(&["main +2 −0 ◆3 ?1"]),
Shape::Badge => samples::badge(PayloadStatus::Ok, "clean"),
_ => return None,
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Lines sample drifts from the actual format_line output.

The sample "main +2 −0 ◆3 ?1" uses a different glyph vocabulary than the real runtime string produced by format_line ("main ↑2 ↓0 · clean"). Since sample_body is the source of truth for generated documentation previews, showing a format that users will never actually see is a bit misleading. Consider aligning the sample with real output (or updating format_line if this new vocabulary is intended).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/git/status.rs` around lines 34 - 46, The Lines sample in
sample_body (Shape::Lines branch using samples::lines) uses a different glyph
set than the real output from format_line; update the sample to match
format_line's runtime string (e.g., "main ↑2 ↓0 · clean") or generate the sample
by calling format_line (or the same helper that format_line uses) so
documentation previews reflect actual output; modify sample_body's Shape::Lines
case accordingly and keep PayloadStatus/other sample values consistent with
format_line's inputs.

Comment on lines +30 to +44
fn sample_body(&self, shape: Shape) -> Option<Body> {
Some(match shape {
Shape::Entries => samples::entries(&[
("main", "/repo"),
("feat/foo", "/repo-feat"),
("hotfix", "/repo-hotfix"),
]),
Shape::Lines => samples::lines(&[
"main /repo",
"feat/foo /repo-feat",
"hotfix /repo-hotfix",
]),
_ => return None,
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Sample Entries payload doesn't match the actual fetch output schema.

The real render_body emits Entry { key = worktree id (e.g. "(main)"), value = "<branch> @ <path>" }, but the sample calls samples::entries(&[("main", "/repo"), ...]) which produces key="main", value="/repo" — no branch-qualified value, and key is branch rather than worktree id. This will make the rendered docs preview diverge from real output.

🛠️ Suggested fix
-            Shape::Entries => samples::entries(&[
-                ("main", "/repo"),
-                ("feat/foo", "/repo-feat"),
-                ("hotfix", "/repo-hotfix"),
-            ]),
+            Shape::Entries => samples::entries(&[
+                ("(main)", "main @ /repo"),
+                ("wt-1", "feat/foo @ /repo-feat"),
+                ("wt-2", "hotfix @ /repo-hotfix"),
+            ]),

Also note the Lines sample uses a "<branch> <path>" column layout while the real format_line emits "<id> (<branch>) @ <path>" — consider aligning those too for snapshot fidelity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/git/worktrees.rs` around lines 30 - 44, The sample_body
implementation in sample_body (Shape::Entries and Shape::Lines) doesn't match
the real render_body/format_line schema: replace the samples::entries call so
entries use worktree id as the key (e.g. "(main)") and values formatted as
"<branch> @ <path>" (e.g. "main @ /repo") to mirror Entry { key = worktree id,
value = "<branch> @ <path>" }, and update the Shape::Lines samples::lines
strings to the same format used by format_line ("<id> (<branch>) @ <path>") so
both Entries and Lines snapshots reflect actual output; adjust the array items
for samples::entries and samples::lines in sample_body accordingly.

Comment thread src/fetcher/mod.rs
Comment on lines +92 to +98
/// A representative payload body for the given shape, used to preview what this fetcher
/// emits without executing it. Default falls back to [`crate::samples::canonical_sample`];
/// fetchers override to surface something closer to real output (`"main +2 ◆3"` for
/// `git_status`, `"14:35"` for `clock`). Must be a member of `shapes()`.
fn sample_body(&self, shape: Shape) -> Option<Body> {
samples::canonical_sample(shape)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Return None for unsupported sample shapes.

The defaults currently return a canonical payload for any non-image Shape, even when that shape is not in self.shapes(). That can make docs/preview callers accidentally render unsupported Fetcher × Renderer pairings as valid. Based on learnings, Each Fetcher must declare its supported shapes via fn shapes(&self) -> &[Shape].

🛡️ Proposed fix to enforce the advertised shape contract
     fn sample_body(&self, shape: Shape) -> Option<Body> {
-        samples::canonical_sample(shape)
+        if self.shapes().contains(&shape) {
+            samples::canonical_sample(shape)
+        } else {
+            None
+        }
     }
@@
     fn sample_body(&self, shape: Shape) -> Option<Body> {
-        samples::canonical_sample(shape)
+        if self.shapes().contains(&shape) {
+            samples::canonical_sample(shape)
+        } else {
+            None
+        }
     }
@@
     pub fn sample_body(&self, shape: Shape) -> Option<Body> {
         match self {
-            Self::Cached(f) => f.sample_body(shape),
-            Self::Realtime(f) => f.sample_body(shape),
+            Self::Cached(f) if f.shapes().contains(&shape) => f.sample_body(shape),
+            Self::Realtime(f) if f.shapes().contains(&shape) => f.sample_body(shape),
+            _ => None,
         }
     }

Also applies to: 117-120, 195-199

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fetcher/mod.rs` around lines 92 - 98, The default sample_body currently
returns samples::canonical_sample for any non-image Shape even if that Shape is
not advertised by the Fetcher; change sample_body(&self, shape: Shape) to first
check whether shape is contained in self.shapes() and only then return
samples::canonical_sample(shape), otherwise return None; apply the same pattern
to the other default sample helper implementations referenced in the review so
they all enforce membership in shapes() before returning a sample.

Comment thread xtask/src/main.rs
Comment on lines +1 to +15
//! Workspace tooling for splashboard. Run via `cargo xtask`.
//!
//! Reads the built-in fetcher / renderer registries and writes Markdown reference pages (one
//! per fetcher, one per renderer, plus an overview). Snapshot / preview generation lives with
//! the Astro docs-site (future work) so HTML production stays a build-time concern of the site,
//! not this tool.

use std::path::PathBuf;

use anyhow::Result;
use clap::Parser;

mod gen_matrix;
mod html_snapshot;
mod snapshots;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale module doc: snapshot/HTML generation is no longer "future work".

The doc comment says HTML production lives on the Astro side, but this crate declares html_snapshot and snapshots, and gen_matrix embeds <pre class="splash-snapshot"> fragments via buffer_to_html. Please update the description to reflect that previews are now produced here.

✏️ Suggested wording
 //! Workspace tooling for splashboard. Run via `cargo xtask`.
 //!
 //! Reads the built-in fetcher / renderer registries and writes Markdown reference pages (one
-//! per fetcher, one per renderer, plus an overview). Snapshot / preview generation lives with
-//! the Astro docs-site (future work) so HTML production stays a build-time concern of the site,
-//! not this tool.
+//! per fetcher, one per renderer, plus an overview). Inline HTML previews are rendered here
+//! via ratatui's `TestBackend` and embedded into the generated Markdown as
+//! `<pre class="splash-snapshot">` fragments (see `snapshots` and `html_snapshot`).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//! Workspace tooling for splashboard. Run via `cargo xtask`.
//!
//! Reads the built-in fetcher / renderer registries and writes Markdown reference pages (one
//! per fetcher, one per renderer, plus an overview). Snapshot / preview generation lives with
//! the Astro docs-site (future work) so HTML production stays a build-time concern of the site,
//! not this tool.
use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
mod gen_matrix;
mod html_snapshot;
mod snapshots;
//! Workspace tooling for splashboard. Run via `cargo xtask`.
//!
//! Reads the built-in fetcher / renderer registries and writes Markdown reference pages (one
//! per fetcher, one per renderer, plus an overview). Inline HTML previews are rendered here
//! via ratatui's `TestBackend` and embedded into the generated Markdown as
//! `<pre class="splash-snapshot">` fragments (see `snapshots` and `html_snapshot`).
use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
mod gen_matrix;
mod html_snapshot;
mod snapshots;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@xtask/src/main.rs` around lines 1 - 15, Update the crate-level doc comment to
remove "future work" wording and state that HTML snapshot/preview generation is
implemented in this crate: reference the html_snapshot and snapshots modules and
the gen_matrix code path that emits <pre class="splash-snapshot"> fragments via
buffer_to_html; change the prose to say previews/HTML production are produced
here (at build/xtask time) and briefly mention the modules responsible
(html_snapshot, snapshots, gen_matrix/buffer_to_html) so the comment accurately
reflects current behavior.

@unhappychoice
unhappychoice merged commit b020403 into main Apr 22, 2026
5 checks passed
@unhappychoice
unhappychoice deleted the feat/docs-site-52 branch April 22, 2026 03:02
unhappychoice added a commit that referenced this pull request May 17, 2026
Replaces the local 4-element SHAPES const with the shared `LIST_SHAPES`
(LinkedTextBlock / TextBlock / MarkdownTextBlock / ImageLinkedList /
Entries / Text / Bars / Badge / Timeline). `fetch` routes through
`forge_items::dispatch_rows_async` so `ImageLinkedList` resolves author
avatars through the thumbnails cache and `Badge` produces the
`"N open PRs"` count-pill.

Entries key convention changes from "splashboard #54" to
"#54" so the row label stays consistent across
every shape variant. Repo-scope fetchers (which already used `#54`)
are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
unhappychoice added a commit that referenced this pull request May 17, 2026
Same migration as the user-scope fetchers, but with `include_repo = false`
so the row label stays the bare `#54` rather than the full
`#54`. Badge noun pair is ("open PR", "open PRs").

Co-Authored-By: Claude Opus 4.7 (1M context) <[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: browsable widget catalog site (Astro + Starlight + xtask snapshot generator)

1 participant