Skip to content

Doc generation: msg variants as enum-parity children, contract polish, theming hooks#1419

Open
micahscopes wants to merge 7 commits intoargotorg:masterfrom
micahscopes:msg-doc-overhaul
Open

Doc generation: msg variants as enum-parity children, contract polish, theming hooks#1419
micahscopes wants to merge 7 commits intoargotorg:masterfrom
micahscopes:msg-doc-overhaul

Conversation

@micahscopes
Copy link
Copy Markdown
Collaborator

Summary

Restructures msg rendering so variants live as variant-kind children of the parent msg page (mirrors enum variants), adds first-class init and recv_handler children for contract pages, and parameterizes the doc viewer for downstream theming. Also fixes the doc-site deploy ref.

Changes

  • Model msg variants as variant children of their parent msg; drop the standalone msg_variant DocItem
  • Add Init and RecvHandler DocChildKinds for contract pages
  • Bump SCHEMA_VERSION 2 → 4; add v2→v3 and v3→v4 migrations in feMigrate
  • Skip desugared msg artifacts (per-variant structs and their impl blocks) during extraction
  • Resolve breadcrumb segments against ancestor kinds rather than hardcoding /mod
  • Substitute ingot config name for lib on the root module page
  • Add fe doc --include-tests; default off (test fns pollute the public API sidebar)
  • SCIP: prefer specific descriptors when occurrences tie on byte range; exclude attribute-internal occurrences from rich-signature overlays
  • Style scrollbars for dark mode, wrap long sidebar entries, expose font / weight / layout knobs as CSS variables
  • Drop search results lacking doc_url (they rendered as unclickable links)
  • CI: fix doc-site deploy ref gh-pagesmain (matches the actual fe-docs branch GitHub Pages serves from)

Notes

Existing 26.0.0 / 26.0.1 doc bundles will run the v2→v3 migration in-browser and lose msg-variant rows. Worth a follow-up regeneration pass for prior versions once this lands.

Test plan

  • cargo test -p fe-web — schema snapshot consistency
  • Local fe doc against a contract with msgs — variants render under their parent msg page
  • Local fe doc against a contract with init / receive handler — both surface as contract page children
  • Tag a test release on a fork to confirm the docs job pushes to fe-docs main

Previously `msg` blocks' desugared Mod + per-variant structs leaked into
docs: variants emitted as top-level DocItems with struct-shaped pages,
URLs used /mod and /struct suffixes, and the module nav tree double-
listed each variant. This produced broken links (/struct and /mod 404s),
duplicated items, and pages that treated message variants as if they
were structs rather than variant subsections of their parent msg.

Changes:

- extract.rs: detect desugared msg Mods and synthesized variant structs/
  impls via HirOrigin markers. Skip them from module item lists and
  populate the parent msg DocItem's `children` array with variant-shaped
  entries (kind: "variant", matching enum variants). Narrows msg variant
  field signatures to "field: Type" rather than the whole variant body.

- symbol.rs: `item_kind_to_url_suffix` returns "msg" for desugared msg
  Mods and "msg_variant" for variant structs instead of the generic
  "mod" and "struct". `scope_to_doc_path` rewrites msg_variant paths to
  `<parent>/msg~variant.<name>` anchors so clicks land on the parent
  msg page rather than a non-existent variant page. Also used by LSP
  goto/hover and SCIP symbol doc_url generation.

