[Feature Request] Unify format of the docstring for all code #911
Labels
documentation
Improvements or additions to documentation
enhancement
New feature or request
good first issue
Good for newcomers
P0
Task with high level priority
Milestone
Required prerequisites
Motivation
Currently there's some code doesn't follow the docstring standard, we need to review and polish
Solution
Guideline for Writing Docstrings:
This guideline will help you write clear, concise, and structured docstrings for contributing to
CAMEL
.Use the Triple-Quoted String with
r"""
(raw string)Begin the docstring with
r"""
to indicate a raw docstring. This prevents any issues with special characters and ensures consistent formatting, especially in documentation tools like Sphinx.Provide a Brief Class or Method Description
Start with a concise summary of the purpose and functionality, keeping each line under
79
characters. The summary should start from the first line without a linebreak:Use the
Args
: section to document the constructor parameters, maintaining the79
-character limit for each line. Break long descriptions into multiple lines if necessary, indenting continuation lines by4
spaces. For each parameter, follow this structure:Parameter name: The name of the parameter as it appears in the function signature.
Type
: The type of the parameter (e.g.,int
,str
, custom types likeBaseModelBackend
). If a parameter is optional, use the suffix ,optional
.Description: A brief explanation of the parameter’s purpose.
Default value: If applicable, include the default value using the format
(default: :obj:<default_value>)
. Use:obj:
to denote Python objects.4. Explain Optional Parameters Clearly
For optional parameters, describe how the class behaves when the parameter is not provided. Keep each line under
79
characters, breaking longer descriptions into multiple lines.Use
reST
Formatting for LinksWhen referring to objects, types, or classes (e.g.,
BaseMessage
), usereST
roles like:obj:
for proper formatting and linking. Ensure that lines do not exceed79
characters.Provide Default Values Consistently
For parameters with default values, include them in parentheses at the end of the description. Keep the
(default: :obj:<default_value>)
format consistent throughout. Wrap long descriptions to avoid exceeding79
characters.Limit Line Length to
79
CharactersEnsure that all lines are limited to
79
characters for readability. Break long sentences or descriptions into multiple lines, and indent continuation lines by 4 spaces. This improves readability in text editors and follows Python's PEP 8 and PEP 257 guidelines.Class Docstring of the Constructor (
__init__
)To improve code hinting in editors like Visual Studio Code, include the constructor's docstring directly under the class definition. This ensures that code editors can display detailed hints.
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: