MCPcopy Index your code
hub / github.com/tailscale/tailscale / PackageDoc

Function PackageDoc

tempfork/pkgdoc/pkgdoc.go:212–234  ·  view source on GitHub ↗

PackageDoc generates Markdown documentation for the package in the given directory. importPath is the full Go import path of that package (e.g. "tailscale.com/tsnet"); it's used to render [Symbol] doc links to the right pkg.go.dev URL. If importPath is empty, build.ImportDir's guess is used (typical

(dir, importPath string)

Source from the content-addressed store, hash-verified

210// right pkg.go.dev URL. If importPath is empty, build.ImportDir's guess
211// is used (typically "." for module-based repos).
212func PackageDoc(dir, importPath string) ([]byte, error) {
213 var buf bytes.Buffer
214 var writer io.Writer = &buf
215
216 buildPackage, err := build.ImportDir(dir, build.ImportComment)
217 if err != nil {
218 var noGoError *build.NoGoError
219 if errors.As(err, &noGoError) {
220 return nil, nil
221 }
222 return nil, err
223 }
224 if importPath != "" {
225 buildPackage.ImportPath = importPath
226 }
227 userPath := dir
228
229 pkg := parsePackage(writer, buildPackage, userPath)
230 pkg.packageDoc()
231 pkg.flush()
232
233 return buf.Bytes(), nil
234}

Callers 1

genGoDocFunction · 0.92

Calls 5

parsePackageFunction · 0.85
packageDocMethod · 0.80
BytesMethod · 0.80
AsMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…