一、参考文档
模版:https://github.com/clenemt/docdash
例子:http://clenemt.github.io/docdash/index.html
jsdoc:http://www.dba.cn/book/jsdoc/
本地服务:http://tapiov.net/live-server/
本地服务:https://github.com/http-party/http-server
二、准备
1、新建package.json,并安装npm包。
"scripts": { "jsdoc:generate": "node_modules/.bin/jsdoc -c jsdoc.json", "jsdoc:dev": "live-server docs --port=9090" },
yarn add -D jsdoc docdash live-server
2、新建src/**.js文件
js文件的格式参考jsdoc的要求。
3、新建jsdoc.json
{ "tags": { "allowUnknownTags": false }, "source": { "include": "./src", "includePattern": ".js$", "excludePattern": "(node_modules/|docs)" }, "plugins": [ "plugins/markdown" ], "opts": { "template": "node_modules/docdash", "encoding": "utf8", "destination": "docs/", "recurse": true, "verbose": true }, "templates": { "cleverLinks": false, "monospaceLinks": false }, "docdash": { "static": true, "sort": true, "sectionOrder": [ ], "disqus": "", "openGraph": { "title": "", "type": "website", "image": "", "site_name": "", "url": "" }, "meta": { "title": "一个JavaScript API文档生成器", "description": "一个JavaScript API文档生成器,借助jsdoc生成文档,借助liveserver在本地起服务查看。", "keyword": "jsdoc,docdash,liveserver,httpserver" }, "search": true, "collapse": true, "wrap": true, "typedefs": true, "navLevel": 0, "private": true, "removeQuotes": "trim", "scripts": [], "menu": { "jsdoc": { "href":"https://github.com/jsdoc/jsdoc", "target":"_blank", "class":"menu-item", "id":"jsdoc_link" }, "docdash": { "href":"https://github.com/clenemt/docdash", "target":"_blank", "class":"menu-item", "id":"docdash_link" }, "case": { "href":"http://clenemt.github.io/docdash/", "target":"_blank", "class":"menu-item", "id":"case_link" }, "httpserver": { "href":"https://github.com/http-party/http-server", "target":"_blank", "class":"menu-item", "id":"http_server_link" }, "liveserver": { "href":"https://github.com/tapio/live-server", "target":"_blank", "class":"menu-item", "id":"live_server_link" } } } }
三、运行
1、生成文件
yarn jsdoc:generate
2、预览文件
yarn jsdoc:dev
四、问题答疑
如果修改了配置文件,比如jsdoc.json,就需要重新生成docs,再起服务。
原文地址:https://www.cnblogs.com/camille666/p/html-jsdoc-docdash.html
时间: 2024-10-06 20:20:04