internal/readme: use go:generate rather than Make

Simplify the readme generation to just use go:generate, no longer
depending on Make or bash.

Subsequent CLs will generate more documentation in a similar manner.

For #442
This commit is contained in:
Rob Findley 2025-09-10 19:25:22 +00:00 • committed by Robert Findley
commit 872b437b2a
3 changed files with 12 additions and 47 deletions

View file

@ -1,19 +0,0 @@
# This makefile builds ../README.md from the files in this directory.
OUTFILE=../../README.md
$(OUTFILE): build README.src.md
go run golang.org/x/example/internal/cmd/weave@latest README.src.md > $(OUTFILE)
# Compile all the code used in the README.
build: $(wildcard */*.go)
go build -o /tmp/mcp-readme/ ./...
# Preview the README on GitHub.
# $HOME/markdown must be a github repo.
# Visit https://github.com/$HOME/markdown to see the result.
preview: $(OUTFILE)
cp $(OUTFILE) $$HOME/markdown/
(cd $$HOME/markdown/ && git commit -m . README.md && git push)
.PHONY: build preview

View file

@ -1,22 +0,0 @@
#!/bin/sh
# Build README.md from the files in this directory.
# Must be invoked from the mcp directory.
cd ../internal/readme
outfile=../../README.md
# Compile all the code used in the README.
go build -o /tmp/mcp-readme/ ./...
# Combine the code with the text in README.src.md.
# TODO: when at Go 1.24, use a tool directive for weave.
go run golang.org/x/example/internal/cmd/weave@latest README.src.md > $outfile
if [[ $1 = '-preview' ]]; then
# Preview the README on GitHub.
# $HOME/markdown must be a github repo.
# Visit https://github.com/$HOME/markdown to see the result.
cp $outfile $HOME/markdown/
(cd $HOME/markdown/ && git commit -m . README.md && git push)
fi

9
internal/readme/doc.go Normal file
View file

@ -0,0 +1,9 @@
// Copyright 2025 The Go MCP SDK Authors. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
//go:generate go run golang.org/x/example/internal/cmd/weave@latest -o ../../README.md ./README.src.md
// The readme package is used to generate README.md at the top-level of this
// repo. Regenerate the README with go generate.
package readme