v3: comments say what the code can't — the documentation pass wanted JSDoc on every export and every field of an exported interface, which filled the code with restatements ("The dump.", "Whether it is loading.", "The props of X.", "Renders the X.") and module docs that told a reader nothing ("The hot and new feeds, and the props every main feed of the index takes."); some were wrong as well as vague. Every comment in api/, shared/ and src/ is rewritten under one rule, now stated in the README's "Comments" section: every module and export still has a JSDoc, and it gives context (who uses it and where), usage (what a caller must know: a precondition, what it leaves to the caller, a side effect) or its place in the chain (where its input comes from, where its output goes); a field, parameter, private function or local gets one only when it adds to its parent's, and context about a whole type goes on the type; a type's doc is phrased from the value's side ("Returned to Y by X when Z", "Passed to Y by X"); full sentences, as short as they can be, no label-colon-list; // goes wherever the code isn't obvious and says why, and the section banners and narration go. Every claim was checked against the code, which turned up some forty comments that were wrong: DumpCard's claimed it was only used by the hot and new feeds, the WebSocket welcome claimed to be a socket's first message (presence comes first), UpdateUserRequest said null removes a description (it keeps it), deletedDumpIds leaves out that it also holds dumps made private, THEME_COLOR claimed to mirror index.html's, and the like. The routers' JSDoc now says where they are mounted and what becomes of a thrown APIException. doc-lint.ts lets a field without a doc through; a module or export without one still fails. No code changes; 204 backend and 628 frontend tests pass, and doc:lint, deno check, deno lint and tsc are clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-09-29 14:31:14 +00:00
parent 42e0356d21
commit 0d4e344d77
287 changed files with 5679 additions and 5135 deletions

View File

@@ -1,5 +1,6 @@
/**
* The password change modal.
* Renders the password change dialog, which the settings tab of one's own
* profile opens.
*
* @module
*/
@@ -19,13 +20,11 @@ import { SubmitButton } from "../form/SubmitButton.tsx";
import { TextField } from "../form/TextField.tsx";
import { useApiForm } from "../../hooks/form/useApiForm.ts";
/** The props of {@link ChangePasswordModal}. */
/** Passed to {@link ChangePasswordModal} by `UserPublicProfile`. */
export interface ChangePasswordModalProps {
/** Called to close it. */
onClose: () => void;
}
/** The form's fields. */
interface Values {
currentPassword: string;
newPassword: string;
@@ -33,9 +32,8 @@ interface Values {
}
/**
* Renders the form that changes the user's password, given the current one. The
* change signs out every other session, and this one keeps the fresh tokens it
* is handed.
* Renders the form that changes the user's password, given the current one.
* The change signs out every other session, in every browser.
*/
export function ChangePasswordModal(
{ onClose }: ChangePasswordModalProps,
@@ -52,8 +50,8 @@ export function ChangePasswordModal(
});
const onSubmit = form.submit(async ({ currentPassword, newPassword }) => {
// The change signs out every session opened with the old password, this
// one included, so keep the fresh tokens it hands back.
// The server revokes every token issued before the change, this session's
// included, and hands back fresh ones. Other tabs read them from storage.
const tokens = await expectOk<{ token: string; mediaToken: string }>(
await authFetch(`${API_URL}/api/users/me/change-password`, {
method: "POST",

View File

@@ -1,5 +1,6 @@
/**
* The header of a profile's subpage.
* Renders the header of a profile's full lists, `/users/:username/dumps`,
* `/upvoted` and `/playlists`.
*
* @module
*/
@@ -9,20 +10,21 @@ import { Link } from "react-router";
import type { PublicUser } from "../../../shared/user.ts";
import { Avatar } from "../shared/Avatar.tsx";
/** The props of {@link ProfileSubpageHeader}. */
/**
* Passed to {@link ProfileSubpageHeader} by each of those pages, once it has
* loaded the profile's user.
*/
export interface ProfileSubpageHeaderProps {
/** The name in the route, for the back link. */
/** The `:username` of the route, which the back link leads to. */
username: string;
/** The profile's user. */
profileUser: PublicUser;
/** The subpage's title. */
title: string;
/** Buttons on the title row. */
/** Buttons at the end of the title row. */
actions?: ReactNode;
}
/**
* Renders a link back to the profile, and the subpage's title beside the user's
* Renders a link back to the profile, then the page's title beside the user's
* avatar.
*/
export function ProfileSubpageHeader(