DigApis编码提交规范白皮书

python

  1. 代码风格:PEP8规范,参考
  2. 注释规范:

    2.1. 文件头:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Author    :  Jason
    # @Mail      :  jczhangmail@126.com
    # @File      :  文件名.py
    
    

    2.2. 类注释:

    class SampleClass(object):
    """Summary of class here.
    
    Longer class information....
    Longer class information....
    
    Attributes:
        likes_spam: A boolean indicating if we like SPAM or not.
        eggs: An integer count of the eggs we have laid.
    """
    
    def __init__(self, likes_spam=False):
        """Inits SampleClass with blah."""
        self.likes_spam = likes_spam
        self.eggs = 0
    
    def public_method(self):
        """Performs operation blah."""
    

    中文自述如下:

    """ 类的终结...(主要介绍功能概况)
    
    详细描述。。。
    
    属性:
        参数1:类型,干啥用的
        参数:类型,干什么用的
    """
    

    2.3. 函数注释:

    def fetch_bigtable_rows(big_table, keys, other_silly_variable=None):
    """Fetches rows from a Bigtable.
    
    Retrieves rows pertaining to the given keys from the Table instance
    represented by big_table.  Silly things may happen if
    other_silly_variable is not None.
    
    Args:
        big_table: An open Bigtable Table instance.
        keys: A sequence of strings representing the key of each table row
            to fetch.
        other_silly_variable: Another optional variable, that has a much
            longer name than the other args, and which does nothing.
    
    Returns:
        A dict mapping keys to the corresponding table row data
        fetched. Each row is represented as a tuple of strings. For
        example:
    
        {'Serak': ('Rigel VII', 'Preparer'),
         'Zim': ('Irk', 'Invader'),
         'Lrrr': ('Omicron Persei 8', 'Emperor')}
    
        If a key from the keys argument is missing from the dictionary,
        then that row was not found in the table.
    
    Raises:
        IOError: An error occurred accessing the bigtable.Table object.
    """
    pass
    

    中文自述如下:

    """函数整体功能概述
    详细描述。。。
    
    参数:
        参数1:干啥用的
        参数2:干啥用的
    
    返回:
        详细描述。。。
        例子:
    
        {“参数1,参数2。。。”:返回值)}
    
    提示:
        程序不完善的或者可能出现报错的情况
    
    """
    

Git Commit

  1. 提交格式

    <type>(<scope>): <subject>
    //空一行
    <body>
    
  2. 说明

    type (必需)、scope (可选)和subject(必需)

    (可选)

  3. 范例

    fix: feat(0429留言下单): add 'graphiteWidth' option
    
    提交的具体情况
    

    关于 <type>

    • type用于说明 commit 的类别,只允许使用下面8个标识。
    • br: 此项特别针对bug号,用于向测试反馈bug列表的bug修改情况
    • feat:新功能(feature)
    • fix:修补bug
    • docs:文档(documentation)
    • style: 格式(不影响代码运行的变动)
    • refactor:重构(即不是新增功能,也不是修改bug的代码变动)
    • test:增加测试
    • chore:构建过程或辅助工具的变动
    • revert: feat(pencil): add 'graphiteWidth' option (撤销之前的commit)

    关于 <scope>
    scope用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。

    关于 <subject>
    subject是 commit 目的的简短描述,不超过50个字符。
    以动词开头,使用第一人称现在时,比如change,而不是changed或changes
    第一个字母小写
    结尾不加句号(.)

    关于 <body>
    Body 部分是对本次 commit 的详细描述,可以分成多行。

原文地址:https://www.cnblogs.com/codeblock/p/DigApis-bian-ma-ti-jiao-gui-fan-bai-pi-shu.html