Skip to content

feat: Add an esdm documentation command that renders the model as a Markdown tree.#21

Draft
goloroden wants to merge 2 commits into
mainfrom
documentation-command
Draft

feat: Add an esdm documentation command that renders the model as a Markdown tree.#21
goloroden wants to merge 2 commits into
mainfrom
documentation-command

Conversation

@goloroden

Copy link
Copy Markdown
Member

What

Adds esdm documentation, a command that renders a resolved ESDM model as a Markdown directory tree written to --output.

docs/
  README.md
  library/
    README.md
    cataloging/
      README.md
      book/
        README.md          # esdm:library/cataloging/book
        acquire.md          # esdm:library/cataloging/book/acquire
        acquired.md         # esdm:library/cataloging/book/acquired
      books.md
      list-books.md

Each element becomes one page at its containment path, so the tree mirrors the reference notation (#8): the page path is exactly the reference path, and supplying a base URL turns a reference into a link into the tree. A container element (Domain, Bounded Context, Aggregate, ...) is a directory with a README.md index; a leaf (Command, Event, ...) is <name>.md.

Each page renders the detail the model records for its kind, aligned with esdm view --with-details (identity, payload/state/schema fields, invariants, constraints, projections, ubiquitous language, ...), and links to the elements it names (publishes, handles, emits, a query's read model, a context mapping's endpoints, ...) with relative links. A link to an element outside the (possibly narrowed) output falls back to its reference, so no link is ever broken.

Why

esdm view is a transient terminal summary and esdm glossary is a single document; neither writes a browsable, publishable view of the whole domain. This command does, and it shares one addressing scheme with the reference notation (#8) rather than inventing a parallel one.

Key decisions (signed off beforehand)

  • Command name esdm documentation; input -d / --directory (default .); optional [path] narrows to a subtree, keeping full containment paths.
  • Output -o / --output, required, no default (a whole tree is never written by accident).
  • Index page README.md (GitHub renders the folder landing natively).
  • Existing target refused when non-empty; --force clears it first, then writes, so the tree mirrors the model with no orphaned pages.
  • No diagrams in this first cut; neutral Markdown only (no mkdocs.yml, no theming).
  • Page content aligned with esdm view --with-details; H1 is the element's bare name; a reference line on every page; children grouped by kind.

Notes

Closes #5

🤖 Generated with Claude Code

https://claude.ai/code/session_01T9ZRRMdA7iKk6in8u12rK6

goloroden and others added 2 commits July 12, 2026 15:18
…arkdown tree.

Add `esdm documentation`, which writes the resolved model as a Markdown
directory tree to --output. Each element becomes a page at its
containment path, so the tree mirrors the reference notation (#8): the
element esdm:library/cataloging/book/acquired lives at
library/cataloging/book/acquired.md, and supplying a base URL turns a
reference into a link into the tree. A container element is written as
a directory with a README.md index; a leaf becomes <name>.md.

The command mirrors view and glossary: -d/--directory to read (default
the current directory) and an optional [path] to narrow to a subtree,
keeping full paths so pages still line up with their references. It
refuses to write into a non-empty directory unless --force clears it
first, so the output always mirrors the model with no orphaned pages.

This first slice renders the structure: each page's name, reference,
description, and an index of its children grouped by kind. The
kind-specific detail sections, the cross-links between related
elements, and the documentation page for the command follow next.

The Go package is named docgen rather than documentation because the
toolchain excludes every file in a package literally named
`documentation` from the build; the CLI command is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9ZRRMdA7iKk6in8u12rK6
…tation.

Flesh out each page with the detail the model records for its kind,
aligned with `esdm view --with-details`: an aggregate's identity and
state fields, a command's payload and published events, a read model's
projections and paradigm, invariants and constraints, a bounded
context's ubiquitous language, and so on. Wherever one element names
another - publishes, handles, emits, projections, a query's read
model, a context mapping's endpoints - the page links to it with a
relative link, resolved through an index of the emitted pages so a
link is never broken; a target outside the (possibly narrowed) output
falls back to the element's reference.

The ubiquitous-language rendering reuses the glossary command's term
extraction, now exported as CollectTerms, rather than duplicating it.

Document the command: a getting-started walkthrough and a CLI reference
entry, both following the existing command pages.

Also tighten naming for readability: containment paths are `segments`
rather than `segs`, references are spelled out rather than `ref`, and
a shadowed local is renamed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9ZRRMdA7iKk6in8u12rK6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an esdm documentation command that writes the domain as a Markdown directory tree

1 participant