-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathautodocs
More file actions
executable file
·46 lines (33 loc) · 1.55 KB
/
autodocs
File metadata and controls
executable file
·46 lines (33 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# autodocs - Automatically update documentation for scripts
# Updates individual doc files and README.md based on script content
set -ex
# Get script directory (works even when called from other directories)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
MODEL=openrouter/anthropic/claude-3.7-sonnet
# Ensure all commands run from the script's directory
cd "$SCRIPT_DIR"
# List of scripts to process
SCRIPTS=(apply-md" "context" "git-context")
echo "Updating documentation files..."
# Process each script
for script in "${SCRIPTS[@]}"; do
if [ -f "$script" ]; then
echo "Generating docs for $script..."
# Define the doc path
DOC_PATH="docs/${script}.md"
./context "$DOC_PATH" "$script" --no-prompt --no-ls-files > tmp-context.md
cat tmp-context.md | llm -m "$MODEL" -s "Fix $DOC_PATH to match script. Output it verbatim and nothing else. DO NOT MODIFY ANYTHING ELSE. Do not wrap into \`\`\` code block." | tee "$DOC_PATH"
echo "Updated $DOC_PATH"
echo ""
else
echo "Warning: Script $script not found, skipping" >&2
fi
done
# Update README.md based on all doc files
echo "Updating README.md..."
./context README.md "docs/*.md" --no-ls-files > tmp-context.md
cat tmp-context.md | llm -m "$MODEL" "Fix README.md to match individual scripts documentation. Output whole file verbatim and nothing else. DO NOT MODIFY ANYTHING ELSE. Do not wrap into \`\`\` code block." | tee README.md
echo "Documentation update complete!"
rm tmp-context.md
exit 0