@@ -8,34 +8,29 @@ The ``ProjectService`` is a service for handling access to the project.
8
8
Project loading
9
9
---------------
10
10
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:
22
18
23
19
Configure the ProjectService
24
20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
21
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:
28
23
29
24
1. Set the project directory location. This is done by passing a directory on
30
25
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.
33
28
34
29
Find the project file
35
30
~~~~~~~~~~~~~~~~~~~~~
36
31
37
32
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
39
34
actual project file. By default, this is simply ``<app name>.yaml `` in the project
40
35
directory. However, applications may override this if they need to search for the
41
36
project file at other locations.
@@ -46,42 +41,42 @@ Parse the project file YAML
46
41
Once the project file is found, it is parsed as a `YAML `_ file. The file has additional
47
42
requirements beyond being a valid YAML document:
48
43
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.
51
46
52
47
Validate grammar
53
48
~~~~~~~~~~~~~~~~
54
49
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.
57
52
58
53
Perform application-specific transforms
59
54
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60
55
61
56
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,
63
58
nothing happens here.
64
59
65
60
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
68
63
pre-processed project dict.
69
64
70
- Expand environment
71
- ~~~~~~~~~~~~~~~~~~
65
+ Expand the environment
66
+ ~~~~~~~~~~~~~~~~~~~~~~
72
67
73
68
Next, :external+craft-parts:func: `craft_parts.expand_environment ` is called to replace
74
69
global parts variables with their expected values.
75
70
76
71
Process parts grammar
77
72
~~~~~~~~~~~~~~~~~~~~~
78
73
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
80
75
during the application-specific transforms step, meaning that transforms may add
81
76
grammar-aware syntax if needed.
82
77
83
- Validate Pydantic model
84
- ~~~~~~~~~~~~~~~~~~~~~~~
78
+ Validate the Pydantic model
79
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
85
80
86
81
A Pydantic model of the project is loaded, validating more thoroughly.
87
82
0 commit comments