We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Example of anti-decaying documentation
2024-12-06 ・ documentation, readme, typescript
In a previous blog post1, I wrote about an idea to avoid documentation decay, like links or installation instructions falling out-of-date. I just had a chance to try it out, on a new project23.
The README is generated from a Jinja2 template. So far, it's the tools that are pulled from the actual model context server. Here's the template for that:
## Tools
{% for tool in tools %}
### `{{ tool.name }}`
{{ tool.description }}
{% endfor %}
The script imports the TOOLS
, and then passes it to the template rendering function.
..
import { TOOLS } from '../src/tools.js';
..
// Define template variables
const templateVars = {
tools: TOOLS.map(tool => ({
name: tool.name,
description: tool.description,
params: Object.keys(tool.inputSchema.properties || {})
}))
};
// Render the template
const output = env.renderString(template, templateVars);
...
Now, it's effectively impossible to be out-of-date or incorrect. As with any generated code, there's the annoyance of having to commit the code, but that is something that's otherwise solved.