diff --git a/docs/ai/ai_actions/ai_actions.md b/docs/ai/ai_actions/ai_actions.md index 95e209462a..ad771680c9 100644 --- a/docs/ai/ai_actions/ai_actions.md +++ b/docs/ai/ai_actions/ai_actions.md @@ -18,7 +18,7 @@ You can also extend it to perform other tasks or support additional AI services. "ai/ai_actions/configure_ai_actions", ("content_management/taxonomy/taxonomy#taxonomy-suggestions", "Taxonomy suggestions", "Learn how to use AI to suggest tags and categories"), ("permissions/policies#ai-actions", "Policies", "Learn about the available AI Actions policies"), -("https://doc.ibexa.co/projects/userguide/en/5.0/ai_actions/work_with_ai_actions/"), +("https://doc.ibexa.co/projects/userguide/en/5.0/ai_actions/work_with_ai_actions/", "Work with AI Actions", "Create new AI actions or modify existing ones to work faster and increase creativity."), ], columns=2) =]] ## Development diff --git a/docs/commerce/shopping_list/shopping_list.md b/docs/commerce/shopping_list/shopping_list.md index 5fe7f1870f..f7cce15c56 100644 --- a/docs/commerce/shopping_list/shopping_list.md +++ b/docs/commerce/shopping_list/shopping_list.md @@ -21,7 +21,7 @@ A user can have several shopping lists, including a default one named "My Wishli [[= cards([ "commerce/shopping_list/shopping_list_design", "commerce/shopping_list/shopping_list_api", -("api/php_api/php_api_reference/namespaces/ibexa-contracts-shoppinglist.html", "PHP API Reference", "Ibexa\Contracts\ShoppingList"), +("api/php_api/php_api_reference/namespaces/ibexa-contracts-shoppinglist.html", "PHP API Reference", "Ibexa\\Contracts\\ShoppingList"), "api/event_reference/shopping_list_events/", "search/shopping_list_search_reference/shopping_list_criteria/", "search/shopping_list_search_reference/shopping_list_sort_clauses/", diff --git a/docs/content_management/collaborative_editing/collaborative_editing.md b/docs/content_management/collaborative_editing/collaborative_editing.md index 770e0e2d03..6aa379f612 100644 --- a/docs/content_management/collaborative_editing/collaborative_editing.md +++ b/docs/content_management/collaborative_editing/collaborative_editing.md @@ -21,7 +21,7 @@ This feature also introduces new dashboard tabs for managing shared drafts and j "content_management/collaborative_editing/collaborative_editing_guide", "content_management/collaborative_editing/configure_collaborative_editing", ("permissions/policies#collaborative-editing", "Policies", "Learn about the available Collaborative editing policies"), -("https://doc.ibexa.co/projects/userguide/en/5.0/content_management/collaborative_editing/"), +("https://doc.ibexa.co/projects/userguide/en/5.0/content_management/collaborative_editing/", "Collaborative editing", "Learn about Collaborative editing feature and its capabilities."), ], columns=2) =]] ## Development diff --git a/docs/discounts/discounts.md b/docs/discounts/discounts.md index 71c8331b88..1561471886 100644 --- a/docs/discounts/discounts.md +++ b/docs/discounts/discounts.md @@ -19,7 +19,7 @@ You can also extend the feature, for example, by creating custom pricing rules, "discounts/discounts_guide", "discounts/configure_discounts", ("permissions/policies#discounts", "Policies", "Learn about the available Discounts policies"), -("https://doc.ibexa.co/projects/userguide/en/5.0/commerce/discounts/work_with_discounts/"), +("https://doc.ibexa.co/projects/userguide/en/5.0/commerce/discounts/work_with_discounts/", "Work with Discounts", "Create and edit discounts, toggle discount status."), ], columns=2) =]] ## Development diff --git a/docs/product_catalog/quable/quable.md b/docs/product_catalog/quable/quable.md index 02282290aa..c73ba23dbe 100644 --- a/docs/product_catalog/quable/quable.md +++ b/docs/product_catalog/quable/quable.md @@ -16,7 +16,7 @@ Products can be viewed, selected, and embedded in [[= product_name =]], while al [[= cards([ "product_catalog/quable/quable_guide", - ("https://doc.ibexa.co/projects/userguide/en/5.0/product_catalog/quable_pim_integration/"), + ("https://doc.ibexa.co/projects/userguide/en/5.0/product_catalog/quable_pim_integration/", "Quable PIM integration", "Quable PIM integration allows you to use products managed in Quable as the source of product data in Ibexa DXP."), ("https://www.quable.com/en", "Quable - PIM solution for product data management", "Manage your product data and accelerate sales with Quable. Discover the new PIM platform that revolutionizes the product experience"), ("https://docs.quable.com/", "Quable resources", "Find all Quable PIM, DAM, and Portal resources: user guides, training content, product documentation, technical documentation, and the PIM API for developers."), ]) =]] diff --git a/main.py b/main.py index 0df8b672b6..636979cc21 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,6 @@ import os import pprint import re -import urllib.error -import urllib.request from mkdocs.structure.pages import Page from mkdocs.utils import meta from typing import List @@ -72,7 +70,6 @@ def include_code(file_path, start_line=1, end_line=None, indent_level=0, remove_ @env.macro def cards(pages, columns=1, style="cards", force_version=False): current_page = env.variables.page - absolute_url = current_page.abs_url canonical = current_page.canonical_url url_parts = re.search(r"^(https?)://([^/]+)/([^/]+)/([^/]+)/", canonical) (scheme, site, language, version) = url_parts.groups() @@ -104,63 +101,31 @@ def cards(pages, columns=1, style="cards", force_version=False): if hash: hash = '#' + hash - if re.search(r"^https?://", path): - html = True - try: - content = urllib.request.urlopen(path).read().decode('utf-8') - except urllib.error.URLError: - content = "" - elif re.search(".html$", path): - html = True - content = open("docs/%s" % path, "r").read() - page = _absolute_page_url(scheme, site, language, version, page) + is_external = path.startswith(("http://", "https://")) + if is_external or path.endswith(".html"): + if not (custom_title and custom_description): + raise ValueError( + "cards(): card %r must supply a title and a description - only " + "Markdown pages carry front matter to read them from." % path + ) + href = page if is_external else _absolute_page_url( + scheme, site, language, version, page + ) + title = custom_title + description = custom_description else: - html = False path = path.rstrip('/') content = open("docs/%s.md" % path, "r").read() - page = _absolute_page_url(scheme, site, language, version, path, hash) - - if html: - match = re.search("(.*)", content, re.MULTILINE) - if match: - title = match.groups()[0] - else: - title = "" - match = re.search(", which markdownify drops + # entirely - the link and its list item disappeared from the generated + # Markdown with nothing left to detect. Fail loudly instead. + html = ( + '
' + '' + '

' + "
" + ) + with pytest.raises(ValueError, match="empty title"): + to_markdown(html) + + def test_inline_pill_becomes_parenthetical(): html = '

Feature is available.

' assert "Feature (Experience) is available." in to_markdown(html) diff --git a/tools/llms_txt/llmstxt_preprocess.py b/tools/llms_txt/llmstxt_preprocess.py index bd2c517b57..8d2462dfd6 100644 --- a/tools/llms_txt/llmstxt_preprocess.py +++ b/tools/llms_txt/llmstxt_preprocess.py @@ -371,12 +371,18 @@ def _process_cards(soup: Soup) -> None: title_elem = link.find("p", class_="title") description_elem = link.find("p", class_="description") - if not title_elem: - continue - - title = title_elem.get_text(strip=True) + title = title_elem.get_text(strip=True) if title_elem else "" description = description_elem.get_text(strip=True) if description_elem else "" + # A titleless card would become , which markdownify + # converts to the empty string - deleting the link and its whole list + # item without leaving a trace. Fail instead of shrinking the output. + if not title: + raise ValueError( + "card has an empty title, refusing to emit a link that would be " + "silently dropped: %s" % (href or "") + ) + li = soup.new_tag("li") link_tag = soup.new_tag("a", href=href) link_tag.string = title