IF Commons GitHub

changes/issue-body

The body of a capability's change request as the check reads it (commons 0020-ifccm FR-003, FR-004, FR-006): its sections Why, Today, Scope and Done when in that order, its checkbox items (- [ ], - [x]) and the requirements its Done when names (NNNN-slug FR-nnn).

A section is a Markdown heading of any level whose text is the section's name (a trailing colon is allowed, case is not significant) and the lines under it up to the next heading of the same or a higher level. Lines inside a fenced code block are not read. The body is the text a Git host gives for an issue, so that a GitHub issue and a GitLab issue read the same.

import { parseIssueBody, unticked } from "./issue-body.ts";
const body = parseIssueBody("## Why\nx\n## Done when\n- [x] 0020-ifccm FR-005 by the test\n- [ ] 0020-ifccm FR-006\n");
unticked(body).length; // 1

Source: commons/mizan/src/changes/issue-body.ts

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

changes.doneWhenItemsfunctionno test imports it
function doneWhenItems(body: IssueBody): readonly CheckItem[]

The items under Done when, in order.

changes.doneWhenRequirementsfunctionno test imports it
function doneWhenRequirements(body: IssueBody): readonly string[]

The requirements the Done when section names (0020-ifccm FR-003).

changes.parseIssueBodyfunctionno test imports it
function parseIssueBody(body: string): IssueBody

A body read: its sections, and every checkbox item with the section it is under.

changes.requirementsInfunctionno test imports it
function requirementsIn(text: string): readonly string[]

The requirements a text names, NNNN-slug FR-nnn each once: 0020-ifccm FR-005, FR-007 to FR-009 gives FR-005, FR-007, FR-008 and FR-009.

changes.SECTIONSconstno test imports it
const SECTIONS: readonly ["Why", "Today", "Scope", "Done when"]

The sections of a capability's change request, in order (0020-ifccm FR-003).

changes.sectionOffunctionno test imports it
function sectionOf(body: IssueBody, name: "Done when" | "Scope" | "Today" | "Why"): Section | undefined

The section called name (case does not matter), or undefined.

changes.sectionProblemsfunctionno test imports it
function sectionProblems(body: IssueBody): readonly SectionProblem[]

What is wrong with the four sections a capability's change request must have, in order (0020-ifccm FR-003).

changes.untickedfunctionno test imports it
function unticked(body: IssueBody): readonly CheckItem[]

The items that are not ticked, in the order of the body.

changes.CheckItemtypeno test imports it
type CheckItem = { readonly text: string; readonly checked: boolean; readonly line: number; readonly section: string | undefined };

A checkbox item: its text, whether it is ticked, its line and the section it is under (none before the first heading).

changes.IssueBodytypeno test imports it
type IssueBody = { readonly sections: readonly Section[]; readonly items: readonly CheckItem[] };

A body as the check reads it.

changes.Sectiontypeno test imports it
type Section = { readonly name: string; readonly level: number; readonly line: number; readonly end: number; readonly text: string };

A section of a body: its heading as written, its level, its line, the line after its last (end) and the text under it.

changes.SectionNametypeno test imports it
type SectionName = (typeof SECTIONS)[number];

The name of one of those sections.

changes.SectionProblemtypeno test imports it
type SectionProblem =
  | { readonly kind: "missing"; readonly name: SectionName }
  | { readonly kind: "order"; readonly name: SectionName; readonly before: SectionName };

What is wrong with a capability's sections: one missing, or two out of order.

doneWhenItemsfunction
function doneWhenItems(body: IssueBody): readonly CheckItem[]

The items under Done when, in order.

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

doneWhenRequirementsfunction
function doneWhenRequirements(body: IssueBody): readonly string[]

The requirements the Done when section names (0020-ifccm FR-003).

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

parseIssueBodyfunction
function parseIssueBody(body: string): IssueBody

A body read: its sections, and every checkbox item with the section it is under.

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

requirementsInfunction
function requirementsIn(text: string): readonly string[]

The requirements a text names, NNNN-slug FR-nnn each once: 0020-ifccm FR-005, FR-007 to FR-009 gives FR-005, FR-007, FR-008 and FR-009.

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

SECTIONSconstno test imports it
const SECTIONS: readonly ["Why", "Today", "Scope", "Done when"]

The sections of a capability's change request, in order (0020-ifccm FR-003).

sectionOffunctionno test imports it
function sectionOf(body: IssueBody, name: "Done when" | "Scope" | "Today" | "Why"): Section | undefined

The section called name (case does not matter), or undefined.

sectionProblemsfunction
function sectionProblems(body: IssueBody): readonly SectionProblem[]

What is wrong with the four sections a capability's change request must have, in order (0020-ifccm FR-003).

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

untickedfunction
function unticked(body: IssueBody): readonly CheckItem[]

The items that are not ticked, in the order of the body.

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

CheckItemtypeno test imports it
type CheckItem = { readonly text: string; readonly checked: boolean; readonly line: number; readonly section: string | undefined };

A checkbox item: its text, whether it is ticked, its line and the section it is under (none before the first heading).

IssueBodytypeno test imports it
type IssueBody = { readonly sections: readonly Section[]; readonly items: readonly CheckItem[] };

A body as the check reads it.

Sectiontypeno test imports it
type Section = { readonly name: string; readonly level: number; readonly line: number; readonly end: number; readonly text: string };

A section of a body: its heading as written, its level, its line, the line after its last (end) and the text under it.

SectionNametypeno test imports it
type SectionName = (typeof SECTIONS)[number];

The name of one of those sections.

SectionProblemtypeno test imports it
type SectionProblem =
  | { readonly kind: "missing"; readonly name: SectionName }
  | { readonly kind: "order"; readonly name: SectionName; readonly before: SectionName };

What is wrong with a capability's sections: one missing, or two out of order.

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