Skip to content

Reference Doc Generator: Rich Content & Diagram Enhancements #25

Description

@darko-mijic

Summary

The reference doc generator (referenceDocConfigs) has a solid foundation with 4 content sources (conventions, diagrams, shapes, behaviors) but several gaps limit its usefulness for generating rich technical documentation. This issue tracks enhancements across three tiers of effort.

Context

The @libar-docs-arch-view annotation + DiagramScope filtering already enables scoped Mermaid diagrams. Shape extraction (@libar-docs-extract-shapes) pulls real TypeScript constructs from AST. Convention content pulls structured rules from Gherkin. But behavior rendering is shallow, diagram types are limited to flowcharts, and some extraction gaps exist.

Tier 1: Codec Enhancements (data exists in MasterDataset, rendering missing)

Deep behavior rendering

  • Render full scenario steps, DataTables, and DocStrings from pattern.scenarios in reference docs
  • Currently behaviorCategories only renders rule name + 120-char truncated description — essentially an index

Full rule descriptions in behavior content

  • Remove 120-character truncation on rule descriptions
  • Parse structured **Invariant:** / **Rationale:** content from behavior patterns (same as conventions do)

JSDoc prose alongside shapes

  • Render directive.description markdown alongside extracted shapes in reference docs
  • Currently shapes render source code but lose the narrative JSDoc context

archLayer filter in DiagramScope

  • Add archLayer to DiagramScope interface and collectScopePatterns()
  • Enable filtering diagrams by domain/application/infrastructure layer

New Mermaid diagram types

  • Sequence diagrams (sequenceDiagram) — valuable for event flow documentation
  • State machine diagrams (stateDiagram-v2) — FSM visualization
  • C4 diagrams (C4Context, C4Container) — architecture overview
  • Class diagrams (classDiagram) — could leverage shapeSources data
  • Currently all diagrams are flowcharts (graph TD/TB/LR)
  • Add diagramType field to DiagramScope

Edge labels on diagrams

  • Show event/command names on relationship arrows
  • Currently edges only distinguish type via arrow style

Custom node shapes/styles per archRole

  • Different Mermaid node shapes for different archRole values (e.g., saga vs projection vs command)

Tier 2: Extraction Enhancements (pipeline changes)

@param/@returns/@throws extraction

  • Currently dropped during JSDoc scanning in ast-parser.ts
  • Function shapes lack parameter documentation
  • Schema update needed: add params, returns, throws to ExtractedShape

Full property-level JSDoc

  • Currently truncated to first line only (extractJsDocText())
  • Multi-line property descriptions, markdown tables within property JSDoc discarded
  • Remove first-line truncation, preserve full property docs

Auto-shape discovery mode

  • Extract all exported types from a file without requiring explicit @libar-docs-extract-shapes tag
  • Could be opt-in via @libar-docs-extract-shapes * or a new tag
  • Reduces manual annotation burden

Convention content from TypeScript JSDoc

  • Pull structured **Invariant:**/**Rationale:** content from TypeScript JSDoc blocks
  • Currently convention extraction only works with Gherkin Rule: blocks
  • Would enable TypeScript files to self-document business rules

Tier 3: Config-Only (zero code, available today)

These require no code changes — just annotation and config work:

  • Add @libar-docs-arch-view to more source files for richer diagrams
  • Add @libar-docs-extract-shapes to key infrastructure files
  • Use diagramScopes (plural) for multiple views per reference doc
  • Combine all 4 content sources in single reference doc configs

Priority Recommendation

  1. Deep behavior rendering — highest ROI, unlocks full Gherkin content
  2. JSDoc prose alongside shapes — makes shape docs self-documenting
  3. @param/@returns extraction — completes function documentation story
  4. New diagram types — sequence diagrams especially for event flows
  5. Auto-shape discovery — removes manual annotation burden

Related

  • Pattern Relationship Model spec (specs/pattern-relationship-model.feature)
  • referenceDocConfigs in downstream delivery-process.config.js
  • Reference codec: src/renderable/codecs/reference.ts
  • Shape extractor: src/extractor/shape-extractor.ts
  • Diagram utils: src/renderable/codecs/diagram-utils.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions