Update documentation

This commit is contained in:
2024-12-27 16:37:31 +01:00
parent 339ab657b8
commit 9bc1b2ecd4
2 changed files with 94 additions and 39 deletions

View File

@@ -1,50 +1,34 @@
#!/bin/bash
set -euo pipefail
# Function to generate anchor from package path
generate_anchor() {
echo "$1" | tr '/' '-'
}
# Create documentation file
echo "# Lemma Package Documentation
echo "# Lemma Package Documentation"
echo ""
echo "Generated documentation for all packages in the Lemma project."
echo ""
echo "## Table of Contents"
Generated documentation for all packages in the Lemma project.
## Table of Contents
" > documentation.md
# Find all directories containing .go files (excluding test files)
# Sort them for consistent output
PACKAGES=$(find . -type f -name "*.go" ! -name "*_test.go" -exec dirname {} \; | sort -u | grep -v "/\.")
# Generate table of contents
for PKG in $PACKAGES; do
# Strip leading ./
PKG_PATH=${PKG#./}
# Skip if empty
[ -z "$PKG_PATH" ] && continue
ANCHOR=$(generate_anchor "$PKG_PATH")
echo "- [$PKG_PATH](#$ANCHOR)" >> documentation.md
echo "- [$PKG_PATH](#$ANCHOR)"
done
echo "" >> documentation.md
echo ""
# Generate documentation for each package
for PKG in $PACKAGES; do
# Strip leading ./
PKG_PATH=${PKG#./}
# Skip if empty
[ -z "$PKG_PATH" ] && continue
echo "## $PKG_PATH" >> documentation.md
echo "" >> documentation.md
echo '```go' >> documentation.md
go doc -all "./$PKG_PATH" >> documentation.md
echo '```' >> documentation.md
echo "" >> documentation.md
done
echo "Documentation generated in documentation.md"
echo "## $PKG_PATH"
echo ""
echo '```go'
go doc -all "./$PKG_PATH" | cat
echo '```'
echo ""
done