Skip to content

Diagnostics

Structured, source-located problems instead of silence.

When Blasdoc cannot do something, it says so — with a code, a message and a position in the source. It does not guess, and it does not fail silently.

Reading them

From a page:

ts
import { blasdocPageDiagnostics } from '@blasdoc/angular';
 
const problems = blasdocPageDiagnostics(page);

From <blasdoc-content>:

html
<blasdoc-content [source]="markdown" (diagnostics)="onProblems($event)" />

The shape

ts
interface BlasdocDiagnostic {
  readonly code: string;        // BLASDOC_*
  readonly severity: 'error' | 'warning';
  readonly message: string;
  readonly position?: BlasdocPosition;
}

The codes

CodeWhen
BLASDOC_UNKNOWN_COMPONENTa tag names a component that is not registered, or a loader returned nothing
BLASDOC_EXPRESSION_FAILEDan expression could not be parsed or evaluated
BLASDOC_TWO_WAY_WITHOUT_OUTPUT[(x)] on a component with no xChange output
BLASDOC_UNKNOWN_THEMEa fence or document selected an unregistered theme
BLASDOC_UNKNOWN_LANGUAGEa fence named a language Shiki does not have
BLASDOC_HIGHLIGHT_FAILEDhighlighting threw; the block renders unhighlighted
BLASDOC_HTML_NOT_ALLOWEDa tag or attribute the HTML policy removed

Late diagnostics

Highlighting and lazy components resolve after the render pass returns, so their problems arrive late. They are reported through the same channel — a diagnostics panel that reads once at render time will miss them, so read on change.

In practice

The best use of diagnostics is a test. This site asserts that every page reports none, which is what keeps its examples honest: a page that documented a feature Blasdoc lacks would fail the suite rather than quietly render nothing.

ts
for (const page of DOC_PAGES) {
  const view = await open(`/docs/${page.slug}`);
  expect(view.diagnostics()).toEqual([]);
}