Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Unify format of the docstring for all code #911

Open
1 of 2 tasks
Wendong-Fan opened this issue Sep 7, 2024 · 0 comments
Open
1 of 2 tasks

[Feature Request] Unify format of the docstring for all code #911

Wendong-Fan opened this issue Sep 7, 2024 · 0 comments
Assignees
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

Comments

@Wendong-Fan
Copy link
Member

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.

  1. 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.

  2. 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:

r"""Class for managing conversations of CAMEL Chat Agents.
"""
  1. Document the Args Section
    Use the Args: section to document the constructor parameters, maintaining the 79-character limit for each line. Break long descriptions into multiple lines if necessary, indenting continuation lines by 4 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 like BaseModelBackend). 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.

  1. Use reST Formatting for Links
    When referring to objects, types, or classes (e.g., BaseMessage), use reST roles like :obj: for proper formatting and linking. Ensure that lines do not exceed 79 characters.

  2. 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 exceeding 79 characters.

  3. Limit Line Length to 79 Characters
    Ensure 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.

  4. 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.

class MyClass:
    r"""Class for managing conversations of CAMEL Chat Agents.

    Args:
        system_message (BaseMessage): The system message for the chat
            agent, used to initialize the conversation and provide context.
        model (BaseModelBackend, optional): The model backend to use for
            generating responses. If not provided, defaults to
            :obj:`OpenAIModel` with `GPT_4O_MINI`. 
            (default: :obj:`OpenAIModel` with `GPT_4O_MINI`)
        memory (AgentMemory, optional): The agent's memory for managing chat 
            messages. If `None`, a default :obj:`ChatHistoryMemory` will
            be used. (default: :obj:`None`)
        message_window_size (int, optional): The maximum number of previous 
            messages to include in the context window. If `None`, no 
            windowing is applied. (default: :obj:`None`)
        token_limit (int, optional): The maximum number of tokens allowed 
            in the context before pruning occurs. If `None`, the token 
            limit is automatically set by the backend model. 
            (default: :obj:`None`)
        output_language (str, optional): The language used for the agent's 
            output. If not specified, defaults to the system's language 
            setting. (default: :obj:`None`)
        tools (List[OpenAIFunction], optional): A list of available 
            :obj:`OpenAIFunction` instances for the agent. If not provided, 
            no tools are available. (default: :obj:`None`)
        response_terminators (List[ResponseTerminator], optional): A list of 
            :obj:`ResponseTerminator` instances that control when the agent 
            terminates its response. (default: :obj:`None`)

    """
    def __init__(self, system_message, model=None, memory=None, 
                 message_window_size=None, token_limit=None, 
                 output_language=None, tools=None, response_terminators=None):
        pass

Alternatives

No response

Additional context

No response

@Wendong-Fan Wendong-Fan added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 7, 2024
@Wendong-Fan Wendong-Fan added this to the Sprint 11 milestone Sep 7, 2024
@Wendong-Fan Wendong-Fan modified the milestones: Sprint 11, Sprint 12 Sep 7, 2024
@Wendong-Fan Wendong-Fan added good first issue Good for newcomers P0 Task with high level priority labels Sep 9, 2024
@Wendong-Fan Wendong-Fan self-assigned this Sep 9, 2024
@WHALEEYE WHALEEYE modified the milestones: Sprint 12, Sprint 13 Sep 23, 2024
@Wendong-Fan Wendong-Fan modified the milestones: Sprint 13, Sprint 14 Oct 7, 2024
@MuggleJinx MuggleJinx assigned MuggleJinx and unassigned MuggleJinx Oct 14, 2024
@Wendong-Fan Wendong-Fan modified the milestones: Sprint 14, Sprint 15 Oct 18, 2024
MuggleJinx added a commit that referenced this issue Oct 18, 2024
MuggleJinx added a commit that referenced this issue Oct 20, 2024
@Wendong-Fan Wendong-Fan linked a pull request Oct 20, 2024 that will close this issue
10 tasks
MuggleJinx added a commit that referenced this issue Oct 26, 2024
Wendong-Fan added a commit that referenced this issue Oct 30, 2024
Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com>
Co-authored-by: Asher-hss <101127070+Asher-hss@users.noreply.github.com>
Co-authored-by: Daniel <91907332+dxmaptin@users.noreply.github.com>
Co-authored-by: Wendong <w3ndong.fan@gmail.com>
Co-authored-by: Zeyu Zhang <503423253@qq.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Isaac Jin <whale3ye@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers P0 Task with high level priority
Projects
Status: No status
Development

No branches or pull requests

3 participants