-
Notifications
You must be signed in to change notification settings - Fork 82
Added "View as markdown" button #3161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| /vendor/ | ||
| **/.DS_Store | ||
| __pycache__/* | ||
| hooks/__pycache__/* | ||
| **/__pycache__ | ||
| /site/ | ||
| **/.idea/ | ||
| .php-cs-fixer.cache | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ | |
| <a href="release_notes/ibexa_dxp_v5.0/">Release notes</a> | ||
| </div> | ||
| <div class="notification__image"> | ||
| <img src="images/notification-latest-release.svg" alt="The latest release" /> | ||
| <img src="images/notification-latest-release.svg" alt="" /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Icons don't need alt text |
||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
@@ -97,7 +97,7 @@ | |
| <a href="ibexa_products/editions/#lts-updates">Discover other LTS Updates</a> | ||
| </div> | ||
| <div class="notification__image"> | ||
| <img src="images/notification-lts-update.svg" alt="LTS Update" /> | ||
| <img src="images/notification-lts-update.svg" alt="" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For all files in perso: exclude them from the Markdown-generated content (llms.txt, llms-full.txt, page actions) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ Then, in the content view configuration, add the configuration under `content_qu | |
|
|
||
| The `match` configuration matches both the content type and the identifier of the Content query field. | ||
|
|
||
| Finally, in the template `templates/themes/<my_theme/content_query/blog_posts.html.twig`, render all results of the query: | ||
| Finally, in the template `templates/themes/<my_theme>/content_query/blog_posts.html.twig`, render all results of the query: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lack of closing |
||
|
|
||
| ``` html+twig | ||
| [[= include_file('code_samples/front/list_content/templates/themes/my_theme/full/blog_post.html.twig') =]] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| """ | ||
| MkDocs hooks for Ibexa developer documentation. | ||
|
|
||
| - Keeps the llmstxt plugin's ``sections`` config in sync with the ``nav`` | ||
| defined in ``mkdocs.yml``. | ||
| - Post-processes the Markdown generated by the llmstxt plugin. | ||
|
|
||
| All content transformations live in ``llmstxt_preprocess.py``; this module is | ||
| only MkDocs event glue. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| from pathlib import Path, PurePosixPath | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| _here = Path(__file__).parent | ||
| if str(_here) not in sys.path: | ||
| sys.path.insert(0, str(_here)) | ||
|
|
||
| from llmstxt_preprocess import ( | ||
| absolutize_image_urls, | ||
| editions_from_frontmatter, | ||
| expand_macros, | ||
| inject_page_metadata, | ||
| renumber_ordered_lists, | ||
| ) | ||
| from update_llmstxt_config import convert_nav_to_llmstxt_sections | ||
|
|
||
| if TYPE_CHECKING: | ||
| from mkdocs.config.defaults import MkDocsConfig | ||
| from mkdocs.structure.pages import Page | ||
|
|
||
|
|
||
| def on_config(config: "MkDocsConfig") -> None: | ||
| """Populate llmstxt sections from nav before the build starts. | ||
|
|
||
| The llmstxt plugin reads ``config.sections`` in its ``on_files`` event, | ||
| which fires after ``on_config``, so injecting here is the right place. | ||
| """ | ||
| nav = config.get("nav") | ||
| if not nav: | ||
| return | ||
|
|
||
| llmstxt = config["plugins"].get("llmstxt") | ||
| if llmstxt is None: | ||
| return | ||
|
|
||
| docs_dir = Path(config["docs_dir"]) | ||
| llmstxt.config.sections = convert_nav_to_llmstxt_sections(nav, docs_dir) | ||
|
|
||
|
|
||
| def on_page_content(html: str, *, page: "Page", config: "MkDocsConfig", **kwargs) -> None: | ||
| """Reformat the Markdown content generated by the llmstxt plugin for this page. | ||
|
|
||
| Hooks run after plugins for every event, so at this point the llmstxt | ||
| plugin has already generated Markdown and stored it in ``_md_pages``. | ||
| We reformat here so the plugin writes the corrected content in its own | ||
| ``on_post_build`` (which also runs before ours, for the same reason). | ||
| """ | ||
| llmstxt = config["plugins"].get("llmstxt") | ||
| if llmstxt is None: | ||
| return | ||
|
|
||
| src_uri = page.file.src_uri | ||
| page_info = llmstxt._md_pages.get(src_uri) | ||
| if page_info is None: | ||
| return | ||
|
|
||
| frontmatter = _read_frontmatter(page, config) | ||
| editions = editions_from_frontmatter(frontmatter) | ||
| description = expand_macros(str(frontmatter.get("description") or ""), config.get("extra") or {}) | ||
| if "[[=" in description: | ||
| # Unresolved macros must not leak into the output. | ||
| description = "" | ||
| content = inject_page_metadata(page_info.content, description, editions) | ||
| content = renumber_ordered_lists(content) | ||
| # Same base URL and page directory the plugin uses for making link hrefs absolute. | ||
| page_dir = PurePosixPath(page.file.dest_uri).parent.as_posix() | ||
| content = absolutize_image_urls(content, llmstxt._base_url, page_dir) | ||
| if content != page_info.content: | ||
| llmstxt._md_pages[src_uri] = page_info._replace(content=content) | ||
|
|
||
|
|
||
| def _read_frontmatter(page: "Page", config: "MkDocsConfig") -> dict: | ||
| """Read the page's YAML frontmatter from its source file.""" | ||
| src_path = Path(config["docs_dir"]) / page.file.src_path | ||
| try: | ||
| from mkdocs.utils import meta as mkdocs_meta | ||
| with open(src_path, encoding="utf-8") as f: | ||
| raw = f.read() | ||
| _, frontmatter = mkdocs_meta.get_data(raw) | ||
| return frontmatter | ||
| except Exception: | ||
| return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running tests for the LLM Markdown converter