Skip to content

Test#56

Merged
5hojib merged 3 commits intodevfrom
test
Feb 9, 2026
Merged

Test#56
5hojib merged 3 commits intodevfrom
test

Conversation

@5hojib
Copy link
Member

@5hojib 5hojib commented Feb 9, 2026

Summary by Sourcery

Automate API docs generation from the codebase and align documentation, type exports, and method groupings with the current Electrogram feature set.

New Features:

  • Automatically discover and generate documentation pages for client methods, types, bound methods, and enums directly from the source tree.
  • Introduce a dedicated Stories method group for story-related operations and expose it through the main methods namespace.
  • Export all public Telegram types, including stories-related types, from the types package for easier importing.
  • Generate API enum documentation pages and toctrees based on the enums library.

Enhancements:

  • Refine the HTML theme configuration and custom CSS to use an indigo color scheme, improve readability, and better style links, code blocks, and tables.
  • Simplify the users methods mixin by moving story-related methods into the new Stories group and cleaning up its composition.

Documentation:

  • Add social links for GitHub and Telegram to the documentation theme header and update API reference structure for methods, types, bound methods, and enums to match the new generator.

5hojib and others added 3 commits February 9, 2026 11:39
- Automated documentation category generation in `compiler/docs/compiler.py` using directory structure and AST discovery.
- Reorganized `pyrogram/methods/` and `pyrogram/types/` into subdirectories (stories, bots, bot_commands, etc.) for better categorization.
- Enhanced `docs/source/conf.py` with `sphinx_immaterial` theme, indigo palette, and social links.
- Improved `docs/source/_static/css/custom.css` with better dark mode support and styled UI badges.
- Maintained backward compatibility via proxy imports and comprehensive `__all__` in `pyrogram/types/__init__.py`.
- Updated `pyrogram/filters.py` to use proper type imports from the package.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Signed-off-by: 5hojib <yesiamshojib@gmail.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 9, 2026

Reviewer's Guide

Refactors documentation generation for Pyrogram/Electrogram APIs to be dynamically discovered from the codebase (methods, types, bound methods, enums), modernizes Sphinx/MkDocs styling and theme configuration, and updates type/method modules to align with new docs structure (including stories methods and expanded types exports).

Class diagram for updated methods and types structure

classDiagram
    direction LR

    class Methods {
    }

    class Users {
    }

    class Stories {
    }

    class DeleteAccount {
    }
    class BlockUser {
    }
    class GetCommonChats {
    }
    class GetChatPhotos {
    }
    class GetChatPhotosCount {
    }
    class SetProfilePhoto {
    }
    class DeleteProfilePhotos {
    }
    class GetUsers {
    }
    class GetMe {
    }
    class SetUsername {
    }
    class UnblockUser {
    }
    class UpdateBirthday {
    }
    class UpdatePersonalChat {
    }
    class UpdateProfile {
    }
    class GetDefaultEmojiStatuses {
    }
    class SetEmojiStatus {
    }

    class DeleteStories {
    }
    class EditStory {
    }
    class ExportStoryLink {
    }
    class ForwardStory {
    }
    class GetAllStories {
    }
    class GetPeerStories {
    }
    class GetStories {
    }
    class GetUserStoriesHistory {
    }
    class SendStory {
    }

    Methods <|-- Users
    Methods <|-- Stories

    Users <|-- BlockUser
    Users <|-- DeleteAccount
    Users <|-- GetCommonChats
    Users <|-- GetChatPhotos
    Users <|-- GetChatPhotosCount
    Users <|-- SetProfilePhoto
    Users <|-- DeleteProfilePhotos
    Users <|-- GetUsers
    Users <|-- GetMe
    Users <|-- SetUsername
    Users <|-- UnblockUser
    Users <|-- UpdateBirthday
    Users <|-- UpdatePersonalChat
    Users <|-- UpdateProfile
    Users <|-- GetDefaultEmojiStatuses
    Users <|-- SetEmojiStatus

    Stories <|-- DeleteStories
    Stories <|-- EditStory
    Stories <|-- ExportStoryLink
    Stories <|-- ForwardStory
    Stories <|-- GetAllStories
    Stories <|-- GetPeerStories
    Stories <|-- GetStories
    Stories <|-- GetUserStoriesHistory
    Stories <|-- SendStory

    class TypesPackage {
        <<module>>
        +__all__ exports
        +users_and_chats
        +messages_and_media
        +bots_and_keyboards
        +payments
        +stories
    }

    class StoriesTypesModule {
        <<module>>
        +Story
        +StoryDeleted
        +StoryForwardHeader
        +StorySkipped
        +StoryViews
        +StoriesPrivacyRules
        +MediaArea
        +MediaAreaChannelPost
        +MediaAreaCoordinates
        +InputMediaArea
        +InputMediaAreaChannelPost
    }

    TypesPackage o-- StoriesTypesModule
Loading

File-Level Changes

Change Details Files
Refactor core docs compiler to dynamically discover and generate methods, types, bound methods, and enums documentation from the source tree instead of static templates.
  • Introduce path constants for methods, types, and enums libraries, with overrides for local vs repo-relative runs.
  • Rename generic generate() helper to generate_raw() and adjust start() to use it for raw API docs.
  • Replace hard-coded methods, types, and bound methods category definitions with AST-based discovery of methods, classes, and bound methods from pyrogram/methods and pyrogram/types.
  • Add support for enums discovery from pyrogram/enums and generate enums index and per-enum rst files.
  • Generate methods, types, bound-methods, and enums .rst trees directly in compiler/docs/compiler.py instead of using template files, and remove the template-based system.
compiler/docs/compiler.py
Align runtime paths for docs compilation with new discovery-based generator.
  • Update start() development-mode path constants to include methods, types library, and enums library paths.
  • Ensure HOME and destination paths remain correct for repo-local docs builds.
compiler/docs/compiler.py
Expand and explicitly manage the public types surface and internal categories to support docs auto-generation.
  • Import additional type subpackages (stories, bots, bot_commands, etc.) in pyrogram.types and populate a comprehensive all list of exposed type names.
  • Adjust multiple type subpackage init.py files to be compatible with new discovery logic (categories like bots_and_keyboards, input_media, messages_and_media, etc.).
pyrogram/types/__init__.py
pyrogram/types/bots_and_keyboards/__init__.py
pyrogram/types/input_media/__init__.py
pyrogram/types/messages_and_media/__init__.py
pyrogram/types/bot_commands/__init__.py
pyrogram/types/bots/__init__.py
pyrogram/types/stories/__init__.py
Restructure methods mixins to move stories-related methods into a dedicated Stories mixin and update aggregate Methods composition accordingly.
  • Create pyrogram/methods/stories package with a Stories mixin composing all story-related method mixins (delete, edit, export link, forward, get, send, etc.).
  • Update pyrogram/methods/init.py Methods class to include Stories in its MRO.
  • Remove story-related mixins from the Users methods mixin, leaving only user/account-related methods there.
pyrogram/methods/users/__init__.py
pyrogram/methods/__init__.py
pyrogram/methods/stories/__init__.py
Modernize documentation styling and theme configuration, and integrate social links.
  • Retheme MkDocs/Sphinx Material primary/accent colors to indigo for both light and dark schemes in docs/source/conf.py.
  • Add social icon links for GitHub and Telegram to the docs theme configuration.
  • Improve custom CSS for links, code blocks, tables, and the .usable-by badge, including dark theme variants and Material color variable usage.
docs/source/conf.py
docs/source/_static/css/custom.css
Align pre-generated enums documentation with new enums generation model and remove unused templates.
  • Adjust or regenerate enums .rst files under docs/source/api/enums to match the new enums layout and content (including index).
  • Remove obsolete compiler/docs/template/*.rst files in favor of inline generation logic.
  • Delete an unused enums cleanup.html artifact.
docs/source/api/enums/*.rst
docs/source/api/enums/index.rst
docs/source/api/enums/cleanup.html
compiler/docs/template/bound-methods.rst
compiler/docs/template/enums.rst
compiler/docs/template/methods.rst
compiler/docs/template/types.rst

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link

Summary of Changes

Hello @5hojib, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a major architectural improvement to the documentation generation system, transitioning from a manual, list-based approach to an automated, code-driven discovery mechanism. This change enhances the accuracy and maintainability of the API reference documentation by directly reflecting the library's structure. Concurrently, it streamlines the internal organization of various library components, particularly those related to stories and bots, into more logical and distinct modules. The user-facing documentation also receives a visual refresh with updated styling and theme colors.

Highlights

  • Documentation Generation Refactor: The documentation generation logic in compiler.py has been significantly overhauled. It now dynamically discovers methods, types, bound methods, and enums by parsing Python's Abstract Syntax Tree (AST) instead of relying on static, hardcoded lists. This change makes the documentation generation more robust and less prone to manual errors when new components are added or moved.
  • Module Reorganization: Several modules within pyrogram/methods and pyrogram/types have been reorganized. Story-related methods and types, as well as bot-related and bot command-related types, have been moved into dedicated subdirectories (pyrogram/methods/stories, pyrogram/types/stories, pyrogram/types/bots, pyrogram/types/bot_commands) to improve code structure and maintainability.
  • Documentation Templates Removal: The static .rst template files used for generating API documentation indices (e.g., methods.rst, types.rst) have been removed. Their content is now dynamically generated by the refactored compiler.py script, ensuring consistency and reducing redundancy.
  • CSS and Theme Updates: The documentation's CSS (custom.css) has been updated to improve the visual appearance of elements like 'usable-by' tags, links, code blocks, and tables. The Sphinx theme configuration (conf.py) has also been adjusted to use 'indigo' as the primary and accent color, and social links have been added.
Changelog
  • compiler/docs/compiler.py
    • Refactored pyrogram_api() to use dynamic discovery via AST parsing for methods, types, bound methods, and enums.
    • Introduced new path constants (METHODS_PATH, TYPES_LIB_PATH, ENUMS_LIB_PATH) and title mappings (METHODS_TITLES, TYPES_TITLES).
    • Renamed generate function to generate_raw.
    • Updated if __name__ == "__main__": block to include new path constants for dynamic generation.
  • compiler/docs/template/bound-methods.rst
    • Removed, as its content is now dynamically generated.
  • compiler/docs/template/enums.rst
    • Removed, as its content is now dynamically generated.
  • compiler/docs/template/methods.rst
    • Removed, as its content is now dynamically generated.
  • compiler/docs/template/types.rst
    • Removed, as its content is now dynamically generated.
  • docs/source/_static/css/custom.css
    • Updated primary and accent colors.
    • Improved styling for .usable-by elements, links, code blocks, and tables, including dark mode support.
  • docs/source/api/enums/AccentColor.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/BusinessSchedule.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatAction.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatEventAction.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatJoinType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatMemberStatus.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatMembersFilter.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ChatType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ClientPlatform.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/FolderColor.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ListenerTypes.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/MessageEntityType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/MessageMediaType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/MessageServiceType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/MessagesFilter.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/NextCodeType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ParseMode.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/PollType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/PrivacyKey.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ProfileColor.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ReactionType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/ReplyColor.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/SentCodeType.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/StoriesPrivacyRules.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/StoryPrivacy.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/UserStatus.rst
    • Removed .. raw:: html cleanup directive.
  • docs/source/api/enums/cleanup.html
    • Removed.
  • docs/source/api/enums/index.rst
    • Simplified header and updated toctree entries to use explicit references.
  • docs/source/conf.py
    • Changed primary and accent theme colors to 'indigo'.
    • Added social links for GitHub and Telegram.
  • pyrogram/methods/init.py
    • Imported and included Stories module in the Methods class.
  • pyrogram/methods/stories/init.py
    • Added new file to define the Stories class, consolidating story-related methods.
  • pyrogram/methods/users/init.py
    • Removed imports and inclusion of story-related methods from the Users class.
  • pyrogram/methods/users/delete_stories.py
    • Renamed and moved to pyrogram/methods/stories/delete_stories.py.
  • pyrogram/methods/users/edit_story.py
    • Renamed and moved to pyrogram/methods/stories/edit_story.py.
  • pyrogram/methods/users/export_story_link.py
    • Renamed and moved to pyrogram/methods/stories/export_story_link.py.
  • pyrogram/methods/users/forward_story.py
    • Renamed and moved to pyrogram/methods/stories/forward_story.py.
  • pyrogram/methods/users/get_all_stories.py
    • Renamed and moved to pyrogram/methods/stories/get_all_stories.py.
  • pyrogram/methods/users/get_peer_stories.py
    • Renamed and moved to pyrogram/methods/stories/get_peer_stories.py.
  • pyrogram/methods/users/get_stories.py
    • Renamed and moved to pyrogram/methods/stories/get_stories.py.
  • pyrogram/methods/users/get_stories_history.py
    • Renamed and moved to pyrogram/methods/stories/get_stories_history.py.
  • pyrogram/methods/users/send_story.py
    • Renamed and moved to pyrogram/methods/stories/send_story.py.
  • pyrogram/types/init.py
    • Added imports for new bot_commands and bots modules.
    • Significantly expanded the __all__ list to explicitly export all types.
  • pyrogram/types/bot_commands/init.py
    • Added new file to define the BotCommand related types.
  • pyrogram/types/bots/init.py
    • Added new file to define the Bot related types.
  • pyrogram/types/bots_and_keyboards/init.py
    • Updated imports to reflect the new locations of BotCommand and Bot related types.
  • pyrogram/types/bots_and_keyboards/bot_allowed.py
    • Renamed and moved to pyrogram/types/bots/bot_allowed.py.
  • pyrogram/types/bots_and_keyboards/bot_app.py
    • Renamed and moved to pyrogram/types/bots/bot_app.py.
  • pyrogram/types/bots_and_keyboards/bot_business_connection.py
    • Renamed and moved to pyrogram/types/bots/bot_business_connection.py.
  • pyrogram/types/bots_and_keyboards/bot_command.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_all_chat_administrators.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_all_group_chats.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_all_group_chats.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_all_private_chats.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_all_private_chats.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_chat.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_chat.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_chat_administrators.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_chat_administrators.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_chat_member.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_chat_member.py.
  • pyrogram/types/bots_and_keyboards/bot_command_scope_default.py
    • Renamed and moved to pyrogram/types/bot_commands/bot_command_scope_default.py.
  • pyrogram/types/bots_and_keyboards/bot_info.py
    • Renamed and moved to pyrogram/types/bots/bot_info.py.
  • pyrogram/types/input_media/init.py
    • Updated imports to reflect the new location of InputMediaArea and InputMediaAreaChannelPost in pyrogram/types/stories.
  • pyrogram/types/input_media/input_media_area.py
    • Renamed and moved to pyrogram/types/stories/input_media_area.py.
  • pyrogram/types/input_media/input_media_area_channel_post.py
    • Renamed and moved to pyrogram/types/stories/input_media_area_channel_post.py.
  • pyrogram/types/messages_and_media/init.py
    • Updated imports to reflect the new location of MediaArea, MediaAreaChannelPost, MediaAreaCoordinates, StoriesPrivacyRules, Story, StoryDeleted, StoryForwardHeader, StorySkipped, StoryViews in pyrogram/types/stories.
  • pyrogram/types/messages_and_media/media_area.py
    • Renamed and moved to pyrogram/types/stories/media_area.py.
  • pyrogram/types/messages_and_media/media_area_channel_post.py
    • Renamed and moved to pyrogram/types/stories/media_area_channel_post.py.
  • pyrogram/types/messages_and_media/media_area_coordinates.py
    • Renamed and moved to pyrogram/types/stories/media_area_coordinates.py.
  • pyrogram/types/messages_and_media/stories_privacy_rules.py
    • Renamed and moved to pyrogram/types/stories/stories_privacy_rules.py.
  • pyrogram/types/messages_and_media/story.py
    • Renamed and moved to pyrogram/types/stories/story.py.
  • pyrogram/types/messages_and_media/story_deleted.py
    • Renamed and moved to pyrogram/types/stories/story_deleted.py.
  • pyrogram/types/messages_and_media/story_forward_header.py
    • Renamed and moved to pyrogram/types/stories/story_forward_header.py.
  • pyrogram/types/messages_and_media/story_skipped.py
    • Renamed and moved to pyrogram/types/stories/story_skipped.py.
  • pyrogram/types/messages_and_media/story_views.py
    • Renamed and moved to pyrogram/types/stories/story_views.py.
  • pyrogram/types/stories/init.py
    • Added new file to define the Story related types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new dynamic API docs generation has quite a bit of duplicated path resolution logic (top-level constants vs overrides in start() and repeated if not path.exists(): path = Path('../../') / ... blocks); consider centralizing this into a single helper that resolves all base paths consistently to reduce confusion and future breakage when paths change.
  • The pyrogram/types/__init__.py __all__ list is now a very long manually maintained list that can easily get out of sync with the actual submodules; consider generating it programmatically from the imported subpackages (e.g., by aggregating their __all__ or using pkgutil) to improve maintainability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new dynamic API docs generation has quite a bit of duplicated path resolution logic (top-level constants vs overrides in `start()` and repeated `if not path.exists(): path = Path('../../') / ...` blocks); consider centralizing this into a single helper that resolves all base paths consistently to reduce confusion and future breakage when paths change.
- The `pyrogram/types/__init__.py` `__all__` list is now a very long manually maintained list that can easily get out of sync with the actual submodules; consider generating it programmatically from the imported subpackages (e.g., by aggregating their `__all__` or using `pkgutil`) to improve maintainability.

## Individual Comments

### Comment 1
<location> `compiler/docs/compiler.py:380-381` </location>
<code_context>
+        f.write(".. code-block:: python\n\n")
+        f.write("    from pyrogram import Client\n\n")
+        f.write('    app = Client("my_account")\n\n\n')
+        f.write("    @app.on_message()\n")
+        f.write("    def hello(client, message)\n")
+        f.write('        message.reply("hi")\n\n\n')
+        f.write("    app.run()\n\n")
</code_context>

<issue_to_address>
**issue (bug_risk):** Example code for bound methods has a syntax error (missing colon after the function definition).

The emitted example is invalid Python because `def hello(client, message)` is missing the colon. Please update that line in the generated string to `def hello(client, message):` so the example runs as-is when copied.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +380 to +381
f.write(" @app.on_message()\n")
f.write(" def hello(client, message)\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Example code for bound methods has a syntax error (missing colon after the function definition).

The emitted example is invalid Python because def hello(client, message) is missing the colon. Please update that line in the generated string to def hello(client, message): so the example runs as-is when copied.

@5hojib 5hojib merged commit f3174b5 into dev Feb 9, 2026
3 of 4 checks passed
@5hojib 5hojib deleted the test branch February 9, 2026 07:40
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a major and impressive refactoring of the documentation generation system. It moves from a hardcoded, manual approach to a dynamic one that discovers API methods, types, and enums from the source code. This significantly improves maintainability. The code organization is also improved by moving story-related methods and various types into their own dedicated packages. The changes are well-executed. I have a couple of suggestions for the documentation compiler script to improve its robustness and reduce code duplication.

Comment on lines +141 to +143
methods_path = Path(METHODS_PATH)
if not methods_path.exists():
methods_path = Path("../../") / METHODS_PATH

Choose a reason for hiding this comment

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

medium

The logic for resolving source paths is repeated for methods_path, types_lib_path (lines 173-175), and enums_lib_path (lines 224-226). To follow the DRY (Don't Repeat Yourself) principle and improve maintainability, this logic can be extracted into a helper function.

For example, you could define a helper function like this:

def get_source_path(relative_path: str) -> Path:
    """Gets the correct path whether run from root or compiler/docs."""
    path = Path(relative_path)
    if not path.exists():
        return Path("../../") / relative_path
    return path

And then use it like this:
methods_path = get_source_path(METHODS_PATH)

Comment on lines +187 to +188
except Exception:
continue

Choose a reason for hiding this comment

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

medium

Using except Exception: is too broad and can mask unexpected errors. It's better to catch a more specific exception. Since ast.parse() is being called, SyntaxError is the most likely and relevant exception to handle here. This also applies to other similar try...except blocks in this file (e.g., lines 204-207 and 233-236).

Suggested change
except Exception:
continue
except SyntaxError:
continue

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.

1 participant