Documentation
¶
Overview ¶
Package notice contains the core types and orchestration for the NOTICE generator: the on-disk schema, the Collector interface, and the helpers that ecosystem packages use to assemble entries.
Index ¶
Constants ¶
const HeaderComment = `# Generated by hack/cmd/notice. DO NOT EDIT.
# Run 'make notice' to regenerate. Source: go.mod + frontend/package.json.
`
HeaderComment is the YAML comment block prepended to the rendered NOTICE.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector interface {
// Name is a stable identifier used in the Entry.Ecosystem field and in
// error messages. Examples: "go", "npm".
Name() string
// Precheck verifies the host has what the collector needs (e.g. an
// installed `go` toolchain, a populated `node_modules`). The returned
// error message is shown verbatim to the user.
Precheck(root string) error
// Collect returns one Entry per direct dependency.
Collect(root string) ([]Entry, error)
}
Collector enumerates one ecosystem's direct dependencies and produces NOTICE entries. Implementations live under hack/cmd/notice/internal/<ecosystem>/.
Adding a new ecosystem is three steps:
- Create internal/<name>/ with a Collector implementation.
- Write hermetic tests using internal/testutil for fixtures.
- Append <name>.New() to the explicit collectors slice in main.go.
Collect MUST NOT sort its result; Build performs a global sort by Dependency across all collectors.
type Document ¶
type Document struct {
Notices []Entry `yaml:"notices"`
}
Document is the YAML root of the NOTICE file.
type Entry ¶
type Entry struct {
Dependency string `yaml:"dependency"`
Ecosystem string `yaml:"ecosystem"`
Copyright []string `yaml:"copyright"`
License []License `yaml:"license"`
}
Entry describes one direct dependency.
func AssembleEntry ¶
AssembleEntry builds a NOTICE entry by reading the LICENSE file in dir, classifying it, extracting copyright lines, and rendering one License per classified license name pointing at the canonical blob URL.
declaredLicense is an optional ecosystem-supplied SPDX identifier (e.g. from npm's package.json "license" field). When non-empty, its friendly form is prepended to the classifier output if the classifier did not already emit it - this is the npm-recommended source of truth for ambiguous license texts.
Ecosystems compute (repoBase, ref) however they need to and pass them in.