Skip to content

Commit 63d3746

Browse files
committed
WIP: Add serialization of missing Description
The `<desc>` element in the XML configuration contains language-specific descriptions. It is used in the index pages of each product release. This PR adds the missing handling of this element. * Build `Description` model for `Manifest` * In `Deliverable`, create new methods (see below). They transform the `<desc>` element * `all_categories`: Return the categories of the deliverable. * `categories`: Return the categories from the product node. * `categories_from_root`: Return the categories from the root node. * For submodels of `Manifest`, add serialization method (e.g., for `lang` attribute) * Improve test cases * Update doc sources of auto API
1 parent adbc42a commit 63d3746

23 files changed

Lines changed: 486 additions & 58 deletions

File tree

changelog.d/155.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add serialization of missing :class:`~docserv.models.deliverable.Description`.

docs/source/reference/_autoapi/docbuild/constants/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Attributes
1919
docbuild.constants.ALLOWED_LANGUAGES
2020
docbuild.constants.DEFAULT_DELIVERABLES
2121
docbuild.constants.SERVER_ROLES
22+
docbuild.constants.SERVER_ROLES_ALIASES
2223
docbuild.constants.DEFAULT_LIFECYCLE
2324
docbuild.constants.ALLOWED_LIFECYCLES
2425
docbuild.constants.VALID_PRODUCTS
@@ -74,7 +75,14 @@ Module Contents
7475

7576
.. py:data:: SERVER_ROLES
7677
77-
The different server roles, including long and short spelling.
78+
The unique primary server role values.
79+
80+
81+
.. py:data:: SERVER_ROLES_ALIASES
82+
:value: ('PRODUCTION', 'STAGING', 'TESTING', 'PROD', 'P', 'prod', 'p', 'STAGE', 'S', 'stage', 's',...
83+
84+
85+
All valid server role names and aliases for validation and testing.
7886

7987

8088
.. py:data:: DEFAULT_LIFECYCLE

docs/source/reference/_autoapi/docbuild/models/config_model/index.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/source/reference/_autoapi/docbuild/models/deliverable/Deliverable.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,50 @@ docbuild.models.deliverable.Deliverable
1111
deliverable.
1212

1313

14+
.. py:property:: all_categories
15+
:type: collections.abc.Generator[lxml.etree._Element, None, None]
16+
17+
18+
Return the groups (formerly categories) of the deliverable.
19+
20+
Yield all elements from the product and root node.
21+
22+
:yield: The elements categories/category and category.
23+
24+
25+
26+
.. py:property:: categories
27+
:type: collections.abc.Generator[lxml.etree._Element, None, None]
28+
29+
30+
Return the groups (formerly categories) from the product node.
31+
32+
Yield all elements under the product were this deliverable belongs to.
33+
34+
:yield: The elements categories/category and category.
35+
36+
37+
38+
.. py:property:: categories_from_root
39+
:type: collections.abc.Generator[lxml.etree._Element, None, None]
40+
41+
42+
Return the groups (formerly categories) from the root node.
43+
44+
Yield all elements under the root node.
45+
46+
:yield: The elements categories/category and category.
47+
48+
49+
50+
.. py:property:: desc
51+
:type: collections.abc.Generator[lxml.etree._Element, None, None]
52+
53+
54+
Return the <desc> from the product node.
55+
56+
57+
1458
.. py:property:: productid
1559
:type: str | None
1660

docs/source/reference/_autoapi/docbuild/models/doctype/Doctype.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ docbuild.models.doctype.Doctype
125125

126126

127127

128-
.. py:method:: coerce_lifecycle(value: str | docbuild.models.lifecycle.LifecycleFlag) -> docbuild.models.lifecycle.LifecycleFlag
129-
:classmethod:
130-
131-
132-
Convert a string into a LifecycleFlag.
133-
134-
135-
136128
.. py:method:: coerce_langs(value: str | list[str | docbuild.models.language.LanguageCode]) -> list[docbuild.models.language.LanguageCode]
137129
:classmethod:
138130

@@ -166,3 +158,19 @@ docbuild.models.doctype.Doctype
166158
deliverables that match this Doctype.
167159

168160

161+
162+
.. py:method:: product_xpath_segment() -> str
163+
164+
Return the XPath segment for the product node.
165+
166+
Example: "product[@productid='sles']" or "product"
167+
168+
169+
170+
.. py:method:: docset_xpath_segment(docset: str) -> str
171+
172+
Return the XPath segment for the docset node.
173+
174+
Example: "docset[@setid='15-SP6']" or "docset"
175+
176+

docs/source/reference/_autoapi/docbuild/models/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Submodules
2020
/reference/_autoapi/docbuild/models/doctype/index
2121
/reference/_autoapi/docbuild/models/language/index
2222
/reference/_autoapi/docbuild/models/lifecycle/index
23+
/reference/_autoapi/docbuild/models/manifest/index
2324
/reference/_autoapi/docbuild/models/metadata/index
2425
/reference/_autoapi/docbuild/models/path/index
2526
/reference/_autoapi/docbuild/models/product/index

docs/source/reference/_autoapi/docbuild/models/lifecycle/LifecycleFlag.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ docbuild.models.lifecycle.LifecycleFlag
4444

4545

4646

47-
.. py:method:: from_str(value: str) -> LifecycleFlag
47+
.. py:method:: from_str(value: str) -> Self
4848
:classmethod:
4949

5050

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
docbuild.models.manifest.Archive
2+
================================
3+
4+
.. py:class:: docbuild.models.manifest.Archive(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.Archive
9+
:parts: 1
10+
11+
12+
Represents an archive (e.g., a ZIP file) for a product/docset.
13+
14+
15+
.. py:method:: serialize_lang(value: docbuild.models.language.LanguageCode, info: pydantic.SerializationInfo) -> str
16+
17+
Serialize LanguageCode to a string like 'en-us'.
18+
19+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
docbuild.models.manifest.Category
2+
=================================
3+
4+
.. py:class:: docbuild.models.manifest.Category(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.Category
9+
:parts: 1
10+
11+
12+
Represents a category for a product/docset.
13+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
docbuild.models.manifest.CategoryTranslation
2+
============================================
3+
4+
.. py:class:: docbuild.models.manifest.CategoryTranslation(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.CategoryTranslation
9+
:parts: 1
10+
11+
12+
Represents a translation for a category title.
13+
14+
15+
.. py:method:: serialize_lang(value: docbuild.models.language.LanguageCode, info: pydantic.SerializationInfo) -> str
16+
17+
Serialize LanguageCode to a string like 'en-us'.
18+
19+

0 commit comments

Comments
 (0)