Skip to content

Add hook to automatically create index tables#272

Open
eshaben wants to merge 9 commits into
mainfrom
eshaben/auto-index
Open

Add hook to automatically create index tables#272
eshaben wants to merge 9 commits into
mainfrom
eshaben/auto-index

Conversation

@eshaben
Copy link
Copy Markdown
Collaborator

@eshaben eshaben commented May 27, 2026

This pull request introduces a new MkDocs hook that automatically generates index tables for documentation sections and removes the old scripts/generate_index_pages.py script. The new hook is enabled in the MkDocs configuration, providing a more robust, configurable, and maintainable solution for generating index tables based on the navigation structure and page frontmatter.

Replacement of index page generation with a new MkDocs hook:

  • New feature: Automatic index table generation

    • Adds hooks/auto_index_table.py, a MkDocs hook that replaces special marker blocks in Markdown files with generated tables of page links, descriptions, tools, and difficulty, based on .nav.yml files and page frontmatter. It supports configuration via YAML in the marker, custom columns, extra rows, and per-row overrides.
    • Enables the new hook in the MkDocs configuration by adding it to the hooks list in mkdocs.yml.
  • Codebase cleanup:

    • Removes the old scripts/generate_index_pages.py script, which previously handled index page generation but is now superseded by the new hook.

Goes with: polkadot-developers/polkadot-docs#1689


P.S. @0xlukem - now we could even use these shorter descriptions for social cards? Something we discussed doing a while back. Not sure if we have the ability to use a fallback description if short_description doesn't exist? Anyways.... food for thought...

Copilot AI review requested due to automatic review settings May 27, 2026 03:40
@eshaben eshaben changed the title Add auto index Adds hook to automatically create index tables May 27, 2026
@eshaben eshaben changed the title Adds hook to automatically create index tables Add hook to automatically create index tables May 27, 2026
@eshaben eshaben requested a review from 0xlukem May 27, 2026 03:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 replaces the legacy index-page generation script with a MkDocs hook that generates index tables during builds, and wires that hook into the site configuration.

Changes:

  • Added hooks/auto_index_table.py to replace <!-- INDEX TABLE START --> ... <!-- INDEX TABLE END --> blocks with generated tables derived from .nav.yml and page frontmatter.
  • Enabled the new hook in mkdocs.yml.
  • Removed legacy tooling (scripts/generate_index_pages.py) and updated build tooling (Makefile target/help).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
hooks/auto_index_table.py Introduces the new hook that parses marker blocks and generates index tables from nav/frontmatter data.
mkdocs.yml Enables the new hook in the MkDocs build pipeline.
scripts/generate_index_pages.py Removes the superseded legacy index generation script.
Makefile Removes the gen-cookbook target/help entry as part of tooling cleanup.

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

Comment thread hooks/auto_index_table.py
Comment thread hooks/auto_index_table.py
Comment thread hooks/auto_index_table.py Outdated
Comment thread hooks/auto_index_table.py
Comment thread hooks/auto_index_table.py
Comment thread hooks/auto_index_table.py
Comment thread Makefile
Copy link
Copy Markdown
Contributor

@0xlukem 0xlukem left a comment

Choose a reason for hiding this comment

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

The hook works great, just need to resolve some minor merge conflicts

@eshaben eshaben requested a review from 0xlukem June 1, 2026 17:39
Copy link
Copy Markdown
Contributor

@0xlukem 0xlukem left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants