API Documentation
slap.application.Application
The application object is the main hub for command-line interactions. It is responsible for managing the project that is the main subject of the command-line invokation (or multiple of such), provide the #cleo command-line application that #ApplicationPlugin#s can register commands to, etc.
Source code in slap/application.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
repository
property
Return the Slap repository that is the subject of the current application. There may be command plugins that do not require the repository to function, so this property creates the repository lazily.
configurations
Return a list of all configuration objects, i.e. all projects and eventually the #Repository, unless one project is from the same directory as the repository.
Source code in slap/application.py
get_target_projects
get_target_projects(only_projects: str | Sequence[str] | None = None, cwd: Path | None = None) -> list[Project]
Returns the list of projects that should be dealt with when executing a command. When there is a main project, only the main project will be returned. When in the repository root, all projects will be returned.
Source code in slap/application.py
load_plugins
Loads all application plugins (see #ApplicationPlugin) and activates them.
By default, all plugins available in the slap.application.ApplicationPlugin
entry point group are loaded. This
behaviour can be modified by setting either the [tool.slap.plugins.disable]
or [tool.slap.plugins.enable]
configuration option (without the tool.slap
prefix in case of a slap.toml
configuration file). The default
plugins delivered immediately with Slap are enabled by default unless disabled explicitly with the disable
option.
Source code in slap/application.py
slap.plugins
ApplicationPlugin
Bases: Generic[T]
, ABC
A plugin that is activated on application load, usually used to register additional CLI commands.
Source code in slap/plugins.py
activate
abstractmethod
activate(app: Application, config: T) -> None
Activate the plugin. Register a #Command to #Application.cleo or another type of plugin to the #Application.plugins registry.
load_configuration
abstractmethod
load_configuration(app: Application) -> T
Load the configuration of the plugin. Usually, plugins will want to read the configuration from the Slap
configuration, which is either loaded from pyproject.toml
or slap.toml
. Use #Application.raw_config
to access the Slap configuration.
Source code in slap/plugins.py
CheckPlugin
Bases: ABC
This plugin type can be implemented to add custom checks to the slap check
command. Note that checks will
be grouped and their names prefixed with the plugin name, so that name does not need to be included in the name
of the returned checks.
Source code in slap/plugins.py
ProjectHandlerPlugin
Bases: ABC
A plugin that implements the core functionality of a project. Project handlers are intermediate layers between the Slap tooling and the actual project configuration, allowing different types of configurations to be adapted and used with Slap.
Source code in slap/plugins.py
add_dependency
Add a dependency to the project configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
Project
|
The project to update. |
required |
dependency |
Dependency
|
The dependency to add. |
required |
where |
str
|
The location of where to add the dependency. This is either |
required |
Raises: NotImplementedError: If the operation is not supported by the project handler.
Source code in slap/plugins.py
get_dependencies
abstractmethod
get_dist_name
abstractmethod
get_packages
abstractmethod
Return a list of packages for the project. Return None
to indicate that the project is expected to
not contain any packages.
get_readme
abstractmethod
get_version
get_version_refs
Allows the project handler to return additional version refs. Usually returns the version reference in
pyproject.toml
.
matches_project
abstractmethod
ReleasePlugin
Bases: ABC
This plugin type provides additional references to the project's version number allowing slap release
to
update these references to a new version number.
Source code in slap/plugins.py
create_release
create_release(repository: Repository, project: Project | None, target_version: str, dry: bool) -> Sequence[Path]
Gives the plugin a chance to perform an arbitrary action after all version references have been bumped,
being informed of the target version. If dry is True
, the plugin should only act as if it was performing
its usual actions but not commit the changes to disk. It should return the list of files that it modifies
or would have modified.
Source code in slap/plugins.py
get_version_refs
RepositoryCIPlugin
Bases: ABC
This plugin type can be used with the slap changelog update-pr -use <plugin_name>
option. It provides all the
details derivable from the environment (e.g. environment variables available from CI builds) that can be used to
detect which changelog entries have been added in a pull request, the pull request URL and the means to publish
the changes back to the original repository.
Source code in slap/plugins.py
all
staticmethod
all() -> dict[str, Callable[[], RepositoryCIPlugin]]
Iterates over all registered automation plugins and returns a dictionary that maps the plugin name to a factory function.
Source code in slap/plugins.py
get
staticmethod
get(plugin_name: str, io: IO) -> RepositoryCIPlugin
Returns an instance of the plugin with given name, fully initialized.
Raises a #ValueError if the plugin does not exist.
Source code in slap/plugins.py
RepositoryHandlerPlugin
Bases: ABC
A plugin to provide data and operations on a repository level.
Source code in slap/plugins.py
get_projects
abstractmethod
get_repository_host
abstractmethod
get_vcs
abstractmethod
matches_repository
abstractmethod
VersionIncrementingRulePlugin
Bases: ABC
This plugin type can be implemented to provide rules accepted by the slap release <rule>
command to "bump" an
existing version number to another. The builtin rules implemented in #slap.ext.version_incrementing_rules.