这是一个为 xlib 中模块的静态文档设计的主题。
请自己安装 node。
参考 http://lab.lepture.com/nico/zh/
另外,如果你安装了 socket.io 的话,将有 livereload 功能。
$ npm install socket.io -g
Linux & Mac 用户一键安装:
curl https://raw.github.com/spmjs/nico-cmd/master/bootstrap.sh | sh
Windows 用户安装:
1.切换到.spm
目录
2.创建一个themes
的目录并切换进入
3.从 git 上拉一份 cmd 的 theme
4.重命名nico-cmd
目录为cmd
P.S. 注意千万别把C:\Users\{{username}}\.spm\themes\cmd
目录设置为全局PATH,这样nico
命令会失效,切记!
cd C:\Users\{{username}}\.spm
mkdir themes
cd themes
git clone https://github.com/spmjs/nico-cmd.git
rename nico-cmd cmd
cd cmd
使用 xdoc 来管理模块文档。
nico 还会用到模块根目录下的 package.json 文件,具体项的含义请参考:spm package.json
其中 repository.url
用来生成 View the Project 链接, bugs.url
用来生成讨论链接。
用三个 ` 会高亮显示代码
```js
function something() {
}
```
用四个 ` 会高亮显示代码,还会将代码插入到生成的 HTML 页面中
````js
function something() {
}
````
````html
<div class="content"></div>
````
插入 iframe
````iframe
<link rel="stylesheet" href="css/some.css">
<button>click</button>
<script>
seajs.use('jquery', function($) {
$('button').click(function() { alert('hello'); })
});
</script>
````
还可以设置 iframe 的高度
````iframe:400
````
生成 iframe 的模板是 templates/iframe.html
,不用写头写尾。
假设模块的目录结构为(以下结构可以用 xdoc init 来生成):
package.json
src/
hello-world.js
examples/
hello-world.md
docs/
hello-world.md
README.md
执行 xdoc build
后会生成:
package.json
_site/
index.html
src/
hello-world.js
examples/
hello-world.html
docs/
hello-world.html
src/
hello-world.js
examples/
hello-world.md
docs/
hello-world.md
README.md
所有生成的文件都在 _site
目录下。
使用 spm test 命令就可以直接在命令行里运行用例。依赖 spm doc
当然也可以使用 spm doc watch 启动服务,然后访问 http://127.0.0.1:8000/tests/runner.html 用例页面进行测试。