Skip to content

Commit 4df44bc

Browse files
committed
feat: add comprehensive documentation generation system
- Add multiple documentation targets in Makefile for flexible doc access - Implement doc-generate to create static API documentation files - Add doc-serve-static for HTTP serving of generated documentation - Fix doc target to properly iterate through package directories - Update .gitignore to exclude generated documentation artifacts - Provide both interactive web docs and static file serving options
1 parent 65457bf commit 4df44bc

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ coverage.html
3636
go.work
3737
go.work.sum
3838

39+
# Documentation artifacts
40+
docs/api/
41+
3942
# YAP specific
4043
/yap
4144
examples/yap/pkg

Makefile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GOLINT=golangci-lint
2222
LDFLAGS=-ldflags="-s -w -X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME} -X main.Commit=${COMMIT}"
2323
BUILD_FLAGS=-trimpath $(LDFLAGS)
2424

25-
.PHONY: all build clean test deps fmt lint help install run dev doc doc-serve doc-package doc-deps
25+
.PHONY: all build clean test deps fmt lint help install run dev doc doc-serve doc-package doc-deps doc-generate doc-serve-static
2626

2727
# Default target
2828
all: clean deps fmt lint test build
@@ -177,7 +177,11 @@ example: build
177177
# Documentation
178178
doc:
179179
@echo "Viewing documentation for all packages..."
180-
@$(GOCMD) doc -all ./...
180+
@for pkg in $$(find ./pkg -name "*.go" -exec dirname {} \; | sort -u); do \
181+
echo "=== $$pkg ==="; \
182+
$(GOCMD) doc $$pkg || true; \
183+
echo; \
184+
done
181185

182186
doc-serve:
183187
@echo "Starting documentation server on http://localhost:8080..."
@@ -205,6 +209,25 @@ doc-deps:
205209
@$(GOCMD) install golang.org/x/pkgsite/cmd/pkgsite@latest
206210
@echo "Documentation tools installed"
207211

212+
# Generate static documentation files
213+
doc-generate:
214+
@echo "Generating static documentation files..."
215+
@mkdir -p docs/api
216+
@for pkg in $$(find ./pkg -name "*.go" -exec dirname {} \; | sort -u); do \
217+
pkg_name=$$(basename $$pkg); \
218+
echo "Generating docs for $$pkg_name..."; \
219+
$(GOCMD) doc -all $$pkg > docs/api/$$pkg_name.txt 2>/dev/null || true; \
220+
done
221+
@echo "Documentation files generated in docs/api/"
222+
223+
# Serve static documentation files
224+
doc-serve-static:
225+
@echo "Generating documentation files..."
226+
@$(MAKE) doc-generate
227+
@echo "Starting HTTP server for static docs on http://localhost:8081..."
228+
@echo "Navigate to http://localhost:8081/api/ to browse documentation files"
229+
@cd docs && python3 -m http.server 8081 2>/dev/null || python -m SimpleHTTPServer 8081
230+
208231
# Help
209232
help:
210233
@echo "Available targets:"
@@ -231,4 +254,6 @@ help:
231254
@echo " doc-serve - Start documentation server on localhost:8080"
232255
@echo " doc-package - View specific package docs (use PKG=<path>)"
233256
@echo " doc-deps - Install documentation tools"
257+
@echo " doc-generate - Generate static documentation files in docs/api/"
258+
@echo " doc-serve-static - Serve static documentation files on localhost:8081"
234259
@echo " help - Show this help"

0 commit comments

Comments
 (0)