Skip to content

feat: export Backstage TechDocs projects (#145) - #155

Merged
anhnh2002 merged 1 commit into
mainfrom
feat/techdocs-output
Nov 5, 2026
Merged

anhnh2002 merged 1 commit into
mainfrom
feat/techdocs-output

Conversation

@anhnh2002

Copy link
Copy Markdown
Collaborator

Closes #145.

What

Adds Backstage TechDocs output, built on the generator proposed in the issue.

  • codewiki generate --techdocs [--techdocs-dir DIR] (default ./techdocs) exports right after generation, like --github-pages.
  • codewiki techdocs [DOCS_DIR] [OUT_DIR] exports existing docs without any LLM calls. Re-run it after --update.

The output is an MkDocs project that techdocs-cli generate builds as is:

techdocs/
├── mkdocs.yml   # techdocs-core, nav from the module tree, mermaid superfences
└── docs/
    ├── index.md # overview.md
    └── ...      # module pages in the same layout, plus images

Each page gets front matter (title/description), a provenance banner (commit, date, model) and a collapsible "Documented components" list linked to the source at the documented commit. The repository URL comes from git origin: SSH remotes become https and credentials are dropped. GitHub, GitLab and bitbucket.org links are built automatically, and --source-url-template covers other hosts. JSON files and temp/ are not published, and the source docs are never modified.

Changes from the script in the issue

  • Re-runs: _prepare_out_docs was passed out/docs and appended docs again. Stale pages were never cleared and the marker file landed in docs/docs/.
  • Nav check: whether a page was already in the nav was checked by splitting the YAML dump. It now walks the nav itself.
  • Descriptions: a first paragraph starting with **bold** was skipped as a list item, and fenced code wasn't tracked.
  • Titles: pages outside the module tree get their H1 as the nav title.
  • Pre-flight check: generate --techdocs validates the output folder before the LLM run.
  • Failures: a failed export after generation prints a warning and the retry command instead of failing the run.

Safety

  • Only a docs/ folder created by an earlier export (it carries a marker file) is ever replaced.
  • The output may not overlap the CodeWiki docs directory.

Docs

  • New guides/backstage-techdocs.md covering the catalog annotation, building with techdocs-cli, and the Mermaid addon Backstage needs to render diagrams.
  • Updated the README, guides/cli-reference.md and the CHANGELOG.

Testing

  • tests/test_techdocs.py: 15 tests covering both layouts, link rewriting, the nav, banner and components, re-runs, the refusals, URL normalisation and the CLI.
  • All tracked tests pass, and so does ruff.
  • Exported this repo's own docs/ (35 pages) and built it with mkdocs build --strict using mkdocs-techdocs-core 1.7.1. It builds cleanly, and Mermaid, admonitions and the details blocks render.

Add `codewiki generate --techdocs [--techdocs-dir DIR]` and a standalone
`codewiki techdocs [DOCS_DIR] [OUT_DIR]` (no LLM calls) that turn CodeWiki
output into an MkDocs project `techdocs-cli generate` builds as is:
mkdocs.yml (techdocs-core, nav from the module tree, mermaid superfences)
plus docs/ with the overview as index.md.

Pages get front matter, a provenance banner and a collapsible list of the
documented components linked to the source at the documented commit. JSON
files and temp/ are not published, the source docs are never modified, and
only a docs/ folder created by an earlier export is replaced.

Based on the generator proposed in the issue, with the double docs/docs
folder on re-runs and the nav membership check fixed.
@anhnh2002
anhnh2002 merged commit a1b9f4a into main Nov 5, 2026
3 checks passed
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.

techdocs output

1 participant