Skip to content

Add glossary hook#270

Merged
eshaben merged 2 commits into
mainfrom
0xlukem/glossary-hook
May 27, 2026
Merged

Add glossary hook#270
eshaben merged 2 commits into
mainfrom
0xlukem/glossary-hook

Conversation

@0xlukem

@0xlukem 0xlukem commented May 14, 2026

Copy link
Copy Markdown
Contributor

This PR adds a hook that uses reference/glossary.md as the single source of truth for glossary terms. During the MkDocs build, it extracts glossary entries from headings and their definitions, filters out excluded terms from mkdocs.yml, and then adds tooltip HTML only to eligible paragraph text after Markdown has already been rendered to HTML. This avoids tooltips in headings, links, code, bold labels, and navigation cards while still using Material’s tooltip styling.

Hook Flow:

  1. reference/glossary.md

  2. The hook reads glossary headings and definitions.

  3. The hook builds an in-memory term map.

    Example: {"Runtime": "The runtime represents..."}

  4. The hook removes terms configured in mkdocs.yml.

    Example: exclude_terms: ["Polkadot"]

  5. MkDocs renders each Markdown page to HTML.

  6. The hook scans the rendered HTML.

  7. The hook only processes normal <p> paragraph text.

  8. The hook skips paragraphs inside .grid.cards.

  9. The hook skips text inside links, code, strong/bold, buttons, etc.

  10. The hook injects <abbr title="...">Term</abbr>.

  11. Material displays the tooltip.

This PR needs to be merged with this one: polkadot-developers/polkadot-docs#1686

Copilot AI review requested due to automatic review settings May 14, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a MkDocs hook that derives glossary terms from reference/glossary.md and injects Material-style tooltip markup into rendered paragraph HTML.

Changes:

  • Registers the new glossary abbreviations hook in mkdocs.yml.
  • Adds extra.glossary_tooltips.exclude_terms configuration.
  • Implements glossary parsing, term filtering, paragraph scanning, and <abbr title="..."> injection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
mkdocs.yml Enables the glossary hook and configures excluded tooltip terms.
hooks/glossary_abbreviations.py Adds glossary extraction and rendered HTML tooltip injection logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/glossary_abbreviations.py
@0xlukem 0xlukem requested a review from eshaben May 14, 2026 20:32

@eshaben eshaben left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you already did this, but we should review the docs repo to see anywhere that we are linking directly to the glossary page and remove those links in favor of the tooltips.

For example in the introduction the FRAME link goes to the glossary, so we should remove it: https://docs.polkadot.com/parachains/customize-runtime/#introduction

Comment thread hooks/glossary_abbreviations.py Outdated

@eshaben eshaben left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pls add docs to the beginning of the hook, like we do with other hooks?

@0xlukem 0xlukem requested a review from eshaben May 26, 2026 17:05
@eshaben eshaben merged commit 9b1e423 into main May 27, 2026
@eshaben eshaben deleted the 0xlukem/glossary-hook branch May 27, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants