commentstart

package
v0.0.0-...-bf59aaa Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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.

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{inspect.Analyzer, extractjsontags.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

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