command documentation
This commit is contained in:
parent
7968a7be3d
commit
09ade754f8
25
Makefile
25
Makefile
@ -1,4 +1,8 @@
|
|||||||
sources = $(shell find . -name "*.go" | grep -v iniparser.gen.go | grep -v docreflect.gen.go | grep -v docreflect_test.go)
|
sources = $(shell find . -name "*.go" | grep -v iniparser.gen.go | grep -v docreflect.gen.go | grep -v docreflect_test.go)
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
prefix ?= $(PREFIX)
|
||||||
|
date = $(shell git show -s --format=%cs HEAD)
|
||||||
|
version = $(date)-$(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
default: build
|
default: build
|
||||||
|
|
||||||
@ -6,7 +10,7 @@ lib: $(sources) iniparser.gen.go docreflect.gen.go
|
|||||||
go build
|
go build
|
||||||
go build ./tools
|
go build ./tools
|
||||||
|
|
||||||
build: lib .build/wand
|
build: lib .build/wand cmd/wand/readme.md
|
||||||
|
|
||||||
check: $(sources) build docreflect_test.go
|
check: $(sources) build docreflect_test.go
|
||||||
go test -count 1 ./...
|
go test -count 1 ./...
|
||||||
@ -46,11 +50,24 @@ docreflect_test.go: $(sources)
|
|||||||
.build/wand: $(sources) iniparser.gen.go docreflect.gen.go .build
|
.build/wand: $(sources) iniparser.gen.go docreflect.gen.go .build
|
||||||
go build \
|
go build \
|
||||||
-o .build/wand \
|
-o .build/wand \
|
||||||
-ldflags "-X main.version=$(git show -s --format=%cs HEAD)-$(shell git rev-parse --short HEAD)" \
|
-ldflags "-X main.version=$(version)" \
|
||||||
./cmd/wand
|
./cmd/wand
|
||||||
|
|
||||||
install: .build/wand
|
.build/wand.1: $(sources) iniparser.gen.go docreflect.gen.go .build
|
||||||
cp .build/wand ~/bin
|
go run script/man/man.go $(date) $(version) ./cmd/wand > .build/wand.1
|
||||||
|
|
||||||
|
cmd/wand/readme.md:
|
||||||
|
go run script/markdown/md.go 0 ./cmd/wand > cmd/wand/readme.md
|
||||||
|
|
||||||
|
$(prefix)/bin:
|
||||||
|
mkdir -p $(prefix)/bin
|
||||||
|
|
||||||
|
$(prefix)/share/man/man1:
|
||||||
|
mkdir -p $(prefix)/share/man/man1
|
||||||
|
|
||||||
|
install: .build/wand .build/wand.1 $(prefix)/bin $(prefix)/share/man/man1
|
||||||
|
cp .build/wand $(prefix)/bin
|
||||||
|
cp .build/wand.1 $(prefix)/share/man/man1
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean ./...
|
go clean ./...
|
||||||
|
|||||||
0
cmd/wand/readme.md
Normal file
0
cmd/wand/readme.md
Normal file
@ -2,10 +2,9 @@
|
|||||||
Generated with https://code.squareroundforest.org/arpio/docreflect
|
Generated with https://code.squareroundforest.org/arpio/docreflect
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package wand
|
package wand
|
||||||
|
|
||||||
import "code.squareroundforest.org/arpio/docreflect"
|
import "code.squareroundforest.org/arpio/docreflect"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
docreflect.Register("code.squareroundforest.org/arpio/wand/tools", "Package tools provides tools to work with the wand library. The functions in this package serve primarily as\nthe implementation of the wand executable command.\n")
|
docreflect.Register("code.squareroundforest.org/arpio/wand/tools", "Package tools provides tools to work with the wand library. The functions in this package serve primarily as\nthe implementation of the wand executable command.\n")
|
||||||
docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Docreflect", "Docreflect generates documentation from the go docs of a package to be included in the compiled binary and\naccessed by the automatic help and documentation generator.\n\nThe packageName parameter specifies the package name for the generated Go code.\n\nThe gopath arguments accept any number of package, package level symbol, or struct field paths. It is\nrecommended to use package paths unless special circumstances.\n\nfunc(out, packageName, gopaths)")
|
docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Docreflect", "Docreflect generates documentation from the go docs of a package to be included in the compiled binary and\naccessed by the automatic help and documentation generator.\n\nThe packageName parameter specifies the package name for the generated Go code.\n\nThe gopath arguments accept any number of package, package level symbol, or struct field paths. It is\nrecommended to use package paths unless special circumstances.\n\nfunc(out, packageName, gopaths)")
|
||||||
|
|||||||
@ -2,10 +2,9 @@
|
|||||||
Generated with https://code.squareroundforest.org/arpio/docreflect
|
Generated with https://code.squareroundforest.org/arpio/docreflect
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package wand
|
package wand
|
||||||
|
|
||||||
import "code.squareroundforest.org/arpio/docreflect"
|
import "code.squareroundforest.org/arpio/docreflect"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib", "")
|
docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib", "")
|
||||||
docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib.Bar", "\nfunc(out, a, b, c)")
|
docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib.Bar", "\nfunc(out, a, b, c)")
|
||||||
|
|||||||
18
script/man/man.go
Normal file
18
script/man/man.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.squareroundforest.org/arpio/wand/tools"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) < 4 {
|
||||||
|
log.Fatalln("expected release date, version and command dir")
|
||||||
|
}
|
||||||
|
|
||||||
|
options := tools.ManOptions{DateString: os.Args[1], Version: os.Args[2]}
|
||||||
|
if err := tools.Man(os.Stdout, options, os.Args[3]); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
24
script/markdown/md.go
Normal file
24
script/markdown/md.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.squareroundforest.org/arpio/wand/tools"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) < 3 {
|
||||||
|
log.Fatalln("default level and command dir are missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
level, err := strconv.ParseInt(os.Args[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
options := tools.MarkdownOptions{Level: int(level)}
|
||||||
|
if err := tools.Markdown(os.Stdout, options, os.Args[2]); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user