Skip to content

Commit 213e44c

Browse files
Add missing doc issues (#178)
* 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]>
1 parent 871ca7a commit 213e44c

10 files changed

Lines changed: 185 additions & 19 deletions

File tree

changelog.d/173.doc.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Describe some missing features:
2+
3+
* Document the command :command:`docbuild check files` in the new seciton
4+
"Checking your Environment"
5+
* Add Pydantic definition into glossary
6+
* Adjusted "Configuring the Tool" section and included placeholders
7+
(static & dynamic), key naming conventions, and more.

docs/source/glossary.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ For Python specific terms, look into:
141141

142142
See class :class:`~docbuild.models.product.Product`.
143143

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+
144149
:file:`pyproject.toml`
145150
A configuration file used in Python project to define build system
146151
requirements and project metadata.

docs/source/reference/_autoapi/docbuild/cli/cmd_config/environment/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ docbuild.cli.cmd_config.environment
55
66
.. autoapi-nested-parse::
77

8-
CLI interface to showsthe configuration of the environment files.
8+
CLI interface to shows the configuration of the environment files.
99

1010

1111

docs/source/user/check-env.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. _check-environment:
2+
3+
Checking your Environment
4+
=========================
5+
6+
.. NOTE: This section is work in progress and related to issue #9
7+
8+
9+
.. _check-dc-files:
10+
11+
Checking DC Files
12+
-----------------
13+
14+
From time to time it makes sense to check if the DC files referred in
15+
the Docbuild XML configuration exist in the repos.
16+
17+
To check all DC files in all repositories, use the following command:
18+
19+
.. code-block:: shell-session
20+
:caption: Checking DC files in all repositories
21+
22+
docbuild --env-config ENV_CONFIG_FILE check dc-files
23+
24+
To check DC files only for a specific product and docset, use the doctype
25+
syntax:
26+
27+
.. code-block:: shell-session
28+
:caption: Checking DC files for SLES 16.0 in English only
29+
30+
docbuild --env-config ENV_CONFIG_FILE check dc-files 'sles/16.0/en-us'
31+
32+
If a DC file is missing, the tool will report it, allowing you to take
33+
corrective action.

docs/source/user/config.rst

Lines changed: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Configuring the Tool
55

66
.. note::
77

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.
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.
99

1010
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.
1111

@@ -21,26 +21,144 @@ To use your configuration file, follow these steps one time:
2121

2222
#. Adjust the path ``paths.root_config_dir``. Use the path from :ref:`get-xml-config`. The rest can stay as it is.
2323

24-
#. Specific the configuration with the global option ``--env-config``.
24+
#. Specify the configuration with the global option ``--env-config``.
2525

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.
2726

28-
.. code-block:: shell-session
29-
:caption: Example aliases for different configuration files
30-
:name: docbuild-aliases
27+
.. _config-key-naming-conventions:
3128

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.
75+
Two types of placeholders are supported:
76+
77+
* **Static placeholders** (Syntax ``{placeholder}``)
78+
79+
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.
83+
84+
85+
* **Dynamic placeholders** (Syntax ``{{placeholder}}``)
86+
87+
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:
98+
99+
.. code-block:: toml
100+
:emphasize-lines: 3
101+
102+
[paths]
103+
root_config_dir = "~/repos/GL/susedoc/docserv-config"
104+
jinja_dir = "{root_config_dir}/jinja-doc-suse-com"
105+
106+
In the previous example, the key ``jinja_dir`` uses a static placeholder
107+
``{root_config_dir}`` to reference the value of the same key
108+
``root_config_dir`` within the same section.
109+
110+
* **Section name** (Syntax ``{section.key}``)
111+
112+
A section name refers to a key in another section:
113+
114+
.. code-block:: toml
115+
:emphasize-lines: 5
116+
117+
[server]
118+
name = "doc-example-com"
119+
120+
[paths]
121+
base_cache_dir = "/tmp/cache"
122+
base_server_cache_dir = "{base_cache_dir}/{server.name}"
123+
base_server_cache_dir = "{base_cache_dir}/{server.name}"
124+
125+
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:
35133

36134
Viewing the Environment Configuration
37135
-------------------------------------
38136

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.
40140

41141
.. code-block:: shell-session
42142
:caption: Displaying the resolved environment configuration
43143
44-
docbuild config env
144+
docbuild --env-config=YOUR_TOML_CONFIG config env
45145
46146
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'

docs/source/user/config/environment.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _config-show-env:
2+
13
Showing Env's Configuration
24
===========================
35

@@ -20,4 +22,4 @@ current project's directory.
2022
.. note::
2123

2224
An example of an environment configuration file is provided in this repo
23-
in the :gh_path:`etc/docbuild/env.example.toml` directory.
25+
in the :gh_path:`etc/docbuild/env.example.toml` directory.

docs/source/user/config/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Showing configuration
1+
Showing Configuration
22
=====================
33

44
The docbuild tool distinguishes between two types of configuration files:
55

6-
* **Application configuration files ("app config")**
6+
* Application configuration files ("app config")
77

8-
* **Environment configuration files ("env config")**
8+
* Environment configuration files ("env config")
99

1010
Additionally, the docbuild tool has also hardcoded default values for both types of configuration.
1111

@@ -17,7 +17,7 @@ Keep in mind that these defaults may not be suitable for all use cases, and it i
1717

1818
.. admonition:: TOML as default format
1919

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.
2121

2222
The following subsections provide more details on how to view and manage the configuration files for both application and environment settings.
2323

docs/source/user/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ User Guide
1313
validate
1414
clone
1515
metadata
16+
check-env

src/docbuild/cli/cmd_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _setup_console() -> None:
6666
help=(
6767
"Enable debug mode. "
6868
"This will show more information about the process and the config files. "
69-
"If available, read the environment variable 'DOCBUILD_DEBUG'."
69+
"If available, read the environment variable ``DOCBUILD_DEBUG``."
7070
),
7171
)
7272
@click.option(

src/docbuild/cli/cmd_config/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""CLI interface to showsthe configuration of the environment files."""
1+
"""CLI interface to shows the configuration of the environment files."""
22

33
import click
44
from rich import print_json

0 commit comments

Comments
 (0)