- scip_index.rs: `overlay_occurrences` prefers the more-specific symbol
  when two non-definition occurrences share a byte range, so variant
  names inside a msg block link to the variant rather than the parent
  namespace. Child doc_url generation collapses to the parent anchor
  when that anchor already contains `~` (viewer extracts the first
  tilde as the anchor, so nested anchors wouldn't route).

- fe-doc-item.js / fe-doc-viewer.js / fe-web.js / fe-search.js: add
  msg and msg_variant to the kind maps used for URL suffix resolution,
  display metadata, and search. Most were working by fallback accident;
  explicit entries keep the four files in sync.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8d9cb94c0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/fe/src/extract.rs
Comment thread crates/fe-web/assets/fe-scip-store.js Outdated
Schema goes from v2 to v4: v3 drops standalone msg_variant items
in favor of variant-kind children of their parent msg; v4 adds
explicit init/recv_handler children for contract pages.
The fe-doc-nav had `overflow-y: auto` which per CSS spec promotes
`overflow-x` from `visible` to `auto`, producing an awkward horizontal
scrollbar whenever sidebar entries (long test function names, etc.)
exceeded the sidebar width. Default browser scrollbars also read as
light-mode chrome on the dark theme.

- `.fe-doc-nav`: explicit `overflow-x: hidden`, dedicated webkit
  scrollbar styling using `--border` thumb and `--bg-secondary` track.
- `.fe-nav-items a`: `overflow-wrap: anywhere` + `word-break: break-word`
  so long underscored symbols wrap within the sidebar.
- Global body: `scrollbar-width: thin` + `scrollbar-color` for Firefox,
  `::-webkit-scrollbar*` rules for Chromium/WebKit using theme vars.
Adds first-class doc rendering for contract bodies and a handful of UX
fixes surfaced during review.

- Contract pages now emit `init` and `recv_handler` children alongside
  fields. `extract.rs` walks the init block and each `recv <Msg> { … }`
  arm, emitting a DocChild per entry. New DocChildKind::Init /
  RecvHandler, wired into fe-doc-item / fe-web CHILD_KIND maps with
  plurals "Initializer" and "Message Handlers".

- Schema bump to v4 (additive -- contracts gain children). fe-scip-store
  migration just updates version number; consumers of v3 data regen.

- `fe doc` hides `#[test]`-annotated items by default; new
  `--include-tests` flag restores them. Bountiful sidebar drops from
  ~800 items to ~80.

- Ingot root modules no longer display as `lib`; extractor substitutes
  the ingot's configured name (games, registry, shared, etc.).

- Deep links with `~anchor` suffixes now reliably scroll to the target:
  fe-doc-viewer retries anchor resolution for up to 1s while content
  renders; member-items carry inline scroll-margin-top so rows aren't
  hidden under sticky headers.

- Variant and handler rows are wrapped in anchor links so clicks
  anywhere in the row hit the row's anchor (previously only the `§`
  glyph was clickable).

- Search results with null doc_url (SCIP-only matches from builtin
  stdlib) are filtered out rather than rendering as broken `href="#"`
  links.

- SCIP signature-link overlay excludes byte ranges inside `#[…]`
  attributes, which were being wrongly attributed to random stdlib
  symbols (most visibly, every `#[selector = sol(...)]` attribute on
  msg variants pointed at Encode::encode_to_ptr).
Exposes CSS custom properties at :root so downstream consumers can
retheme the doc viewer by overriding a handful of variables rather
than waging specificity battles.

Knobs added:
- Fonts:   --fe-body-font, --fe-heading-font, --fe-mono-font
- Weights: --fe-body-weight, --fe-heading-weight,
           --fe-sidebar-weight, --fe-current-weight
- Pixel-rendering: --fe-font-smoothing, --fe-moz-font-smoothing,
                   --fe-text-rendering, --fe-letter-spacing,
                   --fe-heading-text-shadow, --fe-emphasis-text-shadow
- Layout:  --fe-content-max-width, --fe-sidebar-min-width,
           --fe-sidebar-max-width

All hardcoded "JetBrains Mono" / "Fira Code" strings replaced with
var(--fe-mono-font); body and headings now consume the weight and
rendering vars. The `h1..h6` block centralizes heading styling so
themes only set variables instead of per-element selectors.

Sidebar behavior adjusted to accommodate variable-width content:
grid-template-columns switches from fixed `280px 1fr` to `auto 1fr`,
with sidebar width driven by `width: max-content` between the new
sidebar min/max vars. Long names no longer wrap; horizontal scroll
on the sidebar itself is the fallback for outliers.

Responsive (max-width: 768px) block resets the sidebar's min/max
back to a fixed 280px so mobile layout is unchanged.
@micahscopes
Copy link
Copy Markdown
Collaborator Author

Pushed fixes for both Codex P2 findings:

  • extract.rs: ingot-name rewrite now also requires doc_item.path == cfg_name so nested submodules like foo::lib are left alone
  • fe-scip-store.js: v2→v3 migration drops legacy sub-anchors instead of concatenating them, so migrated links resolve to the variant row instead of producing a doubled-tilde hash that matches no element

Squashed into the relevant commits (Flesh out contract pages and polish navigation and Bump doc schema for msg variant restructure).

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