Skip to content

Commit 844dc3e

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 8e43ea2 commit 844dc3e

18 files changed

Lines changed: 458 additions & 25 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/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

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+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
docbuild.models.manifest.Description
2+
====================================
3+
4+
.. py:class:: docbuild.models.manifest.Description(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.Description
9+
:parts: 1
10+
11+
12+
Represents a description 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+
20+
21+
.. py:method:: from_xml_node(node: lxml.etree._Element) -> collections.abc.Generator[Self, None, None]
22+
:classmethod:
23+
24+
25+
Extract descriptions from a parent XML node.
26+
27+
:param node: a node pointing to ``<product>``
28+
:yield:
29+
30+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
docbuild.models.manifest.Document
2+
=================================
3+
4+
.. py:class:: docbuild.models.manifest.Document(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.Document
9+
:parts: 1
10+
11+
12+
Represents a single document within the manifest.
13+
14+
15+
.. py:method:: coerce_rank(value: str | int | None) -> int | None
16+
:classmethod:
17+
18+
19+
Coerce rank from string to int, handling empty strings.
20+
21+
22+
23+
.. py:method:: serialize_rank(value: int | str | None, info: pydantic.SerializationInfo) -> str
24+
25+
Serialize rank to an empty string if None.
26+
27+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
docbuild.models.manifest.DocumentFormat
2+
=======================================
3+
4+
.. py:class:: docbuild.models.manifest.DocumentFormat(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.DocumentFormat
9+
:parts: 1
10+
11+
12+
Represents the available formats for a document.
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
docbuild.models.manifest.Manifest
2+
=================================
3+
4+
.. py:class:: docbuild.models.manifest.Manifest(/, **data: Any)
5+
6+
Bases: :py:obj:`pydantic.BaseModel`
7+
8+
.. autoapi-inheritance-diagram:: docbuild.models.manifest.Manifest
9+
:parts: 1
10+
11+
12+
Represents the aggregated metadata manifest for a product/docset.
13+

0 commit comments

Comments
 (0)