Skip to content

Commit caad0f9

Browse files
committed
Add autodocs script for automated documentation generation
This script facilitates automatic documentation updates for a collection of scripts using AI-powered markdown generation. It processes a predefined list of scripts, generates individual documentation files, and updates the main README.md using context and language model assistance.
1 parent 1a16363 commit caad0f9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

autodocs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# autodocs - Automatically update documentation for scripts
4+
# Updates individual doc files and README.md based on script content
5+
6+
# Get script directory (works even when called from other directories)
7+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
8+
9+
# Ensure all commands run from the script's directory
10+
cd "$SCRIPT_DIR"
11+
12+
# List of scripts to process
13+
SCRIPTS=("apply-md" "autocommit" "context" "git-context")
14+
15+
echo "Updating documentation files..."
16+
17+
# Process each script
18+
for script in "${SCRIPTS[@]}"; do
19+
if [ -f "$script" ]; then
20+
echo "Generating docs for $script..."
21+
22+
# Define the doc path
23+
DOC_PATH="docs/${script}.md"
24+
25+
# Create the command that will generate the updated documentation
26+
CMD="./context \"$script\" | llm -m openrouter/anthropic/claude-3.5-haiku \"Update the markdown documentation for this script.\" | ./apply-md --create-missing"
27+
28+
# Print and execute the command
29+
echo "$ $CMD"
30+
eval "$CMD"
31+
32+
echo "Updated $DOC_PATH"
33+
echo ""
34+
else
35+
echo "Warning: Script $script not found, skipping" >&2
36+
fi
37+
done
38+
39+
# Update README.md based on all doc files
40+
echo "Updating README.md..."
41+
42+
# Command to generate updated README.md content
43+
README_CMD="./context \"docs/*.md\" | llm -m openrouter/anthropic/claude-3.5-haiku \"Generate a comprehensive README.md for this collection of scripts based on their documentation.\" | ./apply-md"
44+
45+
# Print and execute the command
46+
echo "$ $README_CMD"
47+
eval "$README_CMD"
48+
49+
echo "Documentation update complete!"
50+
exit 0

0 commit comments

Comments
 (0)