Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cldoc

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cldoc

Example

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

一个简单的文档工具

NPM version NPM downloads Build Status Coverage Status [![MIT License][license-image]][license-url] [license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat [license-url]: LICENSE

安装

~ npm install cldoc -g

目录结构

仓库必须包含以下两个目录:

- documents //存放文档
  - common // 类目目录,可以自己新建文件夹
    - README.md //目录的根页面,会被渲染为index.html,比如common/README.md,会生成common/index.html
    - example.md // -> common/example.md.html
    - example.ignore.md //注意:如果字符中包含了ignore,那么这个文件/文件夹将会再导航中被忽略
  - README.md // -> index.html 生成最外层的根页面
- models // 存放数据模型和模板
  - example.json
  - comment.pug //使用了pug模板

使用

~ cldoc <outputDir> #输出文件夹

自定义的标签

嵌入配置

\`\`\`config
{
  "baseUrl": "//cdn.withme.cn/a/cldoc/0.2.7/",
  //foundation.css, gruvbox-light.css, school-book.css
  "styleName": "atelier-estuary-light.css"
}
\`\`\`

这段代码不会被渲染到文档中,但是它会成为一个数据到模板渲染的默认数据的config

在最外层的documents/README.md中的config块中,会影响到布局模板的资源路径和样式名,比如上述配置会产生这样的结果:

<link rel="stylesheet" href="//cdn.withme.cn/a/cldoc/0.2.7/cldoc-atelier-estuary-light.css">

代码样式,使用了highlightjshighlightjs可用样式):

atelier-estuary-light.css
foundation.css
gruvbox-light.css
school-book.css
...

可嵌入数据

\`\`\`json
{
  "example": "{{example.json}}"
}
\`\`\`

models/example.json:

{
  // sss
  "x": "sss", //asdjf;jk;
  "items": "xxxx"
}

渲染结果:

\`\`\`json
{
  "example": {
    // sss
    "x": "sss", //asdjf;jk;
    "items": "xxxx"
  }
}
\`\`\`

嵌入pug模板

\`\`\`tpl
example.pug
//第一行必须是文件名,后面是JSON数据
{
  "name": "xxx"
}
//会有一部分默认数据
{
  "title": "example", //ddd
  "basename": "example",
  "keywords": [],
  "filename": "example.md.html",
  "config": {}
}

\`\`\`

models/example.pug:

.ex= title

渲染结果:

<div class="ex">example</div>
默认包含一种json-table.pug的模板
\`\`\`tpl
json-table.pug
[
  //第一行是标题
  { "name":"名称", "optional":"是否可选", "type": "类型", "desc":"描述" },
  { "name":"是打发打发", "optional":1, "type": "string", "desc":"啊啊士大夫撒打发士大夫撒旦法撒旦法撒旦法师的法师打发士大夫撒旦法法师打发士大夫撒旦法法师打发士大夫撒旦法" },
  { "name":"yushan", "optional":1, "type": "string", "desc":"xxx" },
  { "name":"yushan", "optional":1, "type": "string", "desc":"xxx" },
  { "name":"yushan", "optional":1, "type": "string", "desc":"xxx" }
]
\`\`\`

default-models/json-table.pug:

table
  thead
    tr
      each key in keys
        th= titleRow[key]
  tbody
    each row in rows
      tr
        each key in keys
          td= row[key]

渲染结果:

table

工具中包含的默认模板有3个

- default-models/
  - layout.pug //布局
  - nav.pug //导航
  - json-table.pug //json表格

FAQs

Package last updated on 29 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc