Documentation
¶
Index ¶
- Constants
- type Config
- func (c *Config) AddExcludedPattern(pattern string)
- func (c *Config) AddIgnoreDependency(dep string)
- func (c *Config) AddIgnoreFile(file string)
- func (c *Config) CoarseGrainedGeneration() bool
- func (c *Config) ExcludedPatterns() *singlylinkedlist.List
- func (c *Config) ExtensionEnabled() bool
- func (c *Config) FindThirdPartyDependency(modName string) (string, bool)
- func (c *Config) IgnoresDependency(dep string) bool
- func (c *Config) IgnoresFile(file string) bool
- func (c *Config) NewChild() *Config
- func (c *Config) Parent() *Config
- func (c *Config) PythonProjectRoot() string
- func (c *Config) RenderBinaryName(packageName string) string
- func (c *Config) RenderLibraryName(packageName string) string
- func (c *Config) RenderTestName(packageName string) string
- func (c *Config) SetBinaryNamingConvention(binaryNamingConvention string)
- func (c *Config) SetCoarseGrainedGeneration(coarseGrained bool)
- func (c *Config) SetExtensionEnabled(enabled bool)
- func (c *Config) SetGazelleManifest(gazelleManifest *manifest.Manifest)
- func (c *Config) SetLibraryNamingConvention(libraryNamingConvention string)
- func (c *Config) SetPythonProjectRoot(pythonProjectRoot string)
- func (c *Config) SetTestNamingConvention(testNamingConvention string)
- func (c *Config) SetValidateImportStatements(validate bool)
- func (c *Config) ValidateImportStatements() bool
- type Configs
- type GenerationModeType
- type StringMapList
- type StringSet
Constants ¶
const ( // PythonExtensionDirective represents the directive that controls whether // this Python extension is enabled or not. Sub-packages inherit this value. // Can be either "enabled" or "disabled". Defaults to "enabled". PythonExtensionDirective = "python_extension" // PythonRootDirective represents the directive that sets a Bazel package as // a Python root. This is used on monorepos with multiple Python projects // that don't share the top-level of the workspace as the root. PythonRootDirective = "python_root" // PythonManifestFileNameDirective represents the directive that overrides // the default gazelle_python.yaml manifest file name. PythonManifestFileNameDirective = "python_manifest_file_name" // IgnoreFilesDirective represents the directive that controls the ignored // files from the generated targets. IgnoreFilesDirective = "python_ignore_files" // IgnoreDependenciesDirective represents the directive that controls the // ignored dependencies from the generated targets. IgnoreDependenciesDirective = "python_ignore_dependencies" // ValidateImportStatementsDirective represents the directive that controls // whether the Python import statements should be validated. ValidateImportStatementsDirective = "python_validate_import_statements" // GenerationMode represents the directive that controls the target generation // mode. See below for the GenerationModeType constants. GenerationMode = "python_generation_mode" // LibraryNamingConvention represents the directive that controls the // py_library naming convention. It interpolates $package_name$ with the // Bazel package name. E.g. if the Bazel package name is `foo`, setting this // to `$package_name$_my_lib` would render to `foo_my_lib`. LibraryNamingConvention = "python_library_naming_convention" // BinaryNamingConvention represents the directive that controls the // py_binary naming convention. See python_library_naming_convention for // more info on the package name interpolation. BinaryNamingConvention = "python_binary_naming_convention" // TestNamingConvention represents the directive that controls the py_test // naming convention. See python_library_naming_convention for more info on // the package name interpolation. TestNamingConvention = "python_test_naming_convention" )
Directives
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a config extension for a specific Bazel package.
func (*Config) AddExcludedPattern ¶
AddExcludedPattern adds a glob pattern parsed from the standard gazelle:exclude directive.
func (*Config) AddIgnoreDependency ¶
AddIgnoreDependency adds a dependency to the list of ignored dependencies for a given package. Adding an ignored dependency to a package also makes it ignored on a subpackage.
func (*Config) AddIgnoreFile ¶
AddIgnoreFile adds a file to the list of ignored files for a given package. Adding an ignored file to a package also makes it ignored on a subpackage.
func (*Config) CoarseGrainedGeneration ¶
CoarseGrainedGeneration returns whether coarse-grained targets should be generated or not.
func (*Config) ExcludedPatterns ¶
func (c *Config) ExcludedPatterns() *singlylinkedlist.List
ExcludedPatterns returns the excluded patterns list.
func (*Config) ExtensionEnabled ¶
ExtensionEnabled returns whether the extension is enabled or not.
func (*Config) FindThirdPartyDependency ¶
FindThirdPartyDependency scans the gazelle manifests for the current config and the parent configs up to the root finding if it can resolve the module name.
func (*Config) IgnoresDependency ¶
IgnoresDependency checks if a dependency is ignored in the given package or in one of the parent packages up to the workspace root.
func (*Config) IgnoresFile ¶
IgnoresFile checks if a file is ignored in the given package or in one of the parent packages up to the workspace root.
func (*Config) NewChild ¶
NewChild creates a new child Config. It inherits desired values from the current Config and sets itself as the parent to the child.
func (*Config) PythonProjectRoot ¶
PythonProjectRoot returns the Python project root.
func (*Config) RenderBinaryName ¶
RenderBinaryName returns the py_binary target name by performing all substitutions.
func (*Config) RenderLibraryName ¶
RenderLibraryName returns the py_library target name by performing all substitutions.
func (*Config) RenderTestName ¶
RenderTestName returns the py_test target name by performing all substitutions.
func (*Config) SetBinaryNamingConvention ¶
SetBinaryNamingConvention sets the py_binary target naming convention.
func (*Config) SetCoarseGrainedGeneration ¶
SetCoarseGrainedGeneration sets whether coarse-grained targets should be generated or not.
func (*Config) SetExtensionEnabled ¶
SetExtensionEnabled sets whether the extension is enabled or not.
func (*Config) SetGazelleManifest ¶
SetGazelleManifest sets the Gazelle manifest parsed from the gazelle_python.yaml file.
func (*Config) SetLibraryNamingConvention ¶
SetLibraryNamingConvention sets the py_library target naming convention.
func (*Config) SetPythonProjectRoot ¶
SetPythonProjectRoot sets the Python project root.
func (*Config) SetTestNamingConvention ¶
SetTestNamingConvention sets the py_test target naming convention.
func (*Config) SetValidateImportStatements ¶
SetValidateImportStatements sets whether Python import statements should be validated or not. It throws an error if this is set multiple times, i.e. if the directive is specified multiple times in the Bazel workspace.
func (*Config) ValidateImportStatements ¶
ValidateImportStatements returns whether the Python import statements should be validated or not. If this option was not explicitly specified by the user, it defaults to true.
type Configs ¶
Configs is an extension of map[string]*Config. It provides finding methods on top of the mapping.
func (*Configs) ParentForPackage ¶
ParentForPackage returns the parent Config for the given Bazel package.
type GenerationModeType ¶
type GenerationModeType string
GenerationModeType represents one of the generation modes for the Python extension.
const ( // GenerationModePackage defines the mode in which targets will be generated // for each __init__.py, or when an existing BUILD or BUILD.bazel file already // determines a Bazel package. GenerationModePackage GenerationModeType = "package" // GenerationModeProject defines the mode in which a coarse-grained target will // be generated englobing sub-directories containing Python files. GenerationModeProject GenerationModeType = "project" )
Generation modes
type StringMapList ¶
type StringMapList struct {
// contains filtered or unexported fields
}
StringMapList satisfies the flag.Value interface. It constructs a string map by parsing the flag string value using the provided list and map separators.
func NewStringMapList ¶
func NewStringMapList(listSeparator, mapSeparator string) *StringMapList
NewStringMapList constructs a new StringMapList with the given separators.
func (*StringMapList) Get ¶
func (sml *StringMapList) Get(key string) (string, bool)
Get returns the value for the given key.
func (*StringMapList) Set ¶
func (sml *StringMapList) Set(s string) error
Set satisfies flag.Value.Set.
func (*StringMapList) String ¶
func (sml *StringMapList) String() string
String satisfies flag.Value.String.
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
StringSet satisfies the flag.Value interface. It constructs a set backed by a hashmap by parsing the flag string value using the provided separator.
func NewStringSet ¶
NewStringSet constructs a new StringSet with the given separator.