parser

package
v0.0.0-...-055d146 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package parser contain the parsing code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeField

type KubeField struct {
	// The field name (in the JSON representation of this object)
	Name string

	// The field type
	Type TypeInfo

	// The normalized documentation
	Doc string

	// Mandatory flag
	Mandatory bool
}

KubeField is a struct with all the types we need to generate docs

type KubeStructure

type KubeStructure struct {
	// The structure name
	Name string

	// The normalized documentation
	Doc string

	// The structure fields
	Fields []KubeField
}

KubeStructure represent a structure that we need to document

type KubeTypes

type KubeTypes []KubeStructure

KubeTypes is an array to represent all available types in a parsed file. [0] is for the type itself

func GetKubeTypes

func GetKubeTypes(filePaths []string) (KubeTypes, error)

GetKubeTypes return the k8s types into a slice

type TypeInfo

type TypeInfo struct {
	// The type name (i.e. `[]Pod`)
	Name string

	// The base type name (i.e. `Pod`)
	BaseType string

	// The type-constructor who generated the type (i.e. `[]`)
	Constructor string

	// True if the type is internal to this package and false otherwise
	Internal bool
}

TypeInfo is a struct representing a type with a given name and it's base type name. I.e. a type named `[]Pod` has `Pod` as a base type. Atomic types have `Name == BaseName`.

We are adopting a simplification here: we consider only type constructors with 1 parameter. The only multiple-arity type constructor we have is `map[T1]T2` and, since kubernetes resources must be JSON-serializable, T1 == string. Given that, T1 is not interesting and we are only using T2 as base type.

Jump to

Keyboard shortcuts

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