Skip to content

Commit ebae7b5

Browse files
committed
update jsdoc
1 parent 0e77591 commit ebae7b5

15 files changed

+695
-374
lines changed

.jsdoc.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"tags": {
3+
"allowUnknownTags": true
4+
},
5+
"source": {
6+
"includePattern": ".+\\.js(doc)?$",
7+
"excludePattern": "(^|\\/|\\\\)_"
8+
},
9+
"plugins": ["plugins/markdown"],
10+
"templates": {
11+
"cleverLinks" : false,
12+
"monospaceLinks" : false,
13+
"default" : {
14+
"outputSourceFiles" : true
15+
},
16+
"systemName" : "FIS3",
17+
"footer" : "",
18+
"copyright" : "",
19+
"navType" : "vertical",
20+
"theme" : "cerulean",
21+
"linenums" : true,
22+
"collapseSymbols" : false,
23+
"inverseNav" : true
24+
},
25+
"markdown": {
26+
"parser": "gfm",
27+
"hardwrap": true
28+
}
29+
}

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* fis
3-
* http://fis.baidu.com
2+
* fis 模块入口
43
*/
54

65
'use strict';

jsdoc.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

lib/cache.js

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
/*
2-
* fis
3-
* http://fis.baidu.com/
4-
*/
5-
61
'use strict';
7-
82
/**
93
* Cache 构造器,在 fis 中主要用于缓存目标文件的编译信息和编译结果。
104
*
115
* @param {String} path 需要被缓存的文件路径。
126
* @param {String} dir 缓存目录。
13-
*
14-
* @class
157
* @inner
16-
* @memberOf module:fis.cache
8+
* @class
9+
* @memberOf fis.cache
1710
*/
1811
var Cache = Object.derive(function(path, dir) {
1912
var file = fis.util.realpath(path);
@@ -29,13 +22,15 @@ var Cache = Object.derive(function(path, dir) {
2922
var hash = fis.util.md5(file, 10);
3023
this.cacheFile = basename + '-c-' + hash + '.tmp';
3124
this.cacheInfo = basename + '-o-' + hash + '.json';
32-
}, {
25+
},
26+
27+
/** @lends fis.cache~Cache.prototype */
28+
{
3329

3430
/**
3531
* 保存内容以及信息。
3632
* @param {String | Buffer} content 文件内容
3733
* @param {Object} info 数据信息。
38-
* @memberOf module:fis.cache~Cache.prototype
3934
*/
4035
save: function(content, info) {
4136
var infos = {
@@ -52,7 +47,6 @@ var Cache = Object.derive(function(path, dir) {
5247
* 从缓存目录中读取缓存内容。
5348
* @param {Object} [file] 如果传入了此参数,从缓存文件中读取的内容将会赋值到 `file.content` 以及数据信息会被赋值到 `file.info`.
5449
* @return {Boolean} 返回 true, 如果缓存有效,否则返回 false.
55-
* @memberOf module:fis.cache~Cache.prototype
5650
*/
5751
revert: function(file) {
5852
fis.log.debug('revert cache');
@@ -90,7 +84,6 @@ var Cache = Object.derive(function(path, dir) {
9084
/**
9185
* 添加依赖,依赖将会被用来判断缓存是否有效,依赖中,任何一个文件修改时间发生变化,缓存失效。
9286
* @param {String} filepath 依赖的文件路径。
93-
* @memberOf module:fis.cache~Cache.prototype
9487
*/
9588
addDeps: function(file) {
9689
var path = fis.util.realpath(file);
@@ -105,7 +98,6 @@ var Cache = Object.derive(function(path, dir) {
10598
/**
10699
* 删除依赖。
107100
* @param {String} filepath 依赖的文件路径。
108-
* @memberOf module:fis.cache~Cache.prototype
109101
*/
110102
removeDeps: function(file) {
111103
var path = fis.util.realpath(file);
@@ -117,8 +109,7 @@ var Cache = Object.derive(function(path, dir) {
117109

118110
/**
119111
* 合并 cache 中的依赖列表。
120-
* @param {mixed} cache 此对象中的依赖会被合入到改事例依赖中。
121-
* @memberOf module:fis.cache~Cache.prototype
112+
* @param {mixed} cache 此对象中的依赖会被合入到该事例依赖中。
122113
*/
123114
mergeDeps: function(cache) {
124115
var deps = {};
@@ -134,34 +125,57 @@ var Cache = Object.derive(function(path, dir) {
134125
});
135126

136127
/**
137-
* 用来创建 Cache 对象, 更多细节请查看 {@link module:fis.cache~Cache Cache} 说明。
128+
* 用来创建 ~Cache 对象, 更多细节请查看 {@link fis.cache~Cache ~Cache} 说明。
138129
*
139-
* ```js
130+
* @example
131+
* // 检查该文件是否启用缓存
140132
* if (file.useCache) {
133+
*
134+
* // 如果启用,则创建 cache 对象
141135
* file.cache = fis.cache(file.realpath, CACHE_DIR);
142-
* }
143-
* ```
144136
*
145-
* @module {Function} fis.cache
146-
* @see {@link module:fis.cache~Cache Cache 类说明}
137+
* // 保存内容以及信息到缓存中。
138+
* file.cache.save('body', {
139+
* foo: 1
140+
* });
141+
* }
142+
* @see {@link fis.cache~Cache Cache 类说明}
143+
* @param {String} path 需要被缓存的文件路径。
144+
* @param {String} dir 缓存目录。
145+
* @function
146+
* @namespace fis.cache
147147
*/
148148
var exports = module.exports = Cache.factory();
149149

150150
/**
151-
* 是否开启缓存。
151+
* 是否开启缓存。当设置为 false 后, fis 编译将不会启用缓存。
152152
* @type {Boolean}
153+
* @defaultValue true
154+
* @memberOf fis.cache
155+
* @name enable
153156
*/
154157
exports.enable = true;
155158

156159
/**
157-
* {@link module:fis.cache~Cache Cache} 构造器
160+
* 指向 {@link fis.cache~Cache ~Cache 类}。
161+
* @see {@link fis.cache~Cache Cache 类说明}
162+
* @memberOf fis.cache
163+
* @name Cache
158164
*/
159165
exports.Cache = Cache;
160166

161167
/**
162168
* 清除缓存目录下面指定的目录。
163-
* @param {String} name [description]
164-
* @return {Undefined}
169+
* @example
170+
*
171+
* // 当命令行中设置了 --clean 属性后,开始之前,先清除之前编译产生的缓存文件。
172+
* if (options.clean) {
173+
* fis.cache.clean('compile');
174+
* }
175+
* @param {String} name 需要清除的目录名
176+
* @memberOf fis.cache
177+
* @name clean
178+
* @function
165179
*/
166180
exports.clean = function(name) {
167181
name = name || '';

lib/cli.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
/*
2-
* fis命令行操作处理
3-
*/
4-
51
/**
62
* 命令行相关的信息和工具类方法暴露在此模块中。
7-
* @exports fis.cli
3+
* @namespace fis.cli
84
*/
95
var cli = module.exports = {};
6+
107
var path = require('path');
118
var _ = require('./util.js');
129
var util = require('util');
1310
var lolcat = require('fis-lolcat');
1411

1512
/**
16-
* 命令名字
17-
* @type {String}
13+
* 命令行工具名字
14+
* @memberOf fis.cli
15+
* @name name
16+
* @defaultValue fis3
1817
*/
1918
cli.name = 'fis3';
2019

21-
//colors
20+
/**
21+
* 指向 {@link https://www.npmjs.com/package/colors colors} 模块。
22+
* @memberOf fis.cli
23+
* @name colors
24+
*/
2225
cli.colors = require('colors');
2326

2427
//commander object
2528
cli.commander = null;
2629

2730
/**
2831
* package.json 中的信息
29-
* @type {Object}
32+
* @memberOf fis.cli
33+
* @name info
3034
*/
3135
cli.info = fis.util.readJSON(path.dirname(__dirname) + '/package.json');
3236

3337
/**
34-
* 显示帮组信息,主要用来格式化信息,处理缩进等。fis command 插件,可以用此方法来输出帮助信息。
38+
* 显示帮助信息,主要用来格式化信息,处理缩进等。fis command 插件,可以用此方法来输出帮助信息。
3539
*
3640
* @param {String} [cmdName] 命令名称
3741
* @param {Object} [options] 配置
3842
* @param {Array} [commands] 支持的命令集合
43+
* @memberOf fis.cli
44+
* @name help
45+
* @function
3946
*/
4047
cli.help = function(cmdName, options, commands) {
4148
var strs = [
@@ -101,6 +108,24 @@ fis.set('modules.commands', ['init', 'install', 'release', 'server', 'inspect'])
101108

102109
/**
103110
* 输出 fis 版本信息。
111+
*
112+
* ```
113+
* v3.0.0
114+
*
115+
* /\\\\\\\\\\\\\\\ /\\\\\\\\\\\ /\\\\\\\\\\\
116+
* \/\\\/////////// \/////\\\/// /\\\/////////\\\
117+
* \/\\\ \/\\\ \//\\\ \///
118+
* \/\\\\\\\\\\\ \/\\\ \////\\\
119+
* \/\\\/////// \/\\\ \////\\\
120+
* \/\\\ \/\\\ \////\\\
121+
* \/\\\ \/\\\ /\\\ \//\\\
122+
* \/\\\ /\\\\\\\\\\\ \///\\\\\\\\\\\/
123+
* \/// \/////////// \///////////
124+
* ```
125+
*
126+
* @memberOf fis.cli
127+
* @name version
128+
* @function
104129
*/
105130
cli.version = function() {
106131
var content = ['',
@@ -145,9 +170,12 @@ cli.version = function() {
145170
};
146171

147172
/**
148-
* fis由命令行到内核执行的入口
173+
* fis命令行执行入口。
149174
* @param {Array} argv 由 {@link https://github.com/substack/minimist minimist} 解析得到的 argv, 已经转换成了对象。
150175
* @param {Array} env liftoff env
176+
* @name run
177+
* @memberOf fis.cli
178+
* @function
151179
*/
152180
cli.run = function(argv, env) {
153181
// [node, realPath(bin/fis.js)]
@@ -184,9 +212,9 @@ cli.run = function(argv, env) {
184212
} else {
185213

186214
// tip
187-
if (argvRaw[2] === 'release' && !env.modulePath) {
188-
//fis.log.warning('Local `fis3` not found, use global version instead.');
189-
}
215+
// if (argvRaw[2] === 'release' && !env.modulePath) {
216+
// fis.log.warning('Local `fis3` not found, use global version instead.');
217+
// }
190218

191219
//fix args
192220
var p = argvRaw.indexOf('--no-color');

0 commit comments

Comments
 (0)