v3: src/ is documented like api/ and shared/, and the reference covers the whole repository — the frontend had no module docs, JSDoc on some components and hooks and not on others, props typed inline in half the components and in private interfaces in the rest, // comments on declarations, and no return types on 147 exported functions, so deno doc --lint over src/ found 637 errors. The rule api/ follows is applied to every non-test module of src/: a /** … @module */ block, JSDoc on every export and every field of an exported interface, /** */ for declarations and // for notes, verbs for functions ("Renders…" for a component), parameters named in the prose, {@link} only for symbols in scope, and a page's JSDoc names its route and who may see it (App.tsx's module doc lists the route table). For deno doc to show them, every exported function states its return type: components React.JSX.Element (or | null, or a portal), memo and forwardRef components their exotic types, contexts React.Context<…>, and a hook returning several things a documented Use<Name>Result interface (useAuth, useRequiredAuth, useFading, useEmojiTrigger, useMentionAutocomplete, useDumpCardLink, usePlayRichContent; FeedCacheResult, YouTubePlaylistControls and UseApiFormReturn are renamed to match). Every component that takes props takes an exported, documented <Name>Props interface — the 64 inline prop types are lifted into one, DumpFeed gets DumpFeedProps extending MainFeedProps. React types go through the global React namespace: the four default imports of react are gone, since deno doc can't follow them. Two duplicates go too: useMentionAutocomplete's UserResult was shared/'s UserSuggestion, and JournalCard re-exported JournalShape for no one; i18n.ts no longer re-exports Lingui's i18n, which its three users now import from @lingui/core. deno task doc and doc:lint now take src/ (but its tests and the generated locales), the index page gains a Frontend section linking every module by layer and domain, mod.test.ts walks src/ as well, and the docs workflow runs on changes to src/. deno doc doesn't document npm packages, so it takes a type imported from one — react-hook-form's FieldValues in the form fields, frimousse's SkinTone — for a private one; doc:lint now goes through doc-lint.ts, which fails on every diagnostic but those, 25 of them. The README states the frontend's part of the rule. No behaviour changes; 205 backend and 628 frontend tests pass, and tsc, deno check and deno lint are clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
README.md
44
README.md
@@ -158,22 +158,34 @@ place that fetches from other sites. Tests mirror the source one file per
|
||||
module, so the tests of `services/chat-service.ts` are in
|
||||
`test/services/chat-service.test.ts`.
|
||||
|
||||
The backend and `shared/` are documented for `deno doc`, the same way in every
|
||||
file. Each module opens with a `/** … @module */` block saying what it is for.
|
||||
Every export has a JSDoc comment, and so does every field of an exported
|
||||
interface; a comment that describes a declaration is always `/** */`, and `//`
|
||||
is only for notes on the code inside. Functions open with a verb ("Returns…",
|
||||
"Checks…"), everything else with a noun phrase. Parameters are named in the
|
||||
prose, in backticks. `{@link}` points at symbols the file already has in scope.
|
||||
A function that can throw to its caller says so with `@throws`: for an
|
||||
`APIException`, the statuses and when. A router's JSDoc lists its endpoints, one
|
||||
line each: method and path, who may call it, what it does. `deno task doc`
|
||||
builds the HTML reference into `docs/` from every module of `api/` and `shared/`
|
||||
but the tests. Its index page is the module doc of `mod.ts` at the root, which
|
||||
introduces the repository's three parts and links every documented module
|
||||
(`mod.test.ts` checks it), and the `docs` workflow publishes it on every push to
|
||||
`main` that touches them. `deno task doc:lint` checks the rules the linter can
|
||||
see.
|
||||
All three parts — `api/`, `shared/` and `src/` — are documented for `deno doc`,
|
||||
the same way in every file. Each module opens with a `/** … @module */` block
|
||||
saying what it is for. Every export has a JSDoc comment, and so does every field
|
||||
of an exported interface; a comment that describes a declaration is always `/**
|
||||
*/`, and `//` is only for notes on the code inside. Functions open with a verb
|
||||
("Returns…", "Checks…", "Renders…" for a component), everything else with a noun
|
||||
phrase. Parameters are named in the prose, in backticks. `{@link}` points at
|
||||
symbols the file already has in scope. A function that can throw to its caller
|
||||
says so with `@throws`: for an `APIException`, the statuses and when. A router's
|
||||
JSDoc lists its endpoints, one line each: method and path, who may call it, what
|
||||
it does; a page's names its route and who may see it.
|
||||
|
||||
In the frontend, every exported function states its return type, so the
|
||||
reference can show it: a component returns `React.JSX.Element` (or `| null`), a
|
||||
hook returning several things returns a documented `Use<Name>Result` interface.
|
||||
A component that takes props takes an exported `<Name>Props` interface, each
|
||||
prop documented. React's types are used through the global `React` namespace
|
||||
rather than a default import of `react`, which `deno doc` can't follow.
|
||||
|
||||
`deno task doc` builds the HTML reference into `docs/` from every module of
|
||||
`api/`, `shared/` and `src/` but the tests (and the generated `src/locales/`).
|
||||
Its index page is the module doc of `mod.ts` at the root, which introduces the
|
||||
repository's three parts and links every documented module (`mod.test.ts` checks
|
||||
it), and the `docs` workflow publishes it on every push to `main` that touches
|
||||
them. `deno task doc:lint` checks the rules the linter can see, through
|
||||
`doc-lint.ts`: `deno doc` doesn't document npm packages, so it takes a type
|
||||
imported from one (react-hook-form's `FieldValues`, say) for a private one, and
|
||||
those references alone are let through.
|
||||
|
||||
Each of the frontend's `components/`, `contexts/`, `hooks/` and `utils/` is
|
||||
split into the same domain folders — `auth`, `category`, `chat`, `comment`,
|
||||
|
||||
Reference in New Issue
Block a user