- Comment - Represents a single comment.
- CommentGroup - Represents a group of comments.
Accessing with Comments
Comments can be accessed through any symbol or directly from code blocks. Each comment is represented by aComment
object that provides access to both the raw source and parsed text:
Editing Comments
Comments can be modified using theedit_text()
method, which handles formatting and delimiters automatically:
Comment Groups
Multiple consecutive comments are automatically grouped into aCommentGroup
, which can be edited as a single unit:
Working with Docstrings
Docstrings are special comments that document functions, classes, and modules. Graph-sitter provides similar APIs for working with docstrings:Adding Docstrings
You can add docstrings to any symbol that supports them:Language-Specific Formatting
Graph-sitter automatically handles language-specific docstring formatting:Editing Docstrings
Like comments, docstrings can be modified while preserving formatting:Comment Operations
Graph-sitter provides utilities for working with comments at scale. For example, you can update or remove specific types of comments across your codebase:When editing multi-line comments or docstrings, Graph-sitter automatically handles
indentation and maintains the existing comment style.
Special APIs and AI Integration
Google Style Docstrings
Graph-sitter supports Google-style docstrings and can handle their specific formatting, using the CommentGroup.to_google_docstring(…) method.Using AI for Documentation
Graph-sitter integrates with LLMs to help generate and improve documentation. You can use the Codebase.ai(…) method to:- Generate comprehensive docstrings
- Update existing documentation
- Convert between documentation styles
- Add parameter descriptions
Learn more about AI documentation capabilities in our Documentation
Guide and LLM Integration
Guide.
Documentation Coverage
You can analyze and improve documentation coverage across your codebase:Check out the Documentation Guide for
more advanced coverage analysis and bulk documentation generation.