mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Add script for generating single file documentation
This commit is contained in:
50
server/gendocs.sh
Executable file
50
server/gendocs.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Function to generate anchor from package path
|
||||
generate_anchor() {
|
||||
echo "$1" | tr '/' '-'
|
||||
}
|
||||
|
||||
# Create documentation file
|
||||
echo "# NovaMD Package Documentation
|
||||
|
||||
Generated documentation for all packages in the NovaMD 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
|
||||
done
|
||||
|
||||
echo "" >> documentation.md
|
||||
|
||||
# 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"
|
||||
Reference in New Issue
Block a user