doc: generate README with docgen tool (#251)

Introduces a docgen tool for templated documentation generation, and uses it
to generate the README.

At the moment this change makes minimal difference to generating it with
embedmd. The difference is that docgen opens up the possibility to generate
documentation with more elaborate templating. The specific use case currently
in mind is including an adopters list that's kept in sync with the third-party
packages file.

Updates #101
This commit is contained in:
Michael McLoughlin
2022-04-17 19:41:29 -07:00
committed by GitHub
parent 3066c12247
commit 9fee3b0ead
4 changed files with 272 additions and 6 deletions

View File

@@ -34,7 +34,6 @@ $ go get -u github.com/mmcloughlin/avo
`avo` assembly generators are pure Go programs. Here's a function that adds two `uint64` values:
[embedmd]:# (examples/add/asm.go)
```go
//go:build ignore
// +build ignore
@@ -57,14 +56,12 @@ func main() {
`go run` this code to see the assembly output. To integrate this into the rest of your Go package we recommend a [`go:generate`](https://blog.golang.org/generate) line to produce the assembly and the corresponding Go stub file.
[embedmd]:# (examples/add/add_test.go go /.*go:generate.*/)
```go
//go:generate go run asm.go -out add.s -stubs stub.go
```
After running `go generate` the [`add.s`](examples/add/add.s) file will contain the Go assembly.
[embedmd]:# (examples/add/add.s)
```s
// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.
@@ -81,7 +78,6 @@ TEXT ·Add(SB), NOSPLIT, $0-24
The same call will produce the stub file [`stub.go`](examples/add/stub.go) which will enable the function to be called from your Go code.
[embedmd]:# (examples/add/stub.go)
```go
// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.
@@ -101,7 +97,6 @@ See [`examples`](examples) for the full suite of examples.
Sum a slice of `uint64`s:
[embedmd]:# (examples/sum/asm.go /func main/ /^}/)
```go
func main() {
TEXT("Sum", NOSPLIT, "func(xs []uint64) uint64")
@@ -136,7 +131,6 @@ func main() {
The result from this code generator is:
[embedmd]:# (examples/sum/sum.s)
```s
// Code generated by command: go run asm.go -out sum.s -stubs stub.go. DO NOT EDIT.