Problem
Documentation that lists values from code (enum members, constants, configuration keys) goes stale when the code changes. Keeping markdown tables in sync with source files is manual and error-prone.
Proposed solution
A directive that extracts structured data from source files using tree-sitter and renders it as a markdown table (or list) at serve time.
Example
Given a Rust enum:
/// HTTP status codes used by the API.
pub enum StatusCode {
/// Request succeeded
Ok = 200,
/// Resource not found
NotFound = 404,
/// Internal server error
InternalError = 500,
}
A directive in markdown:
```sourcetable
file: ../src/status.rs
query: enum_variant
columns:
- name: Code
field: value
- name: Name
field: name
- name: Description
field: comment
```
Would render:
| Code |
Name |
Description |
| 200 |
Ok |
Request succeeded |
| 404 |
NotFound |
Resource not found |
| 500 |
InternalError |
Internal server error |
Why tree-sitter
- Language-agnostic — works with Rust, Python, Go, C#, TypeScript, etc.
- Parses real syntax, not fragile regex
- Mature grammars for most languages
- Fits rw's "no build step" philosophy — parse on demand at serve time
Use cases
- Enum reference tables (status codes, error codes, feature flags)
- Configuration key inventories from constants
- CLI flag/subcommand lists extracted from struct definitions
Problem
Documentation that lists values from code (enum members, constants, configuration keys) goes stale when the code changes. Keeping markdown tables in sync with source files is manual and error-prone.
Proposed solution
A directive that extracts structured data from source files using tree-sitter and renders it as a markdown table (or list) at serve time.
Example
Given a Rust enum:
A directive in markdown:
Would render:
Why tree-sitter
Use cases