forked from docsifyjs/docsify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 44ac51b
Showing
20 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["vue"], | ||
"globals": { | ||
"XMLHttpRequest": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.log | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 cinwell.li | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# docsify | ||
[![Build Status](https://travis-ci.org/QingWei-Li/docsify.svg?branch=master)](https://travis-ci.org/QingWei-Li/docsify) | ||
[![Coverage Status](https://coveralls.io/repos/github/QingWei-Li/docsify/badge.svg?branch=master)](https://coveralls.io/github/QingWei-Li/docsify?branch=master) | ||
[![npm](https://img.shields.io/npm/v/docsify.svg)](https://www.npmjs.com/package/docsify) | ||
|
||
>🃏 A magical documentation site generator. | ||
## Features | ||
- Easy and lightweight | ||
- Custom themes and plugins | ||
|
||
## Quick start | ||
Such as [./docs](./docs), Just create `404.html` and `README.md` into `/docs`. | ||
|
||
404.html | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<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/highlight.js/lib/highlight.js"></script> | ||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script> | ||
</html> | ||
``` | ||
|
||
|
||
## License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>docsify</title> | ||
<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/highlight.js/lib/highlight.js"></script> | ||
<script src="//unpkg.com/docsify/lib/docsify.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ahhh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
(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 renderer = new marked.Renderer(); | ||
|
||
/** | ||
* render anchor tag | ||
* @link https://github.com/chjj/marked#overriding-renderer-methods | ||
*/ | ||
renderer.heading = function (text, level) { | ||
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); | ||
|
||
return '<h' + level + '><a name="' + escapedText + '" class="anchor" href="#' + | ||
escapedText + '"><span class="header-link"></span></a>' + text + | ||
'</h' + level + '>' | ||
}; | ||
|
||
marked.setOptions({ | ||
highlight: function highlight (code, lang) { | ||
return Prism.highlight(code, Prism.languages[lang]) | ||
} | ||
}); | ||
|
||
var render = function (content) { | ||
return marked(content, { renderer: renderer }) | ||
}; | ||
|
||
var Docsify = function Docsify (opts) { | ||
if ( opts === void 0 ) opts = {}; | ||
|
||
Docsify.installed = true; | ||
|
||
this.dom = document.querySelector(opts.el || 'body'); | ||
this.loc = document.location.pathname; | ||
this.loc = this.loc === '/' ? 'README' : this.loc; | ||
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); | ||
} | ||
}); | ||
}; | ||
|
||
Docsify.prototype.render = function render$1 (content) { | ||
this.dom.innerHTML = render(content); | ||
}; | ||
|
||
window.addEventListener('load', function () { | ||
if (Docsify.installed) { return } | ||
new Docsify(); | ||
}); | ||
|
||
return Docsify; | ||
|
||
}))); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "docsify", | ||
"version": "0.0.0", | ||
"description": "A magical documentation generator.", | ||
"main": "index.js", | ||
"files": [ | ||
"lib", | ||
"themes" | ||
], | ||
"scripts": { | ||
"build": "rollup -c && uglifyjs lib/docsify.js -o lib/docsify.min.js", | ||
"dev": "nodemon -w src -x 'rollup -c && node test/server.js'", | ||
"test": "eslint src server" | ||
}, | ||
"keywords": [ | ||
"doc", | ||
"docs", | ||
"documentation", | ||
"creator", | ||
"generator" | ||
], | ||
"author": "qingwei-li <[email protected]> (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" | ||
}, | ||
"dependencies": { | ||
"marked": "^0.3.6", | ||
"prismjs": "^1.5.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import buble from 'rollup-plugin-buble' | ||
|
||
export default { | ||
entry: 'src/index.js', | ||
dest: 'lib/docsify.js', | ||
plugins: [buble()], | ||
globals: { | ||
marked: 'marked', | ||
prismjs: 'Prism' | ||
}, | ||
format: 'umd', | ||
moduleName: 'Docsify' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function (url, options = {}) { | ||
const xhr = new XMLHttpRequest() | ||
|
||
xhr.open(options.method || 'get', url) | ||
xhr.send() | ||
|
||
return { | ||
then: cb => xhr.addEventListener('load', cb) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import ajax from './ajax' | ||
import render from './render' | ||
|
||
class Docsify { | ||
constructor (opts = {}) { | ||
Docsify.installed = true | ||
|
||
this.dom = document.querySelector(opts.el || 'body') | ||
this.loc = document.location.pathname | ||
this.loc = this.loc === '/' ? 'README' : this.loc | ||
this.load() | ||
} | ||
|
||
load () { | ||
ajax(`${this.loc}.md`).then(res => { | ||
const target = res.target | ||
if (target.status >= 400) { | ||
this.render('not found') | ||
} else { | ||
this.render(res.target.response) | ||
} | ||
}) | ||
} | ||
|
||
render (content) { | ||
this.dom.innerHTML = render(content) | ||
} | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
if (Docsify.installed) return | ||
new Docsify() | ||
}) | ||
|
||
export default Docsify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import marked from 'marked' | ||
import Prism from 'prismjs' | ||
|
||
const renderer = new marked.Renderer() | ||
|
||
/** | ||
* render anchor tag | ||
* @link https://github.com/chjj/marked#overriding-renderer-methods | ||
*/ | ||
renderer.heading = function (text, level) { | ||
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-') | ||
|
||
return '<h' + level + '><a name="' + escapedText + '" class="anchor" href="#' + | ||
escapedText + '"><span class="header-link"></span></a>' + text + | ||
'</h' + level + '>' | ||
} | ||
|
||
marked.setOptions({ | ||
highlight (code, lang) { | ||
return Prism.highlight(code, Prism.languages[lang]) | ||
} | ||
}) | ||
|
||
export default function (content) { | ||
return marked(content, { renderer }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>docsify</title> | ||
<link rel="stylesheet" href="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="docsify.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# docsify | ||
> A magical documentation generator. | ||
## Usage | ||
Create `404.html` into `/docs` | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<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/highlight.js/lib/highlight.js"></script> | ||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script> | ||
</html> | ||
``` | ||
|
||
```javascript | ||
var a = require('a') | ||
console.log(a) | ||
``` | ||
|
||
## License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../lib/docsify.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Themes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../themes |
Empty file.