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) AppendVisibility(visibility string)
- func (c *Config) CoarseGrainedGeneration() bool
- func (c *Config) DefaultVisibilty() []string
- func (c *Config) ExcludedPatterns() *singlylinkedlist.List
- func (c *Config) ExtensionEnabled() bool
- func (c *Config) FindThirdPartyDependency(modName string) (string, string, bool)
- func (c *Config) FormatThirdPartyDependency(repositoryName string, distributionName string) label.Label
- func (c *Config) IgnoresDependency(dep string) bool
- func (c *Config) IgnoresFile(file string) bool
- func (c *Config) LabelConvention() string
- func (c *Config) LabelNormalization() LabelNormalizationType
- func (c *Config) NewChild() *Config
- func (c *Config) Parent() *Config
- func (c *Config) PerFileGeneration() bool
- func (c *Config) PerFileGenerationIncludeInit() bool
- func (c *Config) PerPackageGenerationRequireTestEntryPoint() bool
- 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) SetDefaultVisibility(visibility []string)
- func (c *Config) SetExtensionEnabled(enabled bool)
- func (c *Config) SetGazelleManifest(gazelleManifest *manifest.Manifest)
- func (c *Config) SetLabelConvention(convention string)
- func (c *Config) SetLabelNormalization(normalizationType LabelNormalizationType)
- func (c *Config) SetLibraryNamingConvention(libraryNamingConvention string)
- func (c *Config) SetPerFileGeneration(perFile bool)
- func (c *Config) SetPerFileGenerationIncludeInit(includeInit bool)
- func (c *Config) SetPerPackageGenerationRequireTestEntryPoint(perPackageGenerationRequireTestEntryPoint bool)
- func (c *Config) SetPythonProjectRoot(pythonProjectRoot string)
- func (c *Config) SetTestFilePattern(patterns []string)
- func (c *Config) SetTestNamingConvention(testNamingConvention string)
- func (c *Config) SetValidateImportStatements(validate bool)
- func (c *Config) TestFilePattern() []string
- func (c *Config) ValidateImportStatements() bool
- func (c *Config) Visibility() []string
- type Configs
- type GenerationModeType
- type LabelNormalizationType
- 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" // GenerationModePerFileIncludeInit represents the directive that augments // the "per_file" GenerationMode by including the package's __init__.py file. // This is a boolean directive. GenerationModePerFileIncludeInit = "python_generation_mode_per_file_include_init" // GenerationModePerPackageRequireTestEntryPoint represents the directive that // requires a test entry point to generate test targets in "package" GenerationMode. // This is a boolean directive. GenerationModePerPackageRequireTestEntryPoint = "python_generation_mode_per_package_require_test_entry_point" // 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" // DefaultVisibilty represents the directive that controls what visibility // labels are added to generated python targets. DefaultVisibilty = "python_default_visibility" // Visibility represents the directive that controls what additional // visibility labels are added to generated targets. It mimics the behavior // of the `go_visibility` directive. Visibility = "python_visibility" // TestFilePattern represents the directive that controls which python // files are mapped to `py_test` targets. TestFilePattern = "python_test_file_pattern" // LabelConvention represents the directive that defines the format of the // labels to third-party dependencies. LabelConvention = "python_label_convention" // LabelNormalization represents the directive that controls how distribution // names of labels to third-party dependencies are normalized. Supported values // are 'none', 'pep503' and 'snake_case' (default). See LabelNormalizationType. LabelNormalization = "python_label_normalization" )
Directives
const ( // The default visibility label, including a format placeholder for `python_root`. DefaultVisibilityFmtString = "//%s:__subpackages__" // The default globs used to determine pt_test targets. DefaultTestFilePatternString = "*_test.py,test_*.py" // The default convention of label of third-party dependencies. DefaultLabelConvention = "$distribution_name$" // The default normalization applied to distribution names of third-party dependency labels. DefaultLabelNormalizationType = SnakeCaseLabelNormalizationType )
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) AppendVisibility ¶
AppendVisibility adds additional items to the target's visibility.
func (*Config) CoarseGrainedGeneration ¶
CoarseGrainedGeneration returns whether coarse-grained targets should be generated or not.
func (*Config) DefaultVisibilty ¶
DefaultVisibilty returns the target's default visibility.
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) FormatThirdPartyDependency ¶
func (c *Config) FormatThirdPartyDependency(repositoryName string, distributionName string) label.Label
FormatThirdPartyDependency returns a label to a third-party dependency performing all formating and normalization.
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) LabelConvention ¶
LabelConvention returns the label convention used for third-party dependencies.
func (*Config) LabelNormalization ¶
func (c *Config) LabelNormalization() LabelNormalizationType
LabelConvention returns the label normalization applied to distribution names of third-party dependencies.
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) PerFileGeneration ¶
PerFileGeneration returns whether a separate py_library target should be generated for each file.
func (*Config) PerFileGenerationIncludeInit ¶
PerFileGenerationIncludeInit returns whether py_library targets should include __init__.py files when PerFileGeneration() is true.
func (*Config) PerPackageGenerationRequireTestEntryPoint ¶
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) SetDefaultVisibility ¶
SetDefaultVisibility sets the default visibility of the target.
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) SetLabelConvention ¶
SetLabelConvention sets the label convention used for third-party dependencies.
func (*Config) SetLabelNormalization ¶
func (c *Config) SetLabelNormalization(normalizationType LabelNormalizationType)
SetLabelConvention sets the label normalization applied to distribution names of third-party dependencies.
func (*Config) SetLibraryNamingConvention ¶
SetLibraryNamingConvention sets the py_library target naming convention.
func (*Config) SetPerFileGeneration ¶
SetPerFileGneration sets whether a separate py_library target should be generated for each file.
func (*Config) SetPerFileGenerationIncludeInit ¶
SetPerFileGenerationIncludeInit sets whether py_library targets should include __init__.py files when PerFileGeneration() is true.
func (*Config) SetPerPackageGenerationRequireTestEntryPoint ¶
func (*Config) SetPythonProjectRoot ¶
SetPythonProjectRoot sets the Python project root.
func (*Config) SetTestFilePattern ¶
SetTestFilePattern sets the file patterns that should be mapped to 'py_test' rules.
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) TestFilePattern ¶
TestFilePattern returns the patterns that should be mapped to 'py_test' rules.
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.
func (*Config) Visibility ¶
Visibility returns the target's visibility.
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" GenerationModeFile GenerationModeType = "file" )
Generation modes
type LabelNormalizationType ¶
type LabelNormalizationType int
const ( NoLabelNormalizationType LabelNormalizationType = iota Pep503LabelNormalizationType SnakeCaseLabelNormalizationType )
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.