pkg: reuse pkg/gen to generate package godocs
Instead of sprinkling copies of a tiny gen.go program to do so,
reuse pkg/gen which already knows how to generate for each package.
Each package has a different header, so we use doc.txt files in each.
Note that pkg/gen/packages.txt did not include the tool package itself.
We want to include it now to generate its godoc like the others,
but we don't want to start registering its package as it's not possible
to import it from CUE code today.
We might want to change that in the future, but for now, teach the
generator to skip registering the package to not change that detail.
Beyond the deduplication of code, this is also slightly faster,
as we have fewer go:generate programs to run:
$ time go generate ./...
real 0m10.926s
user 0m42.121s
sys 0m6.126s
$ git switch pkg-tool-generate
$ time go generate ./...
real 0m5.909s
user 0m14.437s
sys 0m3.311s
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I3a0ae6dbbe0766731655c4202b8c6059d1834a4e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/541844
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>