Skip to content

Commit 4b8f06c

Browse files
lengaumedubelko
andauthored
docs: update docs for 5.0.0 (#700)
Co-authored-by: Michael DuBelko <[email protected]>
1 parent 4910b2d commit 4b8f06c

File tree

4 files changed

+39
-46
lines changed

4 files changed

+39
-46
lines changed

craft_application/pytest_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
def debug_mode() -> None:
3636
"""Ensure that the application is in debug mode, raising exceptions from run().
3737
38-
This fixture is automatically used. To disable debug mode for specific tests that
39-
require it, use the :py:func:`production_mode` fixture.
38+
This fixture is automatically used. To disable debug mode for specific tests,
39+
use the :py:func:`production_mode` fixture.
4040
"""
4141
os.environ["CRAFT_DEBUG"] = "1"
4242

@@ -98,7 +98,7 @@ def fake_host_architecture(
9898
"""Run this test as though running on each supported architecture.
9999
100100
This parametrized fixture provides architecture values for all supported
101-
architectures, simulating as though the application is running on that architecture.
101+
architectures, simulating running on that architecture.
102102
This fixture is limited to setting the architecture within this python process.
103103
"""
104104
arch: craft_platforms.DebianArchitecture = request.param
@@ -139,7 +139,7 @@ def in_project_path(
139139
) -> pathlib.Path:
140140
"""Run the test inside the project path.
141141
142-
Changes the working directory of the test to use the project path.
142+
This fixture changes the working directory of the test to use the project path.
143143
Best to use with ``pytest.mark.usefixtures``
144144
"""
145145
monkeypatch.chdir(project_path)

docs/reference/changelog.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
Changelog
55
*********
66

7-
5.0.0 (2025-Mon-DD)
8-
-------------------
7+
5.0.0 (2025-03-26)
8+
------------------
99

1010
Services
1111
========
1212

13-
- A new :doc:`services/project` now handles the creation and management of the project
14-
for this run of the application.
13+
- A new :doc:`services/project` now handles project loading and rendering. Services
14+
and commands can use this to get a project. The abstract ``ProjectService`` is no
15+
longer available for inheritance.
1516
- Setting the arguments for a service using the service factory's ``set_kwargs`` is
16-
deprecated. Use ``update_kwargs`` instead or file `an issue
17-
<https://github.com/canonical/craft-application/issues/new?template=bug.yaml>`_
18-
if you still need this method.
17+
deprecated. Use ``update_kwargs`` instead.
1918

2019
Testing
2120
=======
@@ -33,9 +32,9 @@ Breaking changes
3332
designate that they require a project, but should instead use the
3433
:py:meth:`~craft_application.services.project.ProjectService.get()` method of the
3534
``ProjectService`` to retrieve the project. It will error accordingly.
36-
- The ``BuildPlanner`` class has been replaced with the
35+
- The ``BuildPlanner`` pydantic model has been replaced with the
3736
:py:class:`~craft_application.services.services.buildplan.BuildPlanService`
38-
- ``BuildInfo`` is replaced with
37+
- The internal ``BuildInfo`` model is replaced with
3938
:external+craft-platforms:class:`craft_platforms.BuildInfo`
4039

4140
For a complete list of commits, check out the `5.0.0`_ release on GitHub.

docs/reference/pytest-plugin.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
pytest plugin
44
=============
55

6-
craft-application includes a `pytest`_ plugin to help ease the testing of apps that use
7-
it as a framework.
6+
The `pytest`_ plugin helps ease the testing of apps that use craft-application.
87

98
By default, this plugin sets the application into debug mode, meaning the
109
:py:meth:`~craft_application.Application.run()` method will re-raise generic exceptions.
@@ -26,11 +25,11 @@ Fixtures
2625
.. autofunction:: in_project_path
2726

2827
Auto-used fixtures
29-
~~~~~~~~~~~~~~~~~~
28+
------------------
3029

3130
Some fixtures are automatically enabled for tests, changing the default behaviour of
32-
applications during the testing process. This is kept to a minimum, but is done when
33-
the standard behaviour could cause subtle testing issues.
31+
applications during the testing process. Each auto-use fixture changes the default
32+
behaviour of Craft Application during testing.
3433

3534
.. autofunction:: debug_mode
3635

docs/reference/services/project.rst

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,29 @@ The ``ProjectService`` is a service for handling access to the project.
88
Project loading
99
---------------
1010

11-
The project service is responsible for loading, validating and rendering the project
12-
file to a :py:class:`~craft_application.models.Project` model. While the service can
13-
render a project as though it is running on any architecture and building for
14-
any platform or architecture, the most common use case is to render the project
15-
as though running on the current architecture, for the targeted platform.
16-
Here, the steps taken are as follows:
17-
18-
.. How do I make this numbered?
19-
.. contents::
20-
:class: this-will-duplicate-information-and-it-is-still-useful-here
21-
:local:
11+
The Project service handles loading, validating and rendering the project
12+
file to a :py:class:`~craft_application.models.Project` model. The most common use
13+
case is to render the project as though running on the host's architecture, for
14+
the targeted platform. However, it can also render a project as though it is
15+
running on any architecture and building for any platform or architecture.
16+
17+
The rendering process follows these steps:
2218

2319
Configure the ProjectService
2420
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2521

26-
The first step is for the ``Application`` to configure the project service. This means
27-
several things:
22+
The first step is for the ``Application`` to configure the project service. It:
2823

2924
1. Set the project directory location. This is done by passing a directory on
3025
instantiation.
31-
2. Set any ``platform`` and ``build_for`` hints. This is done using the ``configure``
32-
method.
26+
2. Set any ``platform`` and ``build_for`` hints. This is done using the
27+
``configure()`` method.
3328

3429
Find the project file
3530
~~~~~~~~~~~~~~~~~~~~~
3631

3732
Once a project directory is declared,
38-
:py:meth:`ProjectService.resolve_project_file_path` can be used to find the path to the
33+
:py:meth:`ProjectService.resolve_project_file_path` finds the path to the
3934
actual project file. By default, this is simply ``<app name>.yaml`` in the project
4035
directory. However, applications may override this if they need to search for the
4136
project file at other locations.
@@ -46,42 +41,42 @@ Parse the project file YAML
4641
Once the project file is found, it is parsed as a `YAML`_ file. The file has additional
4742
requirements beyond being a valid YAML document:
4843

49-
1. A file may only contain a single document.
50-
2. The top level of this document must be a map whose keys are strings.
44+
1. It must contain only a single document.
45+
2. Its top level must be a map whose keys are strings.
5146

5247
Validate grammar
5348
~~~~~~~~~~~~~~~~
5449

55-
At this step, any user-added grammar is validated using
56-
:external+craft-grammar:doc:`Craft Grammar <index>`. No grammar is applied yet.
50+
In this step, any user-added grammar is validated using
51+
:external+craft-grammar:doc:`Craft Grammar <index>`. No grammar is processed yet.
5752

5853
Perform application-specific transforms
5954
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6055

6156
At this step, any application-specific transformations of the document are applied
62-
using the :py:meth:`ProjectService._app_preprocess_project` method. By default,
57+
by the :py:meth:`ProjectService._app_preprocess_project` method. By default,
6358
nothing happens here.
6459

6560
The project dict at this state is available using the
66-
:py:meth:`ProjectService._preprocess` protected method. ``_preprocess`` calls
67-
``_app_preprocess_project`` as the last step of processing before returning the
61+
:py:meth:`ProjectService._preprocess` protected method. ``_preprocess()`` calls
62+
``_app_preprocess_project()`` as the last step of processing before returning the
6863
pre-processed project dict.
6964

70-
Expand environment
71-
~~~~~~~~~~~~~~~~~~
65+
Expand the environment
66+
~~~~~~~~~~~~~~~~~~~~~~
7267

7368
Next, :external+craft-parts:func:`craft_parts.expand_environment` is called to replace
7469
global parts variables with their expected values.
7570

7671
Process parts grammar
7772
~~~~~~~~~~~~~~~~~~~~~
7873

79-
At this point, grammar is processed for each part defined. This includes parts added
74+
At this point, grammar is processed for each part. This includes parts added
8075
during the application-specific transforms step, meaning that transforms may add
8176
grammar-aware syntax if needed.
8277

83-
Validate Pydantic model
84-
~~~~~~~~~~~~~~~~~~~~~~~
78+
Validate the Pydantic model
79+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
8580

8681
A Pydantic model of the project is loaded, validating more thoroughly.
8782

0 commit comments

Comments
 (0)