Living Documentation: link docs to code and check freshness when signatures change
Project description
Living Documentation
A tool that links documentation to code so it stays up to date. When function signatures, APIs, or arguments change, the system marks related documentation paragraphs as "possibly outdated" and suggests what to fix.
Goals
- Code ↔ doc linking: explicit mapping between code entities (functions, classes, APIs) and documentation fragments
- Freshness checking: after code changes — mark outdated sections and suggest updates
- Contextual view (planned): show the relevant doc fragment in the IDE when hovering over a function or method call
- Docs next to code: store documentation in the repository and view it as a site with navigation and search
Where to Start (recommendation)
Recommended order:
- Code ↔ documentation mapping format — without it, you can't unambiguously link a doc paragraph to a code entity. Define this first.
- Repository structure and stack — Python and TypeScript/JavaScript for MVP, shared architecture for future languages and IDE support.
- Prototype on one example — one module, one doc page, code parser, and a check that "the document is outdated after a code change."
In short: first the format and structure, then a minimal prototype.
Architecture Overview
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
│ Code parser │────▶│ Link graph │◀────│ Doc parser │
│ (AST / API) │ │ (code_id ↔ doc) │ │ (markdown + anchors)│
└────────┬────────┘ └────────┬──────────┘ └─────────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Change │ │ Report / site │
│ detector │────▶│ "outdated" + │
│ (diff / hash) │ │ suggestions │
└─────────────────┘ └──────────────────┘
- Code parser: extracts signatures (name, arguments, types) and unique identifiers (e.g.,
module.functionorpath.to.file:Class.method). Supports Python and TypeScript/JavaScript. - Doc parser: parses Markdown with explicit anchors (see
spec/code-doc-mapping.md), associating paragraphs/blocks withcode_id. - Link graph: stores (code_id, doc_fragment_id) pairs. When code changes (new signature/hash), related fragments are marked as "possibly outdated."
- Change detector: compares current code state (signatures/hashes) with the last saved state.
Extensibility: code and doc parsers are per-language plugins; the graph and report are shared.
Documentation Format
- Primary format: Markdown in the repository (e.g., a
docs/folder or next to modules). - Linking to code: anchors in Markdown (see
spec/code-doc-mapping.md), optionally plus annotations in code (docstring tags) that reference a fragment id. - Site: generate a static site (MkDocs, Docusaurus, or custom) from the same Markdown files; navigation and search on top of the generated site.
Supported Languages
- Python: functions, class methods (
module.path:nameormodule.path:Class.method) - TypeScript/JavaScript: functions, arrow functions, classes, methods (
.ts,.tsx,.js,.jsx). Excludes*.d.ts,*.test.*,*.spec.*,node_modules,dist,build.
MVP (First Iteration)
- Features:
- Parse modules (functions, methods, signatures) for Python and TypeScript/JavaScript
- Documentation page with anchors linking to code entities
- Check: when a signature changes in code, the related doc paragraph is marked as outdated
- Extensibility: abstractions for the code parser and anchor format to support more languages and IDE integration later.
Repository Structure
LiveDoc/
├── README.md # this file
├── spec/
│ └── code-doc-mapping.md # anchor format and code↔doc mapping
├── src/
│ └── livedoc/
│ ├── __init__.py
│ ├── core/ # link graph, change detector
│ ├── parsers/ # Python code parser, doc parser
│ └── report/ # "outdated" report, future site generation
├── tests/
├── examples/ # sample project (Python + TypeScript)
│ ├── sample_module/ # Python
│ ├── ts_sample/ # TypeScript
│ └── docs/
└── pyproject.toml
Quick Start (Add to Your Project)
-
Install:
pip install living-doc(orpip install -e .from this repo) -
Create docs in
docs/with anchors linking to code:<!-- livedoc: code_id = "mymodule.calc:add" --> ## add Adds two numbers.For TypeScript:
<!-- livedoc: code_id = "src.utils:add" -->(path.to.file:name or path.to.file:Class.method) -
First run (saves code signatures):
python -m livedoc --docs docs
-
CI: Add to your workflow:
- run: pip install living-doc && python -m livedoc --docs docs
-
Optional: Add
.livedoc.jsonin project root for defaults:{"docs": "docs", "ignore": ["build"], "format": "text"}
-
Optional: Add
.livedocignore(one pattern per line) to exclude paths:build scripts -
Optional: Pre-commit hook — add to
.pre-commit-config.yaml:- repo: local hooks: - id: livedoc name: livedoc entry: python -m livedoc language: system pass_filenames: false
Then:
pip install pre-commit && pre-commit install
Running the MVP (This Repo)
# Install (optional, for livedoc command)
pip install -e .
# Check links and freshness for the example (from repo root)
python -m livedoc examples
# First run saves code signatures to examples/.livedoc/code_signatures.json.
# After changing a function/method signature, the next run will show
# related doc fragments as "possibly outdated" with a diff of old vs new signature.
# To update signatures after editing docs: --update
# Pre-commit (this repo): pre-commit install && pre-commit run livedoc
# Options (CLI overrides .livedoc.json):
# --ignore PATTERN Exclude paths (can be repeated)
# --format json Machine-readable output for CI/scripts
# .livedoc.json Config: docs, ignore, format
# .livedocignore File with ignore patterns (one per line)
CI (GitHub Actions)
The workflow .github/workflows/livedoc.yml runs livedoc check on push and pull requests. The examples/.livedoc folder with signatures is committed so CI has a baseline. If code changes without updating docs or without --update, the job fails.
Publishing to PyPI
pip install build twine
python -m build
python -m twine upload dist/*
Requires a PyPI account and token. Use __token__ as username and your API token as password.
Next Steps
- Add parsers for other languages in
parsers/ - IDE integration: LSP or extension (show docs on hover)
- Generate and serve a documentation site with "outdated" highlights
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file living_doc-0.1.2.tar.gz.
File metadata
- Download URL: living_doc-0.1.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
641869c7c8cdea735c172cc363ae3aa0dc80d481145e7f0d8a23724a08d5dc8d
|
|
| MD5 |
3dd8a7d9b46ef7019aa918d4f090a78e
|
|
| BLAKE2b-256 |
3b2812fcba26bfb0945ad82fa366ad94f66f8030d16904d246962760f9d983a0
|
File details
Details for the file living_doc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: living_doc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b84f62cb1dbf086418ca253503dbd95593033c4ee507e0eacb3a1386a8ce6c2b
|
|
| MD5 |
cf70d42eea9b8b3142117e45018deaaa
|
|
| BLAKE2b-256 |
ea036c7b18f97161ddf41e89ac5addd667287ebc284cc97975426c94b8f72cfc
|