diff --git a/tests/python/test_build_package_docs.py b/tests/python/test_build_package_docs.py index 7977b251da..6e22ae252d 100644 --- a/tests/python/test_build_package_docs.py +++ b/tests/python/test_build_package_docs.py @@ -236,7 +236,7 @@ def test_pointer_is_removed_without_leaving_a_double_blank_line(self): ) assert strip_llms_txt_pointer(content) == "# Getting started\n\nBody text here.\n" - def test_description_and_editions_lines_are_kept(self): + def test_description_and_trailing_content_are_kept(self): content = ( "# Heading\n" "\n" @@ -244,10 +244,10 @@ def test_description_and_editions_lines_are_kept(self): "\n" "Some page description.\n" "\n" - "Editions: Content, Experience\n" + "See also: Some related page.\n" ) assert strip_llms_txt_pointer(content) == ( - "# Heading\n\nSome page description.\n\nEditions: Content, Experience\n" + "# Heading\n\nSome page description.\n\nSee also: Some related page.\n" ) def test_nested_project_url_is_also_stripped(self): diff --git a/tests/python/test_page_metadata.py b/tests/python/test_page_metadata.py index 0638a53485..41c05b62c2 100644 --- a/tests/python/test_page_metadata.py +++ b/tests/python/test_page_metadata.py @@ -1,5 +1,4 @@ from llms_txt.llmstxt_preprocess import ( - editions_from_frontmatter, expand_macros, inject_page_metadata, ) @@ -13,18 +12,11 @@ def test_llms_txt_pointer_always_inserted_after_first_h1(): assert inject_page_metadata(content) == ( f"# Title\n\n{LLMS_TXT_LINE}\n\nBody text." ) - assert inject_page_metadata(content, description="", editions=[]) == ( + assert inject_page_metadata(content, description="") == ( f"# Title\n\n{LLMS_TXT_LINE}\n\nBody text." ) -def test_editions_inserted_after_first_h1(): - content = "# Title\n\nBody text." - assert inject_page_metadata(content, editions=["Experience"]) == ( - f"# Title\n\n{LLMS_TXT_LINE}\n\nEditions: Experience\n\nBody text." - ) - - def test_description_inserted_after_first_h1(): content = "# Title\n\nBody text." assert inject_page_metadata(content, description="Configure the Storefront.") == ( @@ -32,17 +24,10 @@ def test_description_inserted_after_first_h1(): ) -def test_description_comes_before_editions(): - content = "# Title\n\nBody text." - assert inject_page_metadata(content, description="A description.", editions=["Experience"]) == ( - f"# Title\n\n{LLMS_TXT_LINE}\n\nA description.\n\nEditions: Experience\n\nBody text." - ) - - def test_prepended_when_no_h1(): content = "Body text." - assert inject_page_metadata(content, description="A description.", editions=["Experience"]) == ( - f"{LLMS_TXT_LINE}\n\nA description.\n\nEditions: Experience\n\nBody text." + assert inject_page_metadata(content, description="A description.") == ( + f"{LLMS_TXT_LINE}\n\nA description.\n\nBody text." ) @@ -57,27 +42,6 @@ def test_llms_txt_url_respects_nested_site_path(): assert result == f"# Title\n\n{nested_line}\n\nBody text." -def test_frontmatter_edition_string(): - assert editions_from_frontmatter({"edition": "headless experience"}) == ["Headless", "Experience"] - - -def test_frontmatter_editions_list(): - assert editions_from_frontmatter({"editions": ["headless", "lts-update"]}) == ["Headless", "LTS Update"] - - -def test_frontmatter_edition_and_editions_merged(): - result = editions_from_frontmatter({"edition": "experience", "editions": ["headless"]}) - assert result == ["Experience", "Headless"] - - -def test_unknown_edition_passes_through(): - assert editions_from_frontmatter({"edition": "custom"}) == ["custom"] - - -def test_empty_frontmatter(): - assert editions_from_frontmatter({}) == [] - - def test_expand_macros_substitutes_scalars(): variables = {"product_name": "Ibexa DXP", "product_name_cdp": "Ibexa CDP"} assert expand_macros("Install [[= product_name_cdp =]] with [[= product_name =]].", variables) == ( diff --git a/tests/python/test_preprocess.py b/tests/python/test_preprocess.py index 81914e48c7..d2cda8277d 100644 --- a/tests/python/test_preprocess.py +++ b/tests/python/test_preprocess.py @@ -50,11 +50,11 @@ def test_release_note_tags_appended_to_heading(): html = ( '
Feature is available.
' - assert "Feature (Experience) is available." in to_markdown(html) - - -def test_adjacent_inline_pills_merged(): - # Structure from update_from_5.0: pills separated by a space in a heading. - html = ( - 'Feature" - ' ' - ' ' - ' is available.
' - ) - assert "Feature (Headless, Experience, LTS Update) is available." in to_markdown(html) - - def test_ol_start_attribute_preserved(): #note
{html_module.escape(code_elem.get_text())}", "html.parser")
)
-# ---------------------------------------------------------------------------
-# Inline edition badge spans (from snippet includes)
-# ---------------------------------------------------------------------------
-
-def _pill_edition(node) -> str:
- """Return the edition name of an inline pill span, or '' if not one."""
- if getattr(node, "name", None) != "span":
- return ""
- classes = node.get("class") or []
- if "pill--inline" not in classes:
- return ""
- for pill_cls, edition_name in PILL_CLASS_TO_EDITION.items():
- if pill_cls in classes:
- return edition_name
- return ""
-
-
-def _process_inline_pills(soup: Soup) -> None:
- """Replace inline edition pill spans with readable text.
-
- Consecutive pills (possibly separated by whitespace) are merged into a
- single parenthetical, e.g. ' (Headless, Experience)' instead of
- ' (Headless) (Experience)'.
- """
- for span in soup.find_all("span", class_="pill--inline"):
- if span.parent is None: # already consumed as part of a previous run
- continue
- edition = _pill_edition(span)
- if not edition:
- continue
-
- # Collect the run of pills that follow, skipping whitespace between them.
- editions = [edition]
- consumed = []
- node = span.next_sibling
- pending_whitespace = []
- while node is not None:
- if isinstance(node, NavigableString) and not node.strip():
- pending_whitespace.append(node)
- node = node.next_sibling
- continue
- next_edition = _pill_edition(node)
- if not next_edition:
- break
- editions.append(next_edition)
- consumed += pending_whitespace + [node]
- pending_whitespace = []
- node = node.next_sibling
-
- for extra_node in consumed:
- extra_node.extract()
- span.replace_with(soup.new_string(f" ({', '.join(editions)})"))
-
-
def _process_release_note_tags(soup: Soup) -> None:
"""Append edition labels from release-note__tags divs to their preceding heading.
@@ -399,20 +333,6 @@ def _process_cards(soup: Soup) -> None:
# Markdown post-processing (applied by hooks.py to the generated Markdown)
# ---------------------------------------------------------------------------
-def editions_from_frontmatter(frontmatter: dict) -> list:
- """Map ``edition``/``editions`` frontmatter values to display names."""
-
- def _to_list(value):
- if isinstance(value, list):
- return value
- if isinstance(value, str):
- return value.split()
- return []
-
- all_editions = _to_list(frontmatter.get("edition")) + _to_list(frontmatter.get("editions") or [])
- return [FRONTMATTER_EDITION_DISPLAY.get(e, e) for e in all_editions if e]
-
-
_MACRO_RE = re.compile(r"\[\[=\s*(\w+)\s*=\]\]")
@@ -431,9 +351,9 @@ def _substitute(match: re.Match) -> str:
def inject_page_metadata(
- content: str, description: str = "", editions: list = (), llms_txt_url: str = "/llms.txt"
+ content: str, description: str = "", llms_txt_url: str = "/llms.txt"
) -> str:
- """Insert the llms.txt pointer, page description, and an 'Editions: X, Y' line after the first h1 heading.
+ """Insert the llms.txt pointer and page description after the first h1 heading.
``llms_txt_url`` must be the absolute URL of *this site's own* llms.txt
(e.g. via ``urljoin(base_url, "llms.txt")``), not a hardcoded root-relative
@@ -443,8 +363,6 @@ def inject_page_metadata(
metadata_lines = ["", f"> For the complete documentation index, see [llms.txt]({llms_txt_url})."]
if description:
metadata_lines += ["", description]
- if editions:
- metadata_lines += ["", "Editions: " + ", ".join(editions)]
lines = content.split("\n")
for i, line in enumerate(lines):