commentstart

package
v0.0.0-...-502783c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

commentstart is a simple analysis tool that checks if the first line of a comment is the same as the json tag.

By convention in Go, comments typically start with the name of the item being described. In the case of field names, this would mean for a field Foo, the comment should look like:

// Foo is a field that does something.
Foo string `json:"foo"`

However, in Kubernetes API types, the json tag is often used to generate documentation. In this case, the comment should start with the json tag, like so:

// foo is a field that does something.
Foo string `json:"foo"`

This ensures that for any generated documentation, the documentation refers to the serialized field name. We expect most readers of Kubernetes API documentation will be more familiar with the serialized field names than the Go field names.

Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     name,
	Doc:      "Check that all struct fields in an API have a godoc, and that the godoc starts with the serialised field name",
	Run:      run,
	Requires: []*analysis.Analyzer{inspector.Analyzer},
}

Analyzer is the analyzer for the commentstart package. It checks that all struct fields in an API have a godoc, and that the godoc starts with the serialised field name.

Functions

func Initializer

func Initializer() initializer.AnalyzerInitializer

Initializer returns the AnalyzerInitializer for this Analyzer so that it can be added to the registry.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL