|
15 | 15 | class Doctype(BaseModel): |
16 | 16 | """A "doctype" that comprises of a product, docset, lifecycle, and language. |
17 | 17 |
|
| 18 | + The format has the following syntax: |
| 19 | +
|
| 20 | + .. code-block:: text |
| 21 | +
|
| 22 | + [/]?[PRODUCT]/[DOCSETS][@LIFECYCLES]/LANGS |
| 23 | +
|
| 24 | + The placeholders mean the following: |
| 25 | +
|
| 26 | + * ``PRODUCT``: a lowercase acronym of a SUSE product, e.g. ``sles`` |
| 27 | + * ``DOCSETS``: one or more docsets of the mentioned product, separated by comma |
| 28 | + * ``LIFECYCLES``: one or more lifecycles, separated by comma or pipe |
| 29 | + * ``LANGS``: one or more languages, separated by comma |
| 30 | +
|
18 | 31 | >>> doctype = Doctype.from_str("sles/15-SP6@supported/en-us,de-de") |
19 | 32 | >>> doctype.product |
20 | 33 | <Product.sles: 'sles'> |
@@ -80,7 +93,7 @@ class Doctype(BaseModel): |
80 | 93 | # This leads to None in the result if that group isn't matched |
81 | 94 | _DOCTYPE_REGEX: ClassVar[Pattern] = re.compile( |
82 | 95 | r'^' # start |
83 | | - r'(?:([^/@]+|\*))?' # optional product (group 1) |
| 96 | + r'(?:/?([^/@]+|\*))?' # optional product (group 1) |
84 | 97 | r'/(?:([^/@]+|\*))?' # optional docset (group 2) |
85 | 98 | r'(?:@([a-z]+(?:[,|][a-z]+)*))?' # optional lifecycle (group 3) |
86 | 99 | r'/(\*|[\w-]+(?:,[\w-]+)*)$', # required langs (group 4) |
@@ -198,19 +211,7 @@ def coerce_langs(cls, value: str | list[str | LanguageCode]) -> list[LanguageCod |
198 | 211 |
|
199 | 212 | @classmethod |
200 | 213 | def from_str(cls, doctype_str: str) -> Self: |
201 | | - """Parse a string that adheres to the doctype format. |
202 | | -
|
203 | | - The format has the following syntax:: |
204 | | -
|
205 | | - [PRODUCT]/[DOCSETS][@LIFECYCLES]/LANGS |
206 | | -
|
207 | | - Plural means you can have one or more items: |
208 | | -
|
209 | | - * ``PRODUCT``: a lowercase acronym of a SUSE product, e.g. ``sles`` |
210 | | - * ``DOCSETS``: separated by comma |
211 | | - * ``LIFECYCLES``: separated by comma or pipe |
212 | | - * ``LANGS``: separated by comma |
213 | | - """ |
| 214 | + """Parse a string that adheres to the doctype format.""" |
214 | 215 | match = cls._DOCTYPE_REGEX.match(doctype_str) |
215 | 216 |
|
216 | 217 | if not match: |
|
0 commit comments