You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix#173: Adjust documentation issues
* Fix a link to the TOML doc
* Fix small typos in docstring or help strings
* Correct title spelling
* Add anchor
* Adjust user doc: config
* Add new "Checking your Environment"
Co-authored-by: Sushant Gaurav <[email protected]>
* Add newsfragment file
---------
Co-authored-by: Sushant Gaurav <[email protected]>
Copy file name to clipboardExpand all lines: docs/source/glossary.rst
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,11 @@ For Python specific terms, look into:
141
141
142
142
See class :class:`~docbuild.models.product.Product`.
143
143
144
+
Pydantic
145
+
A Python library for data validation and settings management using Python type annotations. It provides a way to define data models with strict type checking and validation rules, making it easier to ensure that the data your application works with is correct and consistent.
146
+
147
+
See https://pydantic.dev/
148
+
144
149
:file:`pyproject.toml`
145
150
A configuration file used in Python project to define build system
To prevent accidental commits of sensitive information, all configuration files matching the :file:`env.*.toml` pattern in the root directory are ignored by git. However, this rule does not apply to files within the :file:`etc/` directory.
8
+
To prevent accidental commits of sensitive information, all configuration files matching the :file:`env.*.toml` pattern in the root directory are ignored by Git. However, this rule does not apply to files within the :file:`etc/` directory.
9
9
10
10
Use separate TOML files to define the configuration for each of your environments. To avoid confusion, name each file according to its specific purpose. For instance, use :file:`env.devel.toml` for development, :file:`env.staging.toml` for staging, and :file:`env.production.toml` for production.
11
11
@@ -21,26 +21,144 @@ To use your configuration file, follow these steps one time:
21
21
22
22
#. Adjust the path ``paths.root_config_dir``. Use the path from :ref:`get-xml-config`. The rest can stay as it is.
23
23
24
-
#. Specific the configuration with the global option ``--env-config``.
24
+
#. Specify the configuration with the global option ``--env-config``.
25
25
26
-
To deal with different environments without having to type the full command each time, create aliases in your shell. This allows you to quickly switch between configurations without needing to remember the exact command syntax.
27
26
28
-
.. code-block:: shell-session
29
-
:caption: Example aliases for different configuration files
30
-
:name: docbuild-aliases
27
+
.. _config-key-naming-conventions:
31
28
32
-
alias docbuild-prod='docbuild --env-config env.production.toml'
33
-
alias docbuild-test='docbuild --env-config env.testing.toml'
34
-
alias docbuild-dev='docbuild --env-config env.devel.toml'
29
+
Key Naming Conventions
30
+
----------------------
31
+
32
+
The keys follow specific naming conventions to indicate their purpose and expected value types. Here are some common patterns whereas the asterisk
33
+
(``*``) represents a variable part of the key:
34
+
35
+
* ``*_dir``: Contains a directory.
36
+
37
+
* ``tmp_*``: Indicates a temporary path.
38
+
39
+
* ``*_dyn``: Denotes a dynamic value that is expected to be resolved at runtime.
40
+
41
+
Directories are created automatically when the script runs. Additionally,
42
+
the script checks if the specified paths are readable, writeable and belongs
43
+
to the user running the script.
44
+
45
+
46
+
.. _config-validation:
47
+
48
+
Validating the Configuration
49
+
-----------------------------
50
+
51
+
Before docbuild executes any commands, it validates the provided configuration
52
+
file against a predefined :term:`Pydantic` model.
53
+
54
+
The validation checks for different aspects of the configuration, such as:
55
+
56
+
* Presence of mandatory keys.
57
+
* Correct data types (for example, strings, integers, lists).
58
+
* Valid paths and if they exist on the filesystem and are writable when
59
+
required.
60
+
* Correct use of placeholders.
61
+
62
+
63
+
..
64
+
TODO: Add a link to the TOML env config reference, add an example of
65
+
a validation error message, and explain how to fix common issues.
66
+
a validation error message, and explain how to fix common issues.
67
+
68
+
69
+
.. _config-placeholders:
70
+
71
+
Using Placeholders
72
+
------------------
73
+
74
+
Docbuild supports the use of placeholders in the configuration file.
They are used to reference *other parts* of the configuration.
80
+
For example, assume you have a configuration key ``paths.root_config_dir`` that defines the root directory for configuration files. You can use a static placeholder like ``{paths.root_config_dir}`` in other parts of the configuration to refer to this value.
81
+
82
+
This allows you to maintain consistency and avoid repeating the same path multiple times in your configuration file.
These types of placeholder cannot and must not be replaced. They are meant to be used as *templates* for values that will be resolved at runtime. For example, you might have a placeholder like ``{{product}}`` that is intended to be replaced with the actual product name when the docbuild tool runs.
88
+
89
+
This allows for greater flexibility and adaptability in your configuration, as the same configuration file can be used across different products or environments without needing to hardcode specific values.
90
+
91
+
These types of placeholder make it easier to manage and maintain your configuration files, as they allow you to centralize key values and create reusable templates for dynamic content.
92
+
93
+
Static placeholders follow a specific syntax:
94
+
95
+
* **Regular name** (Syntax ``{placeholder}``)
96
+
97
+
A regular name refers to another key in the same section:
In this example, the key ``base_server_cache_dir`` uses the
126
+
static placeholder ``{server.name}`` to reference the value of the
127
+
key ``name`` in the ``server`` section.
128
+
129
+
If you have nested sections, use dot notation to reference the keys (for example, ``section.subsection.key``).
130
+
131
+
132
+
.. _config-viewing-docbuild-config-env:
35
133
36
134
Viewing the Environment Configuration
37
135
-------------------------------------
38
136
39
-
To see how ``docbuild`` interprets your environment configuration, use the ``config env`` subcommand. This is particularly useful for verifying that all placeholders (like ``{{product}}`` or ``{{lang}}``) have been correctly resolved into absolute paths.
137
+
To see how ``docbuild`` interprets your environment configuration, use the
138
+
``config env`` subcommand. This is particularly useful for verifying that all
139
+
static placeholders have been correctly resolved into absolute paths.
40
140
41
141
.. code-block:: shell-session
42
142
:caption: Displaying the resolved environment configuration
43
143
44
-
docbuild config env
144
+
docbuild --env-config=YOUR_TOML_CONFIG config env
45
145
46
146
If the configuration contains errors—such as missing mandatory keys or invalid data types—the command will output a validation error detailing what needs to be fixed.
147
+
148
+
149
+
.. _config-use-multiple-env-configs:
150
+
151
+
Using Multiple Environment Configurations
152
+
-----------------------------------------
153
+
154
+
To deal with different environments without having to type the full command
155
+
each time, create aliases in your shell. This allows you to quickly switch
156
+
between configurations without needing to remember the exact command syntax.
157
+
158
+
.. code-block:: shell-session
159
+
:caption: Example aliases for different configuration files
160
+
:name: docbuild-aliases
161
+
162
+
alias docbuild-prod='docbuild --env-config env.production.toml'
163
+
alias docbuild-test='docbuild --env-config env.testing.toml'
164
+
alias docbuild-dev='docbuild --env-config env.devel.toml'
Additionally, the docbuild tool has also hardcoded default values for both types of configuration.
11
11
@@ -17,7 +17,7 @@ Keep in mind that these defaults may not be suitable for all use cases, and it i
17
17
18
18
.. admonition:: TOML as default format
19
19
20
-
Both configuration types are written in TOML format, which is a human-readable data serialization standard. See `TOML docs <https://toml.io/en/>_` for more information on its syntax and structure.
20
+
Both configuration types are written in TOML format, which is a human-readable data serialization standard. See `TOML docs <https://toml.io/en/>`_ for more information on its syntax and structure.
21
21
22
22
The following subsections provide more details on how to view and manage the configuration files for both application and environment settings.
0 commit comments