IF Commons GitHub

model

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-docs FR-001

The page model (commons 0011-documentation FR-016): every page of the site is a value of these types before it is HTML. Readers (the Markdown of TSDoc and of specifications, the API reader, the lenses) make blocks and inlines; the HTML emitter is the one writer, and matches every case with a switch that ends in absurd, so that a case added here and left out there does not compile.

Source: commons/docs/src/model.ts

3 of 12 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Badgeinterfaceno test imports it
interface Badge

A small label beside a title: a kind, a status, a mechanism.

MemberTypeWhat it is
textstringWhat it says.
toneToneIts colour.
Blocktype
type Block = | { readonly kind: "heading"; readonly level: 2 | 3 | 4; readonly id: string; readonly text: readonly Inl… (1476 characters)
type Block =
  | { readonly kind: "heading"; readonly level: 2 | 3 | 4; readonly id: string; readonly text: readonly Inline[] }
  | { readonly kind: "paragraph"; readonly inlines: readonly Inline[] }
  | { readonly kind: "meta"; readonly inlines: readonly Inline[] }
  | { readonly kind: "list"; readonly ordered: boolean; readonly items: readonly (readonly Block[])[] }
  | { readonly kind: "code"; readonly lang: Lang; readonly text: string; readonly title?: string }
  | { readonly kind: "table"; readonly head: readonly (readonly Inline[])[]; readonly rows: readonly (readonly (readonly Inline[])[])[]; readonly filter?: string; readonly compact?: boolean }
  | { readonly kind: "callout"; readonly tone: "note" | "limit" | "warn"; readonly title: string; readonly blocks: readonly Block[] }
  | {
    readonly kind: "entry";
    readonly id: string;
    readonly name: string;
    readonly badges: readonly Badge[];
    readonly signature?: string;
    readonly blocks: readonly Block[];
  }
  | { readonly kind: "tabs"; readonly id: string; readonly tabs: readonly Tab[] }
  | { readonly kind: "diagram"; readonly source: string; readonly caption: string }
  | { readonly kind: "cards"; readonly cards: readonly Card[] }
  | { readonly kind: "badges"; readonly badges: readonly Badge[] }
  | { readonly kind: "trend"; readonly label: string; readonly values: readonly number[]; readonly unit?: string }
  | { readonly kind: "tree"; readonly nodes: readonly TreeNode[] };

A part of a page.

Imported by 12 tests of the run (12 passed, 0 failed): the library's results

Cardinterfaceno test imports it
interface Card

A card: a title that links somewhere, with a line under it.

MemberTypeWhat it is
titlestringThe title.
hrefHrefWhere it goes.
textreadonly Inline[]The line under the title.
badges?readonly Badge[]Badges beside the title.
children?readonly Card[]Cards shown under this one, a level in.
Hreftypeno test imports it
type Href =
  | { readonly kind: "page"; readonly path: string; readonly anchor?: string }
  | { readonly kind: "external"; readonly url: string };

Where a link goes: a page of the site (by its path from the site's root), or an address outside it.

Inlinetypeno test imports it
type Inline =
  | { readonly kind: "text"; readonly text: string }
  | { readonly kind: "code"; readonly text: string }
  | { readonly kind: "emphasis"; readonly children: readonly Inline[] }
  | { readonly kind: "strong"; readonly children: readonly Inline[] }
  | { readonly kind: "link"; readonly href: Href; readonly children: readonly Inline[] };

A run of text inside a block.

Pageinterface
interface Page

A page: where it is, what it is called, which section and group of the navigation it is in, and its blocks.

MemberTypeWhat it is
pathstringIts path from the site's root, ending in .html.
titlestringIts title.
descriptionstringA sentence that says what it is, for the search and the page's description.
sectionSectionIts section.
groupstringIts group in the section's navigation.
ordernumberIts place in the group: lower first, then by title.
navTitle?stringWhat the navigation calls it, where that is not its title.
parent?stringThe page it is under in the navigation (its path): it is listed beneath that page, and only while that page or a page beneath it is the one being read.
navKind?stringWhat kind of page it is, for the small heading that groups the pages beneath one page in the navigation (Concepts, Code lists).
badges?readonly Badge[]Its badges, beside the title.
blocksreadonly Block[]What it holds.

Imported by 20 tests of the run (20 passed, 0 failed): the library's results

Sectiontypeno test imports it
type Section = "start" | "concepts" | "overview" | "howto" | "specs" | "api" | "models" | "programs" | "quality" | "repoops";

The sections of the site (commons 0011-documentation FR-009 and FR-032): the guides, the concepts, the libraries, the how-to pages, and the reference (specifications, API and models).

Tabinterfaceno test imports it
interface Tab

A tab of a set of tabs.

MemberTypeWhat it is
labelstringIts label.
blocksreadonly Block[]What it shows.
TreeNodeinterfaceno test imports it
interface TreeNode

A node of a tree diagram: a label, a note, and what is under it.

MemberTypeWhat it is
labelstringWhat the node is called, as code.
note?readonly Inline[]A short note beside it.
childrenreadonly TreeNode[]The nodes under it.
plainfunction
function plain(inlines: readonly Inline[]): string

The text of inlines, with no markup: for a heading's anchor, the search and a page's description.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

possessiveconstno test imports it
const possessive: (name: string) => string

A name as a possessive: commons', Stolos', Erga's.

slugOffunctionno test imports it
function slugOf(t: string): string

An anchor made from a text: lower-case letters, digits and hyphens.

Titles, headings, exports, tables, columns and requirements. Esc closes.