mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/doc: merge with cmd/go/internal/doc
Now that cmd/doc has been removed, cmd/go/internal/doc is the only user of the cmd/internal/doc code. Merge cmd/internal/doc into cmd/go/internal/doc. For #74667 Change-Id: I16bbe7b1f418b54ee411c8d6e6609c0973e40b3e Reviewed-on: https://go-review.googlesource.com/c/go/+/689836 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
da8b50c830
commit
bd446662dd
13 changed files with 22 additions and 19 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !cmd_go_bootstrap
|
||||||
|
|
||||||
package doc
|
package doc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -8,9 +8,12 @@
|
||||||
package doc
|
package doc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/go/internal/base"
|
|
||||||
"cmd/internal/doc"
|
|
||||||
"context"
|
"context"
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"cmd/go/internal/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CmdDoc = &base.Command{
|
var CmdDoc = &base.Command{
|
||||||
|
|
@ -136,5 +139,12 @@ Flags:
|
||||||
}
|
}
|
||||||
|
|
||||||
func runDoc(ctx context.Context, cmd *base.Command, args []string) {
|
func runDoc(ctx context.Context, cmd *base.Command, args []string) {
|
||||||
doc.Main(args)
|
log.SetFlags(0)
|
||||||
|
log.SetPrefix("doc: ")
|
||||||
|
dirsInit()
|
||||||
|
var flagSet flag.FlagSet
|
||||||
|
err := do(os.Stdout, &flagSet, args)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
|
||||||
buildCtx.GOROOT = testenv.GOROOT(nil)
|
buildCtx.GOROOT = testenv.GOROOT(nil)
|
||||||
build.Default.GOROOT = testenv.GOROOT(nil)
|
build.Default.GOROOT = testenv.GOROOT(nil)
|
||||||
|
|
||||||
// Add $GOROOT/src/cmd/doc/testdata explicitly so we can access its contents in the test.
|
// Add $GOROOT/src/cmd/go/internal/doc/testdata explicitly so we can access its contents in the test.
|
||||||
// Normally testdata directories are ignored, but sending it to dirs.scan directly is
|
// Normally testdata directories are ignored, but sending it to dirs.scan directly is
|
||||||
// a hack that works around the check.
|
// a hack that works around the check.
|
||||||
testdataDir, err := filepath.Abs("testdata")
|
testdataDir, err := filepath.Abs("testdata")
|
||||||
|
|
@ -90,7 +90,7 @@ type test struct {
|
||||||
no []string // Regular expressions that should not match.
|
no []string // Regular expressions that should not match.
|
||||||
}
|
}
|
||||||
|
|
||||||
const p = "cmd/internal/doc/testdata"
|
const p = "cmd/go/internal/doc/testdata"
|
||||||
|
|
||||||
var tests = []test{
|
var tests = []test{
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
|
|
@ -105,7 +105,7 @@ var tests = []test{
|
||||||
{
|
{
|
||||||
"package clause",
|
"package clause",
|
||||||
[]string{p},
|
[]string{p},
|
||||||
[]string{`package pkg.*cmd/internal/doc/testdata`},
|
[]string{`package pkg.*cmd/go/internal/doc/testdata`},
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package doc provides the implementation of the "go doc" subcommand and cmd/doc.
|
//go:build !cmd_go_bootstrap
|
||||||
|
|
||||||
package doc
|
package doc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -53,18 +54,6 @@ func usage(flagSet *flag.FlagSet) {
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main is the entry point, invoked both by go doc and cmd/doc.
|
|
||||||
func Main(args []string) {
|
|
||||||
log.SetFlags(0)
|
|
||||||
log.SetPrefix("doc: ")
|
|
||||||
dirsInit()
|
|
||||||
var flagSet flag.FlagSet
|
|
||||||
err := do(os.Stdout, &flagSet, args)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// do is the workhorse, broken out of main to make testing easier.
|
// do is the workhorse, broken out of main to make testing easier.
|
||||||
func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
|
func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
|
||||||
flagSet.Usage = func() { usage(flagSet) }
|
flagSet.Usage = func() { usage(flagSet) }
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !cmd_go_bootstrap
|
||||||
|
|
||||||
package doc
|
package doc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
Loading…
Add table
Add a link
Reference in a new issue