fluffos/docs/README.md
Yucong Sun 89060c5a6b
docs: fully-expandable generated sidebar + Chinese docs via Docusaurus i18n (#1246)
* docs: fully-expandable generated sidebar, replacing index.md link pages

Rework docs navigation so the sidebar expands to every page of every
reference tree, instead of terminating at generated index.md link lists:

- New docs/gen_sidebar.py (replaces gen_index.py + update_index.sh):
  walks efun/, apply/, stdlib/, concepts/, driver/, cli/ and zh-CN/ and
  emits sidebars.generated.json — a full Docusaurus category tree per
  directory. Category landing pages are now `generated-index` card pages
  (title/description/slug), so all generated index.md files are deleted.
  --check mode verifies freshness; new .github/workflows/docs-sidebar.yml
  runs it in CI.
- New docs/sidebar_meta.json holds curated presentation: category labels,
  one-line descriptions (shown on the landing cards), explicit ordering
  (driver/cli/concepts read top-down from user-facing to internals) and
  per-page label overrides.
- sidebars.ts becomes a hand-authored skeleton (Getting Started, lpc/,
  Historical) that splices in the generated trees.

Content reorganization (from a docs-wide review):
- Move misplaced efun pages out of efun/general: terminal/protocol efuns
  (act_mxp, send_zmp, request_term_*) to interactive/, debugging efuns
  (check_memory, dump_*, clear_debug_level, destructed_objects) to
  internals/, shallow_inherit_list to system/.
- Delete stub duplicates superseded by complete pages elsewhere:
  general/parse_{add_synonym,dump,my_rules,remove}, contrib/{shuffle,
  element_of}.

Modernize key pages with MDX:
- index.mdx: landing page with a card grid linking each doc section.
- build.mdx: per-platform <Tabs> (Ubuntu/macOS/Windows/Alpine+Docker),
  admonitions, VitePress [[toc]] leftover removed, stale per-platform CI
  workflow links updated to the unified ci.yml.
- ffi-plan.md: GitHub-style [!CAUTION] alert converted to an admonition.

`npm run build` passes clean (onBrokenLinks: throw, no warnings).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0174GM2azvAHBmvyESwxm5om

* docs: serve the Chinese corpus through Docusaurus i18n

Move the zh-CN/ directory out of the default docs tree and into a proper
Docusaurus locale (i18n/zh-CN/docusaurus-plugin-content-docs/current/):

- The flat zh-CN/efun/ directory (333 pages) is re-homed to mirror the
  categorized English layout (name-matched 1:1; `hash` maps to strings/
  per its own frontmatter). apply/ pages map 1:1; the stray English-text
  zh-CN/apply/master/view_errors.md documents a MudOS-era apply that no
  longer exists in the driver and is dropped; stdlib/db/database_zh.md
  becomes the i18n translation of stdlib/db/database.md; the Chinese
  build guide becomes the translation of build.mdx.
- Untranslated pages automatically fall back to English content under
  /zh-CN/, so the whole site is navigable in either locale from the new
  navbar locale dropdown.
- Both locales share one sidebar. Generated sidebar items now carry
  stable `key` fields (the directory/doc path) so translation keys are
  unique (both efun/ and stdlib/ have an "Arrays" category, crypto and
  strings both document `hash`). Category labels, generated-index
  titles/descriptions, navbar and footer are translated in
  i18n/zh-CN/...; theme UI strings come from Docusaurus' bundled
  zh-Hans translations. Translated landing page at /zh-CN/.
- The "中文文档" sidebar section, the zh-CN tree in gen_sidebar.py /
  sidebar_meta.json, and its slice of sidebars.generated.json are gone.
- Relative .md-file links on pages that render in both locales break
  the localized build (the file->permalink map points at the localized
  copy), so concepts/, the two socket_*_option pages and the config.md
  generator now emit extension-less route links instead.
- zh interactive.md/objects.md get explicit slugs like their English
  counterparts (a doc named after its parent directory is otherwise a
  Docusaurus category-index doc, colliding with the generated-index
  route).

`npm run build` builds both locales clean (onBrokenLinks: throw).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0174GM2azvAHBmvyESwxm5om

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-11 17:20:25 -04:00

5.2 KiB

FluffOS Documentation

This directory contains the source for the FluffOS documentation site, published at https://www.fluffos.info.

The site is built with Docusaurus 3 (@docusaurus/preset-classic). Markdown files live directly in this directory (the docs plugin is configured with path: '.' and routeBasePath: '/'), so docs/efun/strings/explode.md becomes /efun/strings/explode on the site.

This README is for contributors and is excluded from the published site (see exclude in docusaurus.config.ts).

Local Development

Requires Node.js 18+ (Node 22 recommended).

cd docs
npm install
npm run dev       # dev server on http://localhost:3000

Other scripts:

npm run build     # production build → docs/build/
npm run preview   # serve the production build locally
npm run clear     # clear the Docusaurus cache

Full-text search is provided by @easyops-cn/docusaurus-search-local, an offline/local search theme — the index is generated at build time and shipped with the site, so no external search service (e.g. Algolia) is needed.

Notes:

  • The search index is only generated by npm run build. In the dev server (npm run dev) the search bar shows a hint instead of results; use npm run build && npm run preview to test search locally.
  • Both English and Chinese pages are indexed (language: ['en', 'zh']).
  • Search options live in the themes section of docusaurus.config.ts.

Chinese docs (i18n)

The Chinese corpus lives under i18n/zh-CN/docusaurus-plugin-content-docs/current/, mirroring the English tree layout (a translation of docs/efun/arrays/allocate.md goes at i18n/zh-CN/docusaurus-plugin-content-docs/current/efun/arrays/allocate.md). The site serves it at /zh-CN/ with a locale dropdown in the navbar; untranslated pages automatically fall back to the English content.

  • Sidebar/navbar/footer label translations: i18n/zh-CN/docusaurus-plugin-content-docs/current.json and i18n/zh-CN/docusaurus-theme-classic/*.json. Rescaffold new keys with npx docusaurus write-translations --locale zh-CN after sidebar changes, then translate them.
  • The dev server runs one locale at a time: npm run dev -- --locale zh-CN.
  • npm run build builds both locales.

Layout

Path Contents
docusaurus.config.ts Site config: navbar, footer, docs plugin, search theme
sidebars.ts Sidebar skeleton; splices in the generated reference trees
sidebars.generated.json Generated sidebar trees for the reference docs (do not hand-edit)
sidebar_meta.json Curated sidebar labels, descriptions and ordering for the generated trees
src/css/custom.css Infima CSS variable overrides
static/ Files copied verbatim to the site root (CNAME, Google site verification)
apply/ Driver-to-LPC callback (apply) reference
efun/ Built-in function (efun) reference, by category
stdlib/ LPC standard-library reference
driver/ Driver internals & configuration
lpc/ LPC language reference
concepts/ High-level LPC / MUD concepts
cli/ Command-line tool docs
i18n/zh-CN/ Chinese translations (Docusaurus i18n; mirrors the English tree layout)
archive/ Historical MudOS-era documents (not published)

Maintenance scripts

Script Purpose
gen_sidebar.py Regenerates sidebars.generated.json from the reference doc trees + sidebar_meta.json (--check verifies freshness, used by CI)
gen_config_docs.py Regenerates driver/config.md from src/base/internal/rc.cc
add_missing_efuns.py Creates stub pages under efun/general/ for undocumented efuns (needs a keywords.json from the generate_keywords tool)

Conventions & Gotchas

  • driver/config.md is auto-generated from src/base/internal/rc.cc — never edit it by hand. Regenerate with python3 docs/gen_config_docs.py; CI fails if it is stale.
  • .md files are treated as standard CommonMark (markdown.format: 'detect'), but bare {...} in prose is still parsed as a JSX expression and breaks the build — escape it as \{...\} outside fenced code blocks.
  • Sidebar entries in sidebars.ts use doc IDs (relative path without extension), not URLs.
  • The reference trees (efun/apply/stdlib/cli/concepts/driver) have no index.md files: their sidebar trees live in sidebars.generated.json and their landing pages are Docusaurus generated-index card pages. After adding, removing, or moving a page in those trees, run ./gen_sidebar.py and commit the result — CI fails if it is stale. Category labels/descriptions/ordering are curated in sidebar_meta.json. lpc/index.md is hand-written and its sidebar is hand-authored in sidebars.ts.
  • The sidebar is shared by both locales; Chinese category labels come from i18n/zh-CN/docusaurus-plugin-content-docs/current.json, not from sidebar_meta.json.
  • onBrokenLinks is set to 'throw': a broken internal link fails the build (and the Pages deploy) instead of shipping a 404.

See CLAUDE.md for detailed documentation templates (applies, efuns, CLI tools) and the full contribution workflow.