generator

package
v0.4.78 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(sourcePath string, writer io.Writer, config GenerateConfig) error

Generate receives a string sourcePath, an io.Writer writer, and a GenerateConfig config. It will extract all the directives definitions from the .c and .cpp files in sourcePath and its subdirectories, then output the corresponding directive masks map and matchFunc via writer.

Types

type Filters added in v0.4.59

type Filters map[string]struct{}

func (*Filters) UnmarshalJSON added in v0.4.59

func (fs *Filters) UnmarshalJSON(data []byte) error

type GenerateConfig added in v0.4.56

type GenerateConfig struct {
	// Filter is a map used to exclude directives from generator.
	// The key of it is the directive names.
	Filter Filters `json:"filter"`

	// Override is a map used to override the masks from source code of directives.
	// The key of it is the directive name. The value is the masks we want.
	// If a directive exists in Override, generator won't consider its definition
	// in source code.
	Override map[string][]Mask `json:"override"`

	// DirectiveMapName is the name assigned to the variable containing the directives
	// discovered by generator. The variable name generally starts with a
	// lowercase to avoid export. Users will use the generated function named by
	// MatchFuncName to validate the module directives in nginx configurations.
	// It should not be empty.
	DirectiveMapName string `json:"directiveMapName"`

	// MatchFuncName is the name assigned to the matchFunc generated by the generator.
	// It should generally start with a uppercase to export.
	// Users will use the generated function named by MatchFuncName
	// to validate the module directives in nginx configurations.
	// It should not be empty.
	MatchFuncName string `json:"matchFuncName"`

	// MatchFuncComment is the comment appears above the generated MatchFunc.
	// It may contain some information like what modules are included
	// in the generated MatchFunc. Generally it should start with MatchFuncName.
	// If it is empty, no comments will appear above the generated MatchFunc.
	MatchFuncComment string `json:"matchFuncComment"`
}

type Mask added in v0.4.50

type Mask []string

A Mask is a list of string, includes several variable names, which specify a behavior of a directive. An example is []string{"ngxHTTPMainConf", "ngxConfFlag",}. A directive can have several masks.

Jump to

Keyboard shortcuts

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