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
5 changed files with 12 additions and 47 deletions

View file

@ -19,14 +19,13 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check README is up-to-date - name: Check README is up-to-date
run: | run: |
cd internal/readme go generate ./internal/readme
make
if [ -n "$(git status --porcelain)" ]; then if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: README.md is not up-to-date!" echo "ERROR: README.md is not up-to-date!"
echo "" echo ""
echo "The README.md file differs from what would be generated by running 'make' in internal/readme/." echo "The README.md file differs from what would be generated by `go generate ./internal/readme`."
echo "Please update internal/readme/README.src.md instead of README.md directly," echo "Please update internal/readme/README.src.md instead of README.md directly,"
echo "then run 'make' in the internal/readme/ directory to regenerate README.md." echo "then run `go generate ./internal/readme` to regenerate README.md."
echo "" echo ""
echo "Changes:" echo "Changes:"
git status --porcelain git status --porcelain

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

View file

@ -2,8 +2,6 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:generate ../internal/readme/build.sh
// The mcp package provides an SDK for writing model context protocol clients // The mcp package provides an SDK for writing model context protocol clients
// and servers. // and servers.
// //