Remove test folder

This commit is contained in:
qingwei.li 2016-11-22 22:46:44 +08:00
parent c773b71832
commit 6f89c530ed
14 changed files with 2340 additions and 52 deletions

View File

@ -21,12 +21,9 @@ Such as [./docs](https://github.com/QingWei-Li/docsify/tree/master/docs), Create
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
</head>
<body></body>
<script src="//unpkg.com/marked/marked.min.js"></script>
<script src="//unpkg.com/prismjs/prism.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify"></script>
</html>
```
## License
MIT

View File

@ -1,24 +1,52 @@
var rollup = require('rollup')
var buble = require('rollup-plugin-buble')
var commonjs = require('rollup-plugin-commonjs')
var nodeResolve = require('rollup-plugin-node-resolve')
var uglify = require('rollup-plugin-uglify')
var build = function (entry, moduleName) {
var build = function (opts) {
rollup
.rollup({
entry: 'src/' + entry,
plugins: [buble()]
entry: 'src/' + opts.entry,
plugins: [buble()].concat(opts.plugins || [])
})
.then(function (bundle) {
var dest = 'lib/' + (opts.output || opts.entry)
console.log(dest)
bundle.write({
globals: {
globals: !opts.inline ? {
marked: 'marked',
prismjs: 'Prism'
},
} : {},
format: 'umd',
moduleName: moduleName,
dest: 'lib/' + entry
moduleName: opts.moduleName || 'Docsify',
dest: dest
})
})
}
build('docsify.js', 'Docsify')
build('plugins/nav.js', 'Docsify.Nav')
build({
entry: 'docsify.js'
})
build({
entry: 'docsify.js',
output: 'docsify.min.js',
plugins: [uglify()]
})
build({
entry: 'docsify.js',
output: 'docsify.pack.js',
plugins: [commonjs(), nodeResolve()],
inline: false
})
build({
entry: 'docsify.js',
output: 'docsify.pack.min.js',
plugins: [commonjs(), nodeResolve(), uglify()],
inline: false
})
build({
entry: 'plugins/nav.js',
moduleName: 'Docsify.Nav'
})

View File

@ -6,7 +6,5 @@
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
</head>
<body></body>
<script src="//unpkg.com/marked/marked.min.js"></script>
<script src="//unpkg.com/prismjs/prism.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
<script src="//unpkg.com/docsify"></script>
</html>

View File

@ -21,12 +21,9 @@ Such as [./docs](https://github.com/QingWei-Li/docsify/tree/master/docs), Create
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
</head>
<body></body>
<script src="//unpkg.com/marked/marked.min.js"></script>
<script src="//unpkg.com/prismjs/prism.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify"></script>
</html>
```
## License
MIT

View File

@ -128,6 +128,7 @@ function scrollActiveSidebar () {
function scrollIntoView () {
var id = window.location.hash.slice(1);
if (!id) { return }
var section = document.querySelector('#' + id);
if (section) { section.scrollIntoView(); }

2
lib/docsify.min.js vendored
View File

@ -1 +1 @@
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("marked"),require("prismjs")):typeof define==="function"&&define.amd?define(["marked","prismjs"],factory):global.Docsify=factory(global.marked,global.Prism)})(this,function(marked,Prism){"use strict";marked="default"in marked?marked["default"]:marked;Prism="default"in Prism?Prism["default"]:Prism;var ajax=function(url,options){if(options===void 0)options={};var xhr=new XMLHttpRequest;xhr.open(options.method||"get",url);xhr.send();return{then:function(cb){return xhr.addEventListener("load",cb)}}};var tocToTree=function(toc){var headlines=[];var last={};toc.forEach(function(headline){var level=headline.level||1;var len=level-1;if(last[len]){last[len].children=last[len].children||[];last[len].children.push(headline)}else{headlines.push(headline);last[level]=headline}});return headlines};var buildHeadlinesTree=function(tree,tpl){if(tpl===void 0)tpl="";if(!tree||!tree.length){return""}tree.forEach(function(node){tpl+='<li><a class="section-link" href="#'+node.slug+'">'+node.title+"</a></li>";if(node.children){tpl+='<li><ul class="children">'+buildHeadlinesTree(node.children)+"</li>"}});return tpl+"</ul>"};var genToc=function(toc){return buildHeadlinesTree(tocToTree(toc),"<ul>")};var toc=[];var renderer=new marked.Renderer;renderer.heading=function(text,level){var slug=text.toLowerCase().replace(/[\s\n\t]+/g,"-");toc.push({level:level,slug:slug,title:text});return"<h"+level+' id="'+slug+'"><a href="#'+slug+'" class="anchor"></a>'+text+"</h"+level+">"};marked.setOptions({renderer:renderer,highlight:function highlight(code,lang){return Prism.highlight(code,Prism.languages[lang]||Prism.languages.markup)}});var render=function(content){var section='<section class="content">\n <article class="markdown-section">'+marked(content)+"</article>\n </section>";var sidebar='<aside class="sidebar">'+genToc(toc)+"</aside>";return"<main>"+sidebar+section+"</main>"};function scrollActiveSidebar(){if(/mobile/i.test(navigator.userAgent)){return}var anchors=document.querySelectorAll(".anchor");var nav={};var lis=document.querySelectorAll(".sidebar li");var active=null;for(var i=0,len=lis.length;i<len;i+=1){var li=lis[i];var a=li.querySelector("a");nav[a.getAttribute("href").slice(1)]=li}function highlight(){for(var i=0,len=anchors.length;i<len;i+=1){var node=anchors[i].parentNode;var bcr=node.getBoundingClientRect();if(bcr.top<150&&bcr.bottom>150){var li=nav[node.id];if(li===active){return}if(active){active.classList.remove("active")}li.classList.add("active");active=li;return}}}document.querySelector("main .content").addEventListener("scroll",highlight);highlight();function scrollIntoView(){var id=window.location.hash.slice(1);var section=document.querySelector("#"+id);if(section){section.scrollIntoView()}}window.addEventListener("hashchange",scrollIntoView);scrollIntoView()}var bindEvent=function(){scrollActiveSidebar()};var DEFAULT_OPTS={el:"#app",title:document.title,sep:" - "};var Docsify=function Docsify(opts){Docsify.installed=true;this.replace=true;this.opts=Object.assign({},opts,DEFAULT_OPTS);this.dom=document.querySelector(this.opts.el);if(!this.dom){this.dom=document.body;this.replace=false}this.loc=document.location.pathname;if(/\/$/.test(this.loc)){this.loc+="README"}this.load()};Docsify.prototype.load=function load(){var this$1=this;ajax(this.loc+".md").then(function(res){var target=res.target;if(target.status>=400){this$1.render("not found")}else{this$1.render(res.target.response);bindEvent()}})};Docsify.prototype.render=function render$1(content){document.title=this.loc.slice(1)+this.opts.sep+this.opts.title;this.dom[this.replace?"outerHTML":"innerHTML"]=render(content)};Docsify.use=function(){var plugin=arguments[0];if(typeof plugin==="function"){plugin.call(Docsify)}else{throw TypeError("[docsify] Invalid plugin "+plugin.name)}};window.addEventListener("load",function(){if(Docsify.installed){return}new Docsify});return Docsify});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("marked"),require("prismjs")):"function"==typeof define&&define.amd?define(["marked","prismjs"],t):e.Docsify=t(e.marked,e.Prism)}(this,function(e,t){"use strict";function n(){function e(){for(var e=0,t=n.length;e<t;e+=1){var r=n[e].parentNode,s=r.getBoundingClientRect();if(s.top<150&&s.bottom>150){var l=i[r.id];if(l===o)return;return o&&o.classList.remove("active"),l.classList.add("active"),void(o=l)}}}function t(){var e=window.location.hash.slice(1);if(e){var t=document.querySelector("#"+e);t&&t.scrollIntoView()}}if(!/mobile/i.test(navigator.userAgent)){for(var n=document.querySelectorAll(".anchor"),i={},r=document.querySelectorAll(".sidebar li"),o=null,s=0,l=r.length;s<l;s+=1){var a=r[s],c=a.querySelector("a");i[c.getAttribute("href").slice(1)]=a}document.querySelector("main .content").addEventListener("scroll",e),e(),window.addEventListener("hashchange",t),t()}}e="default"in e?e.default:e,t="default"in t?t.default:t;var i=function(e,t){void 0===t&&(t={});var n=new XMLHttpRequest;return n.open(t.method||"get",e),n.send(),{then:function(e){return n.addEventListener("load",e)}}},r=function(e){var t=[],n={};return e.forEach(function(e){var i=e.level||1,r=i-1;n[r]?(n[r].children=n[r].children||[],n[r].children.push(e)):(t.push(e),n[i]=e)}),t},o=function(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='<li><a class="section-link" href="#'+e.slug+'">'+e.title+"</a></li>",e.children&&(t+='<li><ul class="children">'+o(e.children)+"</li>")}),t+"</ul>"):""},s=function(e){return o(r(e),"<ul>")},l=[],a=new e.Renderer;a.heading=function(e,t){var n=e.toLowerCase().replace(/[\s\n\t]+/g,"-");return l.push({level:t,slug:n,title:e}),"<h"+t+' id="'+n+'"><a href="#'+n+'" class="anchor"></a>'+e+"</h"+t+">"},e.setOptions({renderer:a,highlight:function(e,n){return t.highlight(e,t.languages[n]||t.languages.markup)}});var c=function(t){var n='<section class="content">\n <article class="markdown-section">'+e(t)+"</article>\n </section>",i='<aside class="sidebar">'+s(l)+"</aside>";return"<main>"+i+n+"</main>"},u=function(){n()},d={el:"#app",title:document.title,sep:" - "},h=function e(t){e.installed=!0,this.replace=!0,this.opts=Object.assign({},t,d),this.dom=document.querySelector(this.opts.el),this.dom||(this.dom=document.body,this.replace=!1),this.loc=document.location.pathname,/\/$/.test(this.loc)&&(this.loc+="README"),this.load()};return h.prototype.load=function(){var e=this;i(this.loc+".md").then(function(t){var n=t.target;n.status>=400?e.render("not found"):(e.render(t.target.response),u())})},h.prototype.render=function(e){document.title=this.loc.slice(1)+this.opts.sep+this.opts.title,this.dom[this.replace?"outerHTML":"innerHTML"]=c(e)},h.use=function(){var e=arguments[0];if("function"!=typeof e)throw TypeError("[docsify] Invalid plugin "+e.name);e.call(h)},window.addEventListener("load",function(){h.installed||new h}),h});

2292
lib/docsify.pack.js Normal file

File diff suppressed because it is too large Load Diff

1
lib/docsify.pack.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,14 @@
"name": "docsify",
"version": "0.0.3",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"main": "lib/docsify.pack.js",
"files": [
"lib",
"src",
"themes"
],
"scripts": {
"build": "node build/build.js && uglifyjs lib/docsify.js -o lib/docsify.min.js",
"dev": "nodemon -w src -x 'node build/build.js && node test/server.js'",
"build": "node build/build.js",
"test": "eslint src test"
},
"keywords": [
@ -23,14 +22,14 @@
"author": "qingwei-li <cinwell.li@gmail.com> (https://github.com/QingWei-Li)",
"license": "MIT",
"devDependencies": {
"buffet": "^1.0.10",
"eslint": "^3.10.2",
"eslint-config-vue": "^2.0.1",
"eslint-plugin-vue": "^1.0.0",
"nodemon": "^1.11.0",
"rollup": "^0.36.3",
"rollup-plugin-buble": "^0.14.0",
"uglify-js": "^2.7.4"
"rollup-plugin-commonjs": "^5.0.5",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1"
},
"dependencies": {
"marked": "^0.3.6",

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>docsify</title>
<link rel="stylesheet" href="/themes/vue.css">
</head>
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/marked/marked.min.js"></script>
<script src="//unpkg.com/prismjs/prism.js"></script>
<script src="/docsify.js"></script>
</html>

View File

@ -1 +0,0 @@
../README.md

View File

@ -1 +0,0 @@
../lib/docsify.js

View File

@ -1,8 +0,0 @@
const server = require('http').createServer()
const buffet = require('buffet')({ root: './test' })
server.on('request', buffet)
server.listen(6677, function () {
console.log('Ready! Listening on http://localhost:6677')
})

View File

@ -1 +0,0 @@
../themes