Skip to content

[ai_docs] extend dropdown options#41

Merged
eshaben merged 15 commits intomainfrom
eshaben/extend-dropdown-options
Apr 9, 2026
Merged

[ai_docs] extend dropdown options#41
eshaben merged 15 commits intomainfrom
eshaben/extend-dropdown-options

Conversation

@eshaben
Copy link
Copy Markdown
Collaborator

@eshaben eshaben commented Apr 3, 2026

✨ This PR paves the way for us to change the styling of the dropdowns in Polkadot, while keeping the old styling in tact for other projects. ✨


This pull request adds new customization options for the AI actions widget in the documentation site, allowing users to choose between "split" and "dropdown" widget styles and to specify a custom anchor location for widget placement. It also improves the flexibility of CSS targeting for these widgets and updates the documentation accordingly. Additionally, the code has been refactored to support these new options and to clean up related logic.

AI Actions Widget Customization:

  • Added support for a new ai_page_actions_style option ("split" or "dropdown") and a customizable ai_page_actions_dropdown_label in both the plugin configuration (plugins/ai_docs/plugin.py) and the widget HTML generation (ai_file_utils.py). This allows users to choose between a split-button style (copy button + dropdown) and a single dropdown button with a custom label. [1] [2] [3] [4]
  • Introduced the ai_page_actions_anchor option, letting users specify a CSS class where the widget should be injected instead of the default H1 wrapper. The plugin now supports injecting the widget into all matching elements, with fallback and debug logging if none are found. [1] [2] [3] [4]

Codebase Refactoring and Consistency:

  • Refactored widget HTML generation in ai_file_utils.py to support both widget styles, extra CSS classes, and improved code structure. [1] [2] [3]
  • Updated plugin logic to consistently apply extra CSS classes (ai-file-actions-container--table) for widgets in tables, improving CSS targeting and maintainability. [1] [2]

Other Cleanups:

  • Removed the unused _generate_mcp_section method and related code from the AI resources page plugin, as it is no longer needed. [1] [2]

eshaben added 3 commits April 2, 2026 22:39
- Add ability to anchor the per page widget to any class
- Add ability to specify between two different styles of dropdown menus
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 extends the ai_docs plugin’s per-page AI actions widget to support configurable layout (“split” vs “dropdown”), a configurable injection anchor (by CSS class), and more precise CSS targeting via modifier classes, with accompanying refactors, docs updates, and tests.

Changes:

  • Added ai_page_actions_anchor, ai_page_actions_style, and ai_page_actions_dropdown_label options to ai_docs, including new anchor-based injection behavior.
  • Refactored AIFileUtils.generate_dropdown_html() to support both “split” and “dropdown” widget styles plus optional extra container classes.
  • Updated documentation and tests; removed the legacy MCP section generation from the deprecated ai_resources_page plugin/tests.

Reviewed changes

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

Show a summary per file
File Description
plugins/ai_docs/plugin.py Adds new config options, refactors widget HTML creation, and introduces anchor-class injection plus table widget class modifiers.
helper_lib/ai_file_utils/ai_file_utils.py Implements style, dropdown_label, and extra_classes for widget HTML generation.
docs/ai-docs.md Documents new ai_docs configuration options and behavior.
docs/ai-page-actions.md Adds CSS class/modifier documentation and styling examples.
plugins/ai_resources_page/plugin.py Removes the legacy MCP section generation from the deprecated plugin.
tests/ai_docs/test_ai_docs.py Updates placeholder expectations and adds coverage for anchor + style options.
tests/ai_file_utils/test_ai_file_utils.py Adds coverage for new generate_dropdown_html() style/label/class behavior.
tests/ai_resources_page/test_ai_resources_page.py Removes MCP section tests aligned with deprecated plugin behavior change.

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

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

@eshaben
Copy link
Copy Markdown
Collaborator Author

eshaben commented Apr 7, 2026

To test out the dropdown view and use of a custom anchor, spin this up with these branches:

polkadot-mkdocs: eshaben/header-page-info
polkadot-docs: eshaben/header-page-info

Should also be tested using other configs, for example:

  • Split view, no custom anchor
  • Split view, custom anchor
  • Dropdown view: no custom anchor

But remember as you test things out, it might not look perfect, that's because the CSS would need to be adapted for different scenarios. The above branches are catered to look good with the custom anchor. The old default (split view, no custom anchor) don't look good on the above Polkadot branches, but could be tested with Moonbeam/kluster or using Polkadot master/main.

@0xlukem 0xlukem self-assigned this Apr 7, 2026
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.

Great work ❤️ I tested all the versions and edge cases I could think of, and it works. I left just two suggestions at the UI level that we can address, and that's it

@eshaben eshaben requested a review from 0xlukem April 8, 2026 19:09
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.

🚢

@eshaben eshaben merged commit fa1e1b2 into main Apr 9, 2026
@eshaben eshaben deleted the eshaben/extend-dropdown-options branch April 9, 2026 02:03
@eshaben eshaben mentioned this pull request Apr 9, 2026
5 tasks
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