FE Workflow
standard-dev>notes

文档注释

vscode 插件

/*
 * 简述当前文件功能
 * @author 作者名称
 * @version 版本号 最近编辑时间
 * @description 该版本改动信息
 */

HTML 注释规范

模块注释

<!-- S Comment Text A -->
<div class="mod_a">
  ...
</div>
<!-- E Comment Text A -->

<!-- S Comment Text B -->
<div class="mod_b">
  ...
</div>
<!-- E Comment Text B -->

嵌套模块

<!-- S Comment Text A -->
<div class="mod_a">

  <div class="mod_b">
      ...
  </div>
  <!-- /mod_b -->

  <div class="mod_c">
    ...
  </div>
  <!-- /mod_c -->

</div>
<!-- E Comment Text A -->

条件注释

<head>
  <!--[if !IE]> -->
  浏览器 不是 IE
  <!-- <![endif]-->

  <!--[if lte IE 9]>
  IE 浏览器版本低于 9
  <![endif]-->

  <!--[if IE 9]>
  IE 浏览器版本 9
  <![endif]-->

  <!--[if gte IE 9]>
  IE 浏览器版本大于或等于 9
  <![endif]-->
</head>

CSS 文件注释

单行注释

/* Comment Text */
.jdc {}

/* Comment Text */
.jdc {}

模块注释

/* Module A
---------------------------------------------------------------- */
.mod_a {}

/* Module B
---------------------------------------------------------------- */
.mod_b {}

JS 注释规范

单行注释.js

// is current tab
const active = true

// 注释行上面是一个块的顶部时不需要空行
function getType() {
  // set the default type to 'no type'
  const type = this.type || 'no type'
  return type
}

function fn() {
  console.log('fetching type...')

  // set the default type to 'no type'
  const type = this.type || 'no type'
  return type
}

特殊标记注释

Better Comments vscode 注释分类插件TODO Highlight vscode 注释关键字高亮插件

// TODO:功能未完成,待完善
// FIXME:待修复
// XXX:实现方法待确认
// NOTE:代码功能说明
// HACK:此处写法有待优化
// BUG:此处有 Bug

函数注释

JSDoc

/**
 * 方法说明
 * @func
 * @desc xx函数
 * @param {string} a - 参数a
 * @param {number} b=1 - 参数b默认值为1
 * @param {string} c=1 - 参数c有两种支持的取值  1—表示x  2—表示xx
 * @param {object} d - 参数d为一个对象
 * @param {string} d.e - 参数d的e属性
 * @param {object[]} g - 参数g为一个对象数组
 * @param {string} g.h - 参数g数组中一项的h属性
 * @param {string} [j] - 参数j是一个可选参数
 * @return {返回值类型} 返回值说明
 */

变量注释

/**
 * @type {string | null}
 * @desc string或者null
 */
let foo
文档注释
HTML 注释规范
模块注释
嵌套模块
条件注释
CSS 文件注释
单行注释
模块注释
JS 注释规范
单行注释.js
特殊标记注释
函数注释
变量注释