Conversation
- 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>
Reviewer's GuideRefactors 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 structureclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @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
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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 repeatedif 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 usingpkgutil) 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| f.write(" @app.on_message()\n") | ||
| f.write(" def hello(client, message)\n") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| methods_path = Path(METHODS_PATH) | ||
| if not methods_path.exists(): | ||
| methods_path = Path("../../") / METHODS_PATH |
There was a problem hiding this comment.
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 pathAnd then use it like this:
methods_path = get_source_path(METHODS_PATH)
| except Exception: | ||
| continue |
There was a problem hiding this comment.
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).
| except Exception: | |
| continue | |
| except SyntaxError: | |
| continue |
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:
Enhancements:
Documentation: