IF Commons GitHub

extensions/docs/declarations

The documented declarations of a script (commons lang-sql 0004-sql-docs FR-002, FR-006): each table with its columns and named constraints, view, index, common table expression and column added by ALTER TABLE, and every other statement, with the documentation that its attached comments make.

const decls = documentScript(parse("-- The people.\nCREATE TABLE person (\n  id INT -- the key\n)"));
decls[0]?.doc?.summary; // "The people."
decls[0]?.members[0]?.doc?.summary; // "the key"

Spec: 0004-sql-docs FR-002, FR-006

Source: commons/lang-sql/src/extensions/docs/declarations.ts

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

Declarationinterface
interface Declaration

A documented part of a script.

MemberTypeWhat it is
kindDeclarationKind
namestringIts name as written, a qualified name's parts joined by a dot; the statement's kind for a statement that declares nothing.
nodeNode
docDoc | undefinedIts documentation, or none where no comment is attached as the specification says.
commentsreadonly Comment[]The comments the documentation is read from.
membersreadonly Declaration[]What it holds: a table's columns and constraints, a statement's common table expressions and added columns.

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

DeclarationKindtypeno test imports it
type DeclarationKind = "table" | "column" | "constraint" | "view" | "index" | "cte" | "statement";

What a declaration declares.

documentScriptfunction
function documentScript(p: Parsed, options?: DocOptions): readonly Declaration[]

The documented declarations of a parse, in the order of the text.

ParameterWhat it is
pwhat parse gave
optionsthe dialect for the examples, and readers for a project's tags

Returns: a declaration for each statement, with its members

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

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