Skip to content

docs: add comprehensive plugin creation guide#1356

Open
sansyrox wants to merge 1 commit intomainfrom
docs/plugin-creation-guide
Open

docs: add comprehensive plugin creation guide#1356
sansyrox wants to merge 1 commit intomainfrom
docs/plugin-creation-guide

Conversation

@sansyrox
Copy link
Copy Markdown
Member

@sansyrox sansyrox commented Mar 27, 2026

Summary

  • Expands the Plugins documentation page with a comprehensive guide on creating Robyn plugins
  • Documents three plugin patterns: middleware-based, SubRouter-based, and lifecycle-based
  • Includes package structure, naming conventions, and testing guidance
  • Preserves the existing Rate Limit plugin documentation
  • Adds "Creating Plugins" sub-navigation link

Closes #686

Test plan

  • Verify the expanded page renders correctly at /documentation/en/plugins
  • Verify "Creating Plugins" navigation link scrolls to the correct section
  • Verify all code examples are syntactically correct

Made with Cursor

Summary by CodeRabbit

  • Documentation
    • Added "Response Objects" API reference to navigation.
    • Introduced comprehensive "Creating Your Own Plugin" guide featuring code examples, package structure, dependency declarations, naming conventions, and testing outlines.
    • Reorganized plugin documentation with new "Community Plugins" section.
    • Added multilingual support (English and Chinese) for navigation items and documentation content.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
robyn Ready Ready Preview, Comment Mar 27, 2026 0:51am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This PR adds comprehensive documentation for Robyn plugin creation alongside navigation updates. It expands the Plugins page with a complete guide on creating custom plugins using Python packages and Robyn's public APIs, introduces a "Community Plugins" section, and updates the navigation menu to surface the new plugin documentation and a Response Objects API reference page with full English and Chinese localization.

Changes

Cohort / File(s) Summary
Navigation Updates
docs_src/src/components/documentation/Navigation.jsx
Added two new navigation items: "Response Objects" under API Reference and "Creating Plugins" under Plugins. Updated translation mappings for both English (en) and Chinese (zh) locales to provide localized labels for the new entries.
Plugin Documentation
docs_src/src/pages/documentation/en/plugins.mdx
Rewrote plugin introduction to define plugins as regular Python packages using Robyn's public APIs. Added comprehensive "Creating Your Own Plugin" guide with code examples covering middleware patterns, SubRouter usage, lifecycle events, package structure, dependency declaration via pyproject.toml, naming conventions, and testing outline. Reorganized sections including new "Community Plugins" header and updated rate-limit plugin documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop hop, the docs now shine so bright!
New plugins guide, pure delight,
Navigation springs anew,
From English words to Chinese too,
Framework knowledge takes its flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a comprehensive plugin creation guide to the documentation.
Description check ✅ Passed The PR description covers the summary, changes made, linked issue, and test plan, matching the template requirements.
Linked Issues check ✅ Passed The PR fully addresses issue #686 by providing comprehensive plugin creation documentation, patterns, structure guidance, naming conventions, and testing outline.
Out of Scope Changes check ✅ Passed All changes are scoped to documentation: navigation updates, plugin guide content, and translations. No unrelated code modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/plugin-creation-guide

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs_src/src/pages/documentation/en/plugins.mdx (1)

101-116: Make the lifecycle example copy-paste runnable.

At Line 109, create_pool(...) is referenced without definition/import. Adding a minimal import (or explicit placeholder comment) will prevent immediate NameError for readers trying the snippet.

Proposed docs snippet adjustment
 from robyn import Robyn
+from my_db_library import create_pool  # replace with your actual DB pool factory
 
 def register_db_plugin(app: Robyn, connection_string: str):
     """A plugin that manages a database connection pool."""
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_src/src/pages/documentation/en/plugins.mdx` around lines 101 - 116, The
example uses create_pool(connection_string) but that symbol isn't defined or
imported, causing a NameError for readers; update the documentation snippet for
register_db_plugin to include a minimal import or a short placeholder comment
for create_pool (or show an explicit async def create_pool(...) stub) so the
startup handler init_db can call a defined function, and reference the
register_db_plugin, init_db, and close_db symbols to locate where to add the
import/stub.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs_src/src/components/documentation/Navigation.jsx`:
- Around line 360-363: Navigation uses hardcoded '/documentation/en/...' hrefs
(e.g., the entry with href '/documentation/en/needs-help') and
getLocalizedHref() (referenced at line ~573) blindly converts them to
'/documentation/zh/...' causing dead links; update the navigation data or
getLocalizedHref() so that either (a) navigation items that have no Chinese
equivalent are left pointing to the English URL (i.e., implement a fallback that
checks if the localized path exists and returns the original
'/documentation/en/...' when missing) or (b) mark specific nav entries (like the
'needs-help' and 'plugins#creating-your-own-plugin' items) with a flag to always
link to English; change getLocalizedHref() to perform the existence check or
honor that flag and return the correct fallback URL.

---

Nitpick comments:
In `@docs_src/src/pages/documentation/en/plugins.mdx`:
- Around line 101-116: The example uses create_pool(connection_string) but that
symbol isn't defined or imported, causing a NameError for readers; update the
documentation snippet for register_db_plugin to include a minimal import or a
short placeholder comment for create_pool (or show an explicit async def
create_pool(...) stub) so the startup handler init_db can call a defined
function, and reference the register_db_plugin, init_db, and close_db symbols to
locate where to add the import/stub.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d932d50-66d5-4685-971f-9d936fe34e48

📥 Commits

Reviewing files that changed from the base of the PR and between 9e1fd74 and 2587a16.

📒 Files selected for processing (3)
  • docs_src/src/components/documentation/Navigation.jsx
  • docs_src/src/pages/documentation/en/needs-help.mdx
  • docs_src/src/pages/documentation/en/plugins.mdx

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs_src/src/components/documentation/Navigation.jsx`:
- Around line 235-238: The navigation array in Navigation.jsx contains an entry
with href '/documentation/en/api_reference/response-objects' which points to a
non-existent page; either remove that object from the navigation list (the
object with title 'Response Objects' and href
'/documentation/en/api_reference/response-objects') or create the missing
documentation page(s) (add a response-objects page under the docs content for
English and its localized counterpart so getLocalizedHref() resolves correctly);
ensure the new page path matches the href exactly and include it in the docs
build so clicking the link does not 404.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5bbd6185-a732-4b8e-8c53-fccb7fe91376

📥 Commits

Reviewing files that changed from the base of the PR and between 2587a16 and 9f98e53.

📒 Files selected for processing (2)
  • docs_src/src/components/documentation/Navigation.jsx
  • docs_src/src/pages/documentation/en/plugins.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs_src/src/pages/documentation/en/plugins.mdx

Comment on lines +235 to +238
{
href: '/documentation/en/api_reference/response-objects',
title: 'Response Objects',
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the Response Objects page exists for both languages

echo "=== English Response Objects page ==="
fd 'response-objects\.mdx$' docs_src/src/pages/documentation/en --type f || echo "Not found in en/"

echo ""
echo "=== Chinese Response Objects page ==="
fd 'response-objects\.mdx$' docs_src/src/pages/documentation/zh --type f || echo "Not found in zh/"

echo ""
echo "=== All response-objects files ==="
fd 'response-objects' docs_src/src/pages/documentation --type f

Repository: sparckles/Robyn

Length of output: 171


🏁 Script executed:

# Check the documentation directory structure to understand how pages are organized
echo "=== Documentation directory structure ==="
find docs_src/src/pages/documentation -type d | head -20

echo ""
echo "=== Check for api_reference directory ==="
fd 'api_reference' docs_src/src/pages/documentation --type d

echo ""
echo "=== All files in api_reference if it exists ==="
find docs_src/src/pages/documentation -name 'api_reference' -type d -exec find {} -type f \;

echo ""
echo "=== Check for any response-related files ==="
rg -l 'response' docs_src/src/pages/documentation --type mdx | head -20

Repository: sparckles/Robyn

Length of output: 4630


🏁 Script executed:

# Search for any response-objects references in the entire codebase
echo "=== Search for response-objects references ==="
rg 'response-objects' docs_src --type-list | grep -i mdx

echo ""
echo "=== Search for response-objects in all file types ==="
rg -l 'response-objects' docs_src

echo ""
echo "=== Check if response-objects.mdx exists anywhere ==="
find docs_src -name '*response*objects*' -o -name '*response-object*'

echo ""
echo "=== Check the git status to see added/modified files ==="
git status --short | grep -i response || echo "No response files in git status"

Repository: sparckles/Robyn

Length of output: 765


🏁 Script executed:

# Check the Navigation.jsx file to see the context of the response-objects link
echo "=== Navigation.jsx around lines 235-238 ==="
sed -n '230,245p' docs_src/src/components/documentation/Navigation.jsx

echo ""
echo "=== Check if there are any other response-objects references ==="
grep -n 'response-objects' docs_src/src/components/documentation/Navigation.jsx

Repository: sparckles/Robyn

Length of output: 703


Create the Response Objects documentation page before adding the navigation link.

The navigation entry at line 236 links to /documentation/en/api_reference/response-objects, but this page does not exist in the codebase. The getLocalizedHref() function will convert this to /documentation/zh/api_reference/response-objects for Chinese users, but neither version exists. Users will encounter 404 errors when clicking this link. Either create the documentation file or remove the navigation entry.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_src/src/components/documentation/Navigation.jsx` around lines 235 - 238,
The navigation array in Navigation.jsx contains an entry with href
'/documentation/en/api_reference/response-objects' which points to a
non-existent page; either remove that object from the navigation list (the
object with title 'Response Objects' and href
'/documentation/en/api_reference/response-objects') or create the missing
documentation page(s) (add a response-objects page under the docs content for
English and its localized counterpart so getLocalizedHref() resolves correctly);
ensure the new page path matches the href exactly and include it in the docs
build so clicking the link does not 404.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 27, 2026

Merging this PR will not alter performance

✅ 189 untouched benchmarks


Comparing docs/plugin-creation-guide (9f98e53) with main (9e1fd74)

Open in CodSpeed

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.

add documentation regarding the plugin creation and create a create plugin template

1 participant