Skip to content

Commit bfaa74b

Browse files
authored
Merge pull request #32 from openSUSE/31-doctype.xpath
Fix #31 in Doctype.xpath with '*' for products
2 parents 5a20e9a + b4b32de commit bfaa74b

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

changelog.d/31.bugfix.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Correctly convert ``'*'`` for products in :func:`docbuild.model.doctype.Doctype.xpath`
2+
3+
An XPath ``//*`` created a syntactically correct XPath, but with an
4+
additional and unnecessary ``[@productid='*']`` predicate.

src/docbuild/models/doctype.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ def xpath(self) -> str:
244244
deliverables that match this Doctype.
245245
"""
246246
# Example: /sles/15-SP6@supported/en-us,de-de
247-
product = f"product[@productid={self.product.value!r}]"
247+
product = "product"
248+
if self.product != Product.ALL:
249+
product += f'[@productid={self.product.value!r}]'
250+
248251
setids = [f'@setid={d!r}' for d in self.docset if d != '*']
249252

250253
setids_str = ' or '.join(setids)

tests/models/test_doctype.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ def test_sorted_langs_in_doctype_instantiation():
255255
'/builddocs/language'
256256
),
257257
),
258+
# 6: many products + many docsets + many lifecycles + English
259+
('//en-us', "product/docset/builddocs/language[@lang='en-us']"),
260+
# 7: all products, docsets, lifecycles, and languages
261+
('//*', "product/docset/builddocs/language"),
258262
],
259263
)
260264
def test_xpath_in_doctype(string, xpath):

0 commit comments

Comments
 (0)