Repository: oceanhouse21/dokker
Branch: master
Commit: 34e15326023b
Files: 27
Total size: 121.7 KB
Directory structure:
gitextract_owqcwv6i/
├── .dokker.json
├── .gitignore
├── .jshintrc
├── .travis.yml
├── LICENSE
├── README.md
├── bin/
│ ├── dokker
│ ├── dokker-init
│ ├── dokker-watch
│ └── gh-pages
├── docs/
│ ├── CNAME
│ ├── README.md
│ ├── annotated/
│ │ ├── docco.css
│ │ ├── dokker.html
│ │ └── public/
│ │ └── stylesheets/
│ │ └── normalize.css
│ ├── app.js
│ ├── index.html
│ ├── styles.css
│ └── tests.html
├── dokker.js
├── gulpfile.js
├── package.json
├── templates/
│ ├── app.js
│ ├── index.ejs.html
│ ├── styles.css
│ └── tests.ejs.html
└── test/
└── dokker.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .dokker.json
================================================
{
"dir": "docs",
"literate": {
"source": "dokker.js",
"dir": "annotated"
},
"jsdoc": {
"title": "Dokker.js",
"source": "dokker.js",
"markdown": "README.md",
"html": "index.html",
"readme": "README.md",
"template": "templates/index.ejs.html",
"github": "https://github.com/oceanhouse21/dokker/blob/master/dokker.js",
"site": "http://dokkerjs.com"
},
"mocha": {
"command": "mocha --reporter doc",
"test": "test/dokker.js",
"path": "tests.html",
"template": "templates/tests.ejs.html"
}
}
================================================
FILE: .gitignore
================================================
.tmp
node_modules
================================================
FILE: .jshintrc
================================================
{
"node": true,
"mocha": true
}
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
- "iojs"
- "iojs-v1.0.4"
================================================
FILE: LICENSE
================================================
Copyright 2014-2015 Oceanhouse21 <http://oceanhouse21.com/>
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.
================================================
FILE: README.md
================================================

Dokker.js creates professional Javascript code documentations.
[See Dokker.js documentation as example.](http://dokkerjs.com)
[](https://travis-ci.org/oceanhouse21/dokker)
## Features
* Create or [HTML](http://dokkerjs.com/) or [markdown](https://github.com/oceanhouse21/dokker/tree/master/docs#dokkerjs-api-documentation) documentation from [JSDOC](http://usejsdoc.org/) tags
* Support for [literate programming](https://en.wikipedia.org/?title=Literate_programming) documentation
* Live edit source code and watch changes
* Include link to your Github repository
* Customize your own templates with [ejs](http://www.embeddedjs.com/) or use default style
* Create feature description from [mocha test suite](http://mochajs.org/)
* Automagically include your README.md into the documentation
* Use your own logo to make an astonishing impression
* Deploy documentation to Github pages on the fly
## Community
[](https://gitter.im/oceanhouse21/dokker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
## Installation
Dokker is available as npm package. So the easiest way is to install dokker as global module into your project:
```
npm install -g dokker
```
## Usage
After installation you can execute Dokker with the help of several terminal commands.
**Bootstrap Dokker project**
Dokker needs a configuration file to execute, such as a [.travis](https://travis-ci.org/) or [.jshintrc](http://jshint.com/docs/). You can easily create .dokker.json file with the ```dokker-init``` command from the root directory of your project or copy an [example file](https://github.com/oceanhouse21/dokker/blob/master/.dokker.json).
Dokker provides a default template for your project. The template is based on an [ejs](http://www.embeddedjs.com/) file. Either you use the default template or modify it. If you choose for the latter you can copy the [templates directory](https://github.com/oceanhouse21/dokker/tree/master/templates) and tweak the ejs files how you like.
**Create documentation**
Creating a documentation is really simple with the help of Dokker. You just configure the [.dokker.json](https://github.com/oceanhouse21/dokker/blob/master/.dokker.json) file and execute ```dokker```. Then you're done.
**Live edit your documentation**
If you want to work on your source file and see how the documentation evolves, you can do ```dokker-watch``` and it will open a browser with live preview.
<!-- Node.js/Express server is started for you that serves your Dokker project at [localhost:9000](http://localhost:9000).
If you want to use the live edit function please install the [LiveReload](http://livereload.com/) plugin for your browser. You can then even start a ```nodemon docs/app.js``` and whenever you hit save the HTML site is reloading. But before you might need ```npm install -g nodemon```. -->
**Deploy to Github Pages**
If you want to deploy your documentation to Github Pages, run ```gh-pages```. Finally a separate branch, named ```gh-pages``` is created from the ```docs``` folder. That is enough for Github to serve your documentation. Please do not forget to ```git commit``` your changes before your run ```gh-pages``` command.
## Dokker in the wild
Some examples by our users. Let us know what you did with Dokker too!
- [Dokker.js](http://dokkerjs.com)
- [lomath](http://kengz.github.io/lomath/)
## Further Reading
* [API Documentation](http://dokkerjs.com)
* [Changelog](https://github.com/oceanhouse21/dokker/wiki/Changelog)
* [Release Notes](https://github.com/oceanhouse21/dokker/releases)
* [Roadmap](https://github.com/oceanhouse21/dokker/wiki/Roadmap)
* [More Resources](https://github.com/oceanhouse21/dokker/wiki/Resources)
## Contributors
Dokker.js was originally created by [georgschlenkhoff](https://github.com/georgschlenkhoff), and transferred to [kengz](https://github.com/kengz) on 16 Jun 2016 for further development.
* [georgschlenkhoff](https://github.com/georgschlenkhoff) *(original author)*
* [kengz](https://github.com/kengz)
================================================
FILE: bin/dokker
================================================
#!/usr/bin/env node
var path = require('path');
var Dokker = require('../dokker');
var options;
return Dokker.configure()
.then(function(data) {
options = data;
return Dokker.mkdir(path.join(process.cwd(), options.dir));
}).then(function() {
return Dokker.jsdocMarkdown(options.jsdoc);
}).then(function() {
return Dokker.jsdocHtml(options.jsdoc);
}).then(function() {
return Dokker.injectTemplate(options.jsdoc);
}).then(function() {
return Dokker.createTests(options.mocha);
}).then(function() {
return Dokker.literate(options.literate);
}).then(function() {
console.log('Dokker executed successfully');
}).done();
================================================
FILE: bin/dokker-init
================================================
#!/usr/bin/env node
var Dokker = require('../dokker');
var path = require('path');
var options;
return Dokker.init()
.then(function(){
return Dokker.configure();
}).then(function(data){
options = data;
return Dokker.mkdir(path.join(process.cwd(), options.dir));
}).then(function(){
return Dokker.copyTemplate(options);
}).then(function(){
console.log('Templates copied sucessfully');
}).done();
================================================
FILE: bin/dokker-watch
================================================
#!/usr/bin/env node
var Dokker = require('../dokker');
var options = Dokker.configure()
.then(function(data){
return Dokker.watch(data);
}).then(function(){
console.log('Watching for changes');
}).done();
================================================
FILE: bin/gh-pages
================================================
#!/usr/bin/env node
var dokker = require('../dokker');
return dokker.ghPages()
.then(function(){
console.log('Successfully created gh-pages branch');
}).done();
================================================
FILE: docs/CNAME
================================================
dokkerjs.com
================================================
FILE: docs/README.md
================================================
# dokker.js API documentation
<!-- div class="toc-container" -->
<!-- div -->
## `Github Pages`
* <a href="#Dokker-ghPages">`Dokker.ghPages`</a>
<!-- /div -->
<!-- div -->
## `JSDoc`
* <a href="#Dokker-injectTemplate">`Dokker.injectTemplate`</a>
* <a href="#Dokker-jsdocHtml">`Dokker.jsdocHtml`</a>
* <a href="#Dokker-jsdocMarkdown">`Dokker.jsdocMarkdown`</a>
<!-- /div -->
<!-- div -->
## `Literate programming`
* <a href="#Dokker-literate">`Dokker.literate`</a>
<!-- /div -->
<!-- div -->
## `Mocha`
* <a href="#Dokker-createTests">`Dokker.createTests`</a>
<!-- /div -->
<!-- div -->
## `Utility`
* <a href="#Dokker-configure">`Dokker.configure`</a>
* <a href="#Dokker-copyTemplate">`Dokker.copyTemplate`</a>
* <a href="#Dokker-init">`Dokker.init`</a>
* <a href="#Dokker-watch">`Dokker.watch`</a>
<!-- /div -->
<!-- div -->
## `Methods`
<!-- /div -->
<!-- div -->
## `Properties`
* <a href="#Dokker-VERSION">`Dokker.VERSION`</a>
<!-- /div -->
<!-- /div -->
<!-- div class="doc-container" -->
<!-- div -->
## `“Github Pages” Methods`
<!-- div -->
### <a id="Dokker-ghPages"></a>`Dokker.ghPages()`
<a href="#Dokker-ghPages">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L152 "View in source") [Ⓣ][1]
Runs a terminal shell with the git command to extract the docs branch
into a seperate gh-pages branch and finally pushes that branch to Github,
so that the Github page is updated.
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
Dokker.ghPages()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- /div -->
<!-- div -->
## `“JSDoc” Methods`
<!-- div -->
### <a id="Dokker-injectTemplate"></a>`Dokker.injectTemplate([options])`
<a href="#Dokker-injectTemplate">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L56 "View in source") [Ⓣ][1]
Creates a HTML file that transcludes the HTML snippet that was created
by the docdown module into an ejs template which is defined by the
.dokker.json configuration file.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.template='template/index.ejs.html']` *(String)*: The path to the ejs template file.
3. `[options.html='docs/index.html']` *(string)*: The path to the docdown generated JSDoc documentation.
4. `[options.readme='README.md']` *(string)*: The path to the README.md file.
5. `[options.title='']` *(string)*: The title for the documentation.
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
var options = {
template: 'template/index.ejs.html',
html: 'docs/index.html',
readme: 'docs/README.md',
title: 'Dokker.js API Documentation'
};
Dokker.injectTemplate(options)
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- div -->
### <a id="Dokker-jsdocHtml"></a>`Dokker.jsdocHtml([options])`
<a href="#Dokker-jsdocHtml">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L288 "View in source") [Ⓣ][1]
Create an HTML file from the Markdown file that was create with
[Dokker.jsdocMarkdown()](#Dokker-jsdocMarkdown)
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file.
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
var options = {
markdown: 'docs/README.md'
};
Dokker.jsdocHtml()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- div -->
### <a id="Dokker-jsdocMarkdown"></a>`Dokker.jsdocMarkdown([options])`
<a href="#Dokker-jsdocMarkdown">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L237 "View in source") [Ⓣ][1]
Create a Markdown file from JSDoc tags.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.source='app.js']` *(String)*: The path the source code with JSDoc tags.
3. `[options.github ='']` *(String)*: The path the Github repository.
4. `[options.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file.
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
var options = {
source: 'app.js',
markdown: 'docs/README.md'
};
Dokker.jsdocMarkdown()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- /div -->
<!-- div -->
## `“Literate programming” Methods`
<!-- div -->
### <a id="Dokker-literate"></a>`Dokker.literate([options])`
<a href="#Dokker-literate">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L189 "View in source") [Ⓣ][1]
Create a styled HTML file from your source code with the help of **docco**
module.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.source='app.js']` *(String)*: The path the source code with comments
3. `[options.dir='docs/annotated']` *(string)*: The directory where to save the generated HTML file.
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
var options = {
dir: 'docs',
source: 'app.js'
};
Dokker.literate()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- /div -->
<!-- div -->
## `“Mocha” Methods`
<!-- div -->
### <a id="Dokker-createTests"></a>`Dokker.createTests([options])`
<a href="#Dokker-createTests">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L113 "View in source") [Ⓣ][1]
Creates an HTML file to describe the features of your module from your
**Mocha** tests. The module is using the mocha **doc** reporter to
generate the HTML contents.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.path='docs.html']` *(String)*: The path where to save the HTML file
#### Returns
*(Promise)*: Returns a resolved promise if file was created.
#### Example
```js
var options = {
path: 'docs/tests.html',
};
Dokker.createTests(options)
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- /div -->
<!-- div -->
## `“Utility” Methods`
<!-- div -->
### <a id="Dokker-configure"></a>`Dokker.configure([options])`
<a href="#Dokker-configure">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L361 "View in source") [Ⓣ][1]
Helper function that takes a couple of options arguments and
normalises them and subsequently returns them.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.li.markdown='docs/READMDE.md']` *(string)*: The path where to
3. `[options.source='app.js']` *(String)*: The path the source code with JSDoc tags.
4. `[options.jsdoc.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file.
5. `[options.jsdoc.README ='READMDE.md']` *(string)*: The path to the project's README.md file
6. `[options.jsodc.template ='templates/index.ejs.html']` *(String)*: The path to the ejs template.
7. `[options.mocha.template='templates/tests.ejs.html']` *(String)*: The path to the mocha template.
8. `[options.dir='docs']` *(String)*: The path where to store the generated files
#### Returns
*(Promise)*: Returns a resolved promise with edited options object
#### Example
```js
var options = {
dir: 'docs',
literate: {
source: 'dokker.js',
dir: 'annotated'
},
jsdoc: {
title: 'Dokker.js',
source: 'dokker.js',
markdown: 'README.md',
html: 'index.html',
readme: 'README.md',
}
};
Dokker.jsdocHtml()
.then(function(){
// => object with absolute pathes to the directory from
// which the command was executed
});
```
* * *
<!-- /div -->
<!-- div -->
### <a id="Dokker-copyTemplate"></a>`Dokker.copyTemplate([options])`
<a href="#Dokker-copyTemplate">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L403 "View in source") [Ⓣ][1]
Copy the template to local directory so that one can make changes to ejs
files.
#### Arguments
1. `[options]` *(Object)*: The options object.
2. `[options.dir='templates']` *(string)*: The path where to save the template files
#### Returns
*(Promise)*: Returns a resolved promise if files were created.
#### Example
```js
var options = {
dir: 'template'
};
Dokker.copyTemplate()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- div -->
### <a id="Dokker-init"></a>`Dokker.init()`
<a href="#Dokker-init">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L437 "View in source") [Ⓣ][1]
Create a .dokker.json file to bootstrap any Dokker project
#### Returns
*(Promise)*: Returns a resolved promise if files were created.
#### Example
```js
Dokker.init()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- div -->
### <a id="Dokker-watch"></a>`Dokker.watch()`
<a href="#Dokker-watch">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L462 "View in source") [Ⓣ][1]
Starts a Node.js/Express webserver in docs directory to watch
the build Dokker project
#### Returns
*(Promise)*: Returns a resolved promise if files were created.
#### Example
```js
Dokker.init()
.then(function(){
// => resolved promise
});
```
* * *
<!-- /div -->
<!-- /div -->
<!-- div -->
## `Methods`
<!-- /div -->
<!-- div -->
## `Properties`
<!-- div -->
### <a id="Dokker-VERSION"></a>`Dokker.VERSION`
<a href="#Dokker-VERSION">#</a> [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L23 "View in source") [Ⓣ][1]
(string): The semantic version number.
* * *
<!-- /div -->
<!-- /div -->
<!-- /div -->
[1]: #github pages "Jump back to the TOC."
================================================
FILE: docs/annotated/docco.css
================================================
/*--------------------- Typography ----------------------------*/
@font-face {
font-family: 'aller-light';
src: url('public/fonts/aller-light.eot');
src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'),
url('public/fonts/aller-light.woff') format('woff'),
url('public/fonts/aller-light.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'aller-bold';
src: url('public/fonts/aller-bold.eot');
src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'),
url('public/fonts/aller-bold.woff') format('woff'),
url('public/fonts/aller-bold.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'roboto-black';
src: url('public/fonts/roboto-black.eot');
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
url('public/fonts/roboto-black.woff') format('woff'),
url('public/fonts/roboto-black.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/*--------------------- Layout ----------------------------*/
html { height: 100%; }
body {
font-family: "aller-light";
font-size: 14px;
line-height: 18px;
color: #30404f;
margin: 0; padding: 0;
height:100%;
}
#container { min-height: 100%; }
a {
color: #000;
}
b, strong {
font-weight: normal;
font-family: "aller-bold";
}
p {
margin: 15px 0 0px;
}
.annotation ul, .annotation ol {
margin: 25px 0;
}
.annotation ul li, .annotation ol li {
font-size: 14px;
line-height: 18px;
margin: 10px 0;
}
h1, h2, h3, h4, h5, h6 {
color: #112233;
line-height: 1em;
font-weight: normal;
font-family: "roboto-black";
text-transform: uppercase;
margin: 30px 0 15px 0;
}
h1 {
margin-top: 40px;
}
h2 {
font-size: 1.26em;
}
hr {
border: 0;
background: 1px #ddd;
height: 1px;
margin: 20px 0;
}
pre, tt, code {
font-size: 12px; line-height: 16px;
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
.annotation pre {
display: block;
margin: 0;
padding: 7px 10px;
background: #fcfcfc;
-moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
overflow-x: auto;
}
.annotation pre code {
border: 0;
padding: 0;
background: transparent;
}
blockquote {
border-left: 5px solid #ccc;
margin: 0;
padding: 1px 0 1px 1em;
}
.sections blockquote p {
font-family: Menlo, Consolas, Monaco, monospace;
font-size: 12px; line-height: 16px;
color: #999;
margin: 10px 0 0;
white-space: pre-wrap;
}
ul.sections {
list-style: none;
padding:0 0 5px 0;;
margin:0;
}
/*
Force border-box so that % widths fit the parent
container without overlap because of margin/padding.
More Info : http://www.quirksmode.org/css/box.html
*/
ul.sections > li > div {
-moz-box-sizing: border-box; /* firefox */
-ms-box-sizing: border-box; /* ie */
-webkit-box-sizing: border-box; /* webkit */
-khtml-box-sizing: border-box; /* konqueror */
box-sizing: border-box; /* css3 */
}
/*---------------------- Jump Page -----------------------------*/
#jump_to, #jump_page {
margin: 0;
background: white;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
font: 16px Arial;
cursor: pointer;
text-align: right;
list-style: none;
}
#jump_to a {
text-decoration: none;
}
#jump_to a.large {
display: none;
}
#jump_to a.small {
font-size: 22px;
font-weight: bold;
color: #676767;
}
#jump_to, #jump_wrapper {
position: fixed;
right: 0; top: 0;
padding: 10px 15px;
margin:0;
}
#jump_wrapper {
display: none;
padding:0;
}
#jump_to:hover #jump_wrapper {
display: block;
}
#jump_page_wrapper{
position: fixed;
right: 0;
top: 0;
bottom: 0;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
max-height: 100%;
overflow: auto;
}
#jump_page .source {
display: block;
padding: 15px;
text-decoration: none;
border-top: 1px solid #eee;
}
#jump_page .source:hover {
background: #f5f5ff;
}
#jump_page .source:first-child {
}
/*---------------------- Low resolutions (> 320px) ---------------------*/
@media only screen and (min-width: 320px) {
.pilwrap { display: none; }
ul.sections > li > div {
display: block;
padding:5px 10px 0 10px;
}
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
padding-left: 30px;
}
ul.sections > li > div.content {
overflow-x:auto;
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
box-shadow: inset 0 0 5px #e5e5ee;
border: 1px solid #dedede;
margin:5px 10px 5px 10px;
padding-bottom: 5px;
}
ul.sections > li > div.annotation pre {
margin: 7px 0 7px;
padding-left: 15px;
}
ul.sections > li > div.annotation p tt, .annotation code {
background: #f8f8ff;
border: 1px solid #dedede;
font-size: 12px;
padding: 0 0.2em;
}
}
/*---------------------- (> 481px) ---------------------*/
@media only screen and (min-width: 481px) {
#container {
position: relative;
}
body {
background-color: #F5F5FF;
font-size: 15px;
line-height: 21px;
}
pre, tt, code {
line-height: 18px;
}
p, ul, ol {
margin: 0 0 15px;
}
#jump_to {
padding: 5px 10px;
}
#jump_wrapper {
padding: 0;
}
#jump_to, #jump_page {
font: 10px Arial;
text-transform: uppercase;
}
#jump_page .source {
padding: 5px 10px;
}
#jump_to a.large {
display: inline-block;
}
#jump_to a.small {
display: none;
}
#background {
position: absolute;
top: 0; bottom: 0;
width: 350px;
background: #fff;
border-right: 1px solid #e5e5ee;
z-index: -1;
}
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
padding-left: 40px;
}
ul.sections > li {
white-space: nowrap;
}
ul.sections > li > div {
display: inline-block;
}
ul.sections > li > div.annotation {
max-width: 350px;
min-width: 350px;
min-height: 5px;
padding: 13px;
overflow-x: hidden;
white-space: normal;
vertical-align: top;
text-align: left;
}
ul.sections > li > div.annotation pre {
margin: 15px 0 15px;
padding-left: 15px;
}
ul.sections > li > div.content {
padding: 13px;
vertical-align: top;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.pilwrap {
position: relative;
display: inline;
}
.pilcrow {
font: 12px Arial;
text-decoration: none;
color: #454545;
position: absolute;
top: 3px; left: -20px;
padding: 1px 2px;
opacity: 0;
-webkit-transition: opacity 0.2s linear;
}
.for-h1 .pilcrow {
top: 47px;
}
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow {
top: 35px;
}
ul.sections > li > div.annotation:hover .pilcrow {
opacity: 1;
}
}
/*---------------------- (> 1025px) ---------------------*/
@media only screen and (min-width: 1025px) {
body {
font-size: 16px;
line-height: 24px;
}
#background {
width: 525px;
}
ul.sections > li > div.annotation {
max-width: 525px;
min-width: 525px;
padding: 10px 25px 1px 50px;
}
ul.sections > li > div.content {
padding: 9px 15px 16px 25px;
}
}
/*---------------------- Syntax Highlighting -----------------------------*/
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
/*
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
pre code {
display: block; padding: 0.5em;
color: #000;
background: #f8f8ff
}
pre .hljs-comment,
pre .hljs-template_comment,
pre .hljs-diff .hljs-header,
pre .hljs-javadoc {
color: #408080;
font-style: italic
}
pre .hljs-keyword,
pre .hljs-assignment,
pre .hljs-literal,
pre .hljs-css .hljs-rule .hljs-keyword,
pre .hljs-winutils,
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
color: #954121;
/*font-weight: bold*/
}
pre .hljs-number,
pre .hljs-hexcolor {
color: #40a070
}
pre .hljs-string,
pre .hljs-tag .hljs-value,
pre .hljs-phpdoc,
pre .hljs-tex .hljs-formula {
color: #219161;
}
pre .hljs-title,
pre .hljs-id {
color: #19469D;
}
pre .hljs-params {
color: #00F;
}
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
font-weight: normal
}
pre .hljs-class .hljs-title,
pre .hljs-haskell .hljs-label,
pre .hljs-tex .hljs-command {
color: #458;
font-weight: bold
}
pre .hljs-tag,
pre .hljs-tag .hljs-title,
pre .hljs-rules .hljs-property,
pre .hljs-django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal
}
pre .hljs-attribute,
pre .hljs-variable,
pre .hljs-instancevar,
pre .hljs-lisp .hljs-body {
color: #008080
}
pre .hljs-regexp {
color: #B68
}
pre .hljs-class {
color: #458;
font-weight: bold
}
pre .hljs-symbol,
pre .hljs-ruby .hljs-symbol .hljs-string,
pre .hljs-ruby .hljs-symbol .hljs-keyword,
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
pre .hljs-lisp .hljs-keyword,
pre .hljs-tex .hljs-special,
pre .hljs-input_number {
color: #990073
}
pre .hljs-builtin,
pre .hljs-constructor,
pre .hljs-built_in,
pre .hljs-lisp .hljs-title {
color: #0086b3
}
pre .hljs-preprocessor,
pre .hljs-pi,
pre .hljs-doctype,
pre .hljs-shebang,
pre .hljs-cdata {
color: #999;
font-weight: bold
}
pre .hljs-deletion {
background: #fdd
}
pre .hljs-addition {
background: #dfd
}
pre .hljs-diff .hljs-change {
background: #0086b3
}
pre .hljs-chunk {
color: #aaa
}
pre .hljs-tex .hljs-formula {
opacity: 0.5;
}
================================================
FILE: docs/annotated/dokker.html
================================================
<!DOCTYPE html>
<html>
<head>
<title>dokker.js</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>dokker.js</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
<pre><code>Dokker.js <span class="hljs-number">0.0</span>.1
http:<span class="hljs-comment">//dokker.oceanhouse21.com</span>
(c) <span class="hljs-number">2014</span>-<span class="hljs-number">2015</span> Georg Schlenkhoff and Oceanhouse21
Dokker.js may be freely distributed under the MIT license.
</code></pre>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-pi">
'use strict'</span>;</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<p>Define required dependencies</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">var</span> <span class="hljs-built_in">Promise</span> = <span class="hljs-built_in">require</span>(<span class="hljs-string">'promise'</span>);
<span class="hljs-keyword">var</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">var</span> path = <span class="hljs-built_in">require</span>(<span class="hljs-string">'path'</span>);
<span class="hljs-keyword">var</span> read = <span class="hljs-built_in">Promise</span>.denodeify(fs.readFile);
<span class="hljs-keyword">var</span> write = <span class="hljs-built_in">Promise</span>.denodeify(fs.writeFile);
<span class="hljs-keyword">var</span> docco = <span class="hljs-built_in">require</span>(<span class="hljs-string">'docco'</span>);
<span class="hljs-keyword">var</span> docdown = <span class="hljs-built_in">require</span>(<span class="hljs-string">'docdown'</span>);
<span class="hljs-keyword">var</span> marked = <span class="hljs-built_in">require</span>(<span class="hljs-string">'marked'</span>);
<span class="hljs-keyword">var</span> ejs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ejs'</span>);
<span class="hljs-keyword">var</span> cheerio = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cheerio'</span>);
<span class="hljs-keyword">var</span> exec = <span class="hljs-built_in">require</span>(<span class="hljs-string">'child_process'</span>).exec;
<span class="hljs-keyword">var</span> Dokker = {};
Dokker.VERSION = <span class="hljs-string">'0.1.2'</span>;</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p>Transclude in a ejs template file the HTML snippet that was ultimately
created with docdown. Also tweak the HTML page a bit and finally
inject the README.md.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.injectTemplate = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> template, body, html, readme, $;
<span class="hljs-keyword">return</span> read(options.template, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
template = data;
<span class="hljs-keyword">return</span> read(options.readme, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
readme = marked(data);
$ = cheerio.load(readme);
$(<span class="hljs-string">'h1'</span>).remove();
readme = $.html();
<span class="hljs-keyword">return</span> read(options.html, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
$ = cheerio.load(data);
<span class="hljs-keyword">return</span> ejs.render(template, {
apiToc: $(<span class="hljs-string">'.toc-container'</span>).html(),
readme: readme,
apiDoc: $(<span class="hljs-string">'.doc-container'</span>).html(),</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p>correctly setting links to your github/pages</p>
</div>
<div class="content"><div class='highlight'><pre> page_url: options.site,
title: options.title,
github_url: options.github,</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>fixed reference to generated annotation
the ‘literate’ in .dokker.json shall not require a source since it’s never used.</p>
</div>
<div class="content"><div class='highlight'><pre> annotated_path: <span class="hljs-string">'annotated/'</span>+options.source
});
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
<span class="hljs-keyword">return</span> write(options.html, data, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
resolve();
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
reject(err);
});
});
};</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">¶</a>
</div>
<p>Create a HTML site from any mocha tests find when executing mocha
—reporter doc terminal command.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.createTests = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> template, tests;</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">¶</a>
</div>
<p>allows specification of mocha.command in .dokker.json, e.g. ‘mocha -u tdd —reporter doc’</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> cmd = options.command || <span class="hljs-string">'mocha --reporter doc'</span>;
exec(cmd, {cwd: process.cwd()}, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">error, stdout</span>) </span>{
<span class="hljs-keyword">if</span>(error) <span class="hljs-keyword">return</span> reject(error);
tests = stdout;
<span class="hljs-keyword">return</span> read(options.template, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
template = data;
<span class="hljs-keyword">return</span> ejs.render(template, {tests: tests});
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
<span class="hljs-keyword">return</span> write(options.path, data, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
resolve();
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
reject(err);
});
});
});
};</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">¶</a>
</div>
<p>Extract docs folder to separate git branch and finally push branch to
Github repository</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.ghPages = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
exec(<span class="hljs-string">'git subtree split -P docs -b gh-pages'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">error, stdout, stderr</span>) </span>{
<span class="hljs-keyword">if</span>(error) <span class="hljs-keyword">return</span> reject(stderr);
exec(<span class="hljs-string">'git push origin gh-pages'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">error, stdout, stderr</span>) </span>{
<span class="hljs-keyword">if</span>(error) <span class="hljs-keyword">return</span> reject(stderr);
resolve();
});
});
});
};</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">¶</a>
</div>
<p>Create an HTML file from any source code comments in the style of
<a href="https://de.wikipedia.org/wiki/Literate_programming">literate programming</a></p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.literate = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> tmpDir = path.join(process.cwd(), <span class="hljs-string">'/.tmp'</span>);
<span class="hljs-keyword">var</span> tmpFile = path.join(tmpDir, options.source);
<span class="hljs-keyword">var</span> sourceFile = (options.cwd) ?
path.join(process.cwd(), options.cwd, options.source) :
path.join(process.cwd(), options.source);
<span class="hljs-keyword">return</span> read(sourceFile, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
<span class="hljs-keyword">var</span> source = data.replace(<span class="hljs-regexp">/^\s*(\*|\/\*).*[\r\n]/gm</span>, <span class="hljs-string">''</span>);
<span class="hljs-keyword">return</span> Dokker.mkdir(tmpDir)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-keyword">return</span> write(tmpFile, source, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
docco.run([<span class="hljs-string">''</span>, <span class="hljs-string">''</span>, tmpFile, <span class="hljs-string">'-o'</span>, options.dir]);
resolve();
});
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">return</span> reject(err);
});
});
};</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">¶</a>
</div>
<p>Convert markdown from any source code comments with docdown module.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.jsdocMarkdown = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> source, tmpFile, tmpDir;
<span class="hljs-keyword">var</span> sourceFile = (options.cwd) ?
path.join(process.cwd(), options.cwd, options.source) :
path.join(process.cwd(), options.source);
<span class="hljs-keyword">return</span> read(sourceFile, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>)</span>{
source = data.replace(<span class="hljs-regexp">/^\s*(\/\/).*[\r\n]/gm</span>, <span class="hljs-string">''</span>);
tmpDir = path.join(process.cwd(), <span class="hljs-string">'/.tmp'</span>);
<span class="hljs-keyword">return</span> Dokker.mkdir(tmpDir);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
tmpFile = path.join(tmpDir, options.source);
<span class="hljs-keyword">return</span> write(tmpFile, source, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-keyword">var</span> markdown = docdown({
<span class="hljs-string">'path'</span>: tmpFile,
<span class="hljs-string">'url'</span>: options.github,
<span class="hljs-string">'toc'</span>: <span class="hljs-string">'categories'</span>
});
<span class="hljs-keyword">return</span> write(options.markdown, markdown, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
resolve();
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
reject(err);
});
});
};</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">¶</a>
</div>
<p>Create an HTML file from any source code comments in the style of
<a href="https://de.wikipedia.org/wiki/Literate_programming">literate programming</a></p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.jsdocHtml = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">return</span> read(options.markdown, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
<span class="hljs-keyword">var</span> html = marked(data).replace(<span class="hljs-regexp">/<!-- /g</span>,<span class="hljs-string">'<'</span>).replace(<span class="hljs-regexp">/ -->/g</span>,<span class="hljs-string">'>'</span>);
<span class="hljs-keyword">return</span> write(options.html, html, <span class="hljs-string">'utf8'</span>);
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
resolve();
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
reject(err);
});
});
};</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">¶</a>
</div>
<p>Internal helper function that creates any directory if not existing.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.mkdir = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">dir</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
fs.exists(dir, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">exists</span>) </span>{
<span class="hljs-keyword">if</span> (exists) {
resolve();
} <span class="hljs-keyword">else</span> {
fs.mkdir(dir, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">return</span> reject(err);
resolve();
});
}
});
});
};</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">¶</a>
</div>
<p>Parses the options file, .Dokker.json, and sets the default parameters.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.configure = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>)</span>{
<span class="hljs-keyword">var</span> file = path.join(process.cwd(), <span class="hljs-string">'.dokker.json'</span>);
<span class="hljs-keyword">return</span> read(file, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
data = <span class="hljs-built_in">JSON</span>.parse(data);
data.jsdoc.template = (data.jsdoc.template) ? path.join(process.cwd(), data.jsdoc.template) : path.join(__dirname, <span class="hljs-string">'templates/index.ejs.html'</span>);
data.mocha.template = (data.mocha.template) ? path.join(process.cwd(), data.mocha.template) : path.join(__dirname, <span class="hljs-string">'templates/tests.ejs.html'</span>);
data.mocha.path = path.join(process.cwd(), data.dir, data.mocha.path);</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">¶</a>
</div>
<p>mocha.command commented out to fix build-breaking bug
specifies mocha command in .dokker.json; e.g. mocha -u tdd -R spec
data.mocha.command = path.join(process.cwd(), data.dir, data.mocha.command);</p>
</div>
<div class="content"><div class='highlight'><pre> data.literate.dir = path.join(process.cwd(), data.dir, data.literate.dir);
data.jsdoc.markdown = path.join(process.cwd(), data.dir, data.jsdoc.markdown);
data.jsdoc.html = path.join(process.cwd(), data.dir, data.jsdoc.html);
data.jsdoc.readme = path.join(process.cwd(), data.jsdoc.readme);
resolve(data);
}).then(<span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
reject(err);
});
});
};</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">¶</a>
</div>
<p>Copy starter template to bootstrap any Dokker project.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.copyTemplate = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> templatesDir = path.join(process.cwd(), <span class="hljs-string">'templates'</span>);
<span class="hljs-keyword">return</span> Dokker.mkdir(templatesDir)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-keyword">var</span> oldStyle = path.join(__dirname, <span class="hljs-string">'templates'</span>, <span class="hljs-string">'styles.css'</span>);
<span class="hljs-keyword">var</span> newStyle = path.join(process.cwd(), options.dir, <span class="hljs-string">'styles.css'</span>);
fs.createReadStream(oldStyle).pipe(fs.createWriteStream(newStyle));
<span class="hljs-keyword">var</span> oldLogo = path.join(__dirname, <span class="hljs-string">'templates'</span>, <span class="hljs-string">'logo.png'</span>);
<span class="hljs-keyword">var</span> newLogo = path.join(process.cwd(), options.dir, <span class="hljs-string">'logo.png'</span>);
fs.createReadStream(oldLogo).pipe(fs.createWriteStream(newLogo));
<span class="hljs-keyword">var</span> oldApp = path.join(__dirname, <span class="hljs-string">'templates'</span>, <span class="hljs-string">'app.js'</span>);
<span class="hljs-keyword">var</span> newApp = path.join(process.cwd(), options.dir, <span class="hljs-string">'app.js'</span>);
fs.createReadStream(oldApp).pipe(fs.createWriteStream(newApp));
resolve();
});
});
};</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">¶</a>
</div>
<p>Copies the .Dokker.json file to bootstrap any Dokker project.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.init = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
<span class="hljs-keyword">var</span> oldDok = path.join(__dirname, <span class="hljs-string">'.dokker.json'</span>);
<span class="hljs-keyword">var</span> newDok = path.join(process.cwd(), <span class="hljs-string">'.dokker.json'</span>);
fs.createReadStream(oldDok).pipe(fs.createWriteStream(newDok));
resolve();
});
};</pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">¶</a>
</div>
<p>Starts the Node.js/Express server to watch Dokker.js project
documentation.</p>
</div>
<div class="content"><div class='highlight'><pre>Dokker.watch = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{
<span class="hljs-keyword">var</span> gulpex = <span class="hljs-built_in">require</span>(__dirname + <span class="hljs-string">'/gulpfile.js'</span>).gulpex;
<span class="hljs-keyword">return</span> gulpex();</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">¶</a>
</div>
<p>return new Promise(function(resolve, reject){
exec(‘DIR=’+ options.dir + ‘ node ‘ + options.dir + ‘/app.js’, function(error, stdout, stderr){
if(error) return reject(stderr);
});
});</p>
</div>
<div class="content"><div class='highlight'><pre>};
<span class="hljs-built_in">module</span>.exports = Dokker;</pre></div></div>
</li>
</ul>
</div>
</body>
</html>
================================================
FILE: docs/annotated/public/stylesheets/normalize.css
================================================
/*! normalize.css v2.0.1 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE 8/9.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE 8/9.
*/
audio,
canvas,
video {
display: inline-block;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE 8/9.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Sets default font family to sans-serif.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
/*
* Removes default margin.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/*
* Addresses `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/*
* Improves readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/*
* Addresses `h1` font sizes within `section` and `article` in Firefox 4+,
* Safari 5, and Chrome.
*/
h1 {
font-size: 2em;
}
/*
* Addresses styling not present in IE 8/9, Safari 5, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/*
* Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/*
* Addresses styling not present in Safari 5 and Chrome.
*/
dfn {
font-style: italic;
}
/*
* Addresses styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/*
* Corrects font family set oddly in Safari 5 and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
/*
* Improves readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
/*
* Sets consistent quote types.
*/
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
/*
* Addresses inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/*
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Embedded content
========================================================================== */
/*
* Removes border when inside `a` element in IE 8/9.
*/
img {
border: 0;
}
/*
* Corrects overflow displayed oddly in IE 9.
*/
svg:not(:root) {
overflow: hidden;
}
/* ==========================================================================
Figures
========================================================================== */
/*
* Addresses margin not present in IE 8/9 and Safari 5.
*/
figure {
margin: 0;
}
/* ==========================================================================
Forms
========================================================================== */
/*
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/*
* 1. Corrects color not being inherited in IE 8/9.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/*
* 1. Corrects font family not being inherited in all browsers.
* 2. Corrects font size not being inherited in all browsers.
* 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome
*/
button,
input,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 2 */
margin: 0; /* 3 */
}
/*
* Addresses Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
button,
input {
line-height: normal;
}
/*
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Corrects inability to style clickable `input` types in iOS.
* 3. Improves usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/*
* Re-set default cursor for disabled elements.
*/
button[disabled],
input[disabled] {
cursor: default;
}
/*
* 1. Addresses box sizing set to `content-box` in IE 8/9.
* 2. Removes excess padding in IE 8/9.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/*
* 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome.
* 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/*
* Removes inner padding and search cancel button in Safari 5 and Chrome
* on OS X.
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
* Removes inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/*
* 1. Removes default vertical scrollbar in IE 8/9.
* 2. Improves readability and alignment in all browsers.
*/
textarea {
overflow: auto; /* 1 */
vertical-align: top; /* 2 */
}
/* ==========================================================================
Tables
========================================================================== */
/*
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
================================================
FILE: docs/app.js
================================================
var express = require('express');
var app = express();
var path = require('path');
var livereload = require('livereload');
var path = path.join(process.cwd(), process.env.DIR);
livereload.createServer({exts: ['applyJSLive']}).watch(path);
app.use(express.static(path));
app.listen(9000);
================================================
FILE: docs/index.html
================================================
<!DOCTYPE html>
<html lang="en" id="docs">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="author" content="Dokker.js">
<meta name="description" content="This API documentation is built with Dokker.js at dokkerjs.com">
<title>Dokker.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles.css" media="all">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/default.min.css">
</head>
<body>
<div class="toc-container">
<h2><code><a href=http://dokkerjs.com>Dokker.js</a></code></h2>
<ul>
<li><a href="#">Introduction</a></li>
<li><a href=https://github.com/oceanhouse21/dokker/blob/master/dokker.js>Github Repository</a></li>
<li><a href="tests.html">Test suite</a></li>
<li><a href=annotated/dokker.js>Annotated Source</a></li>
</ul>
<div>
<h2 id="-github-pages-"><code>Github Pages</code></h2>
<ul>
<li><a href="#Dokker-ghPages"><code>Dokker.ghPages</code></a></li>
</ul>
</div>
<div>
<h2 id="-jsdoc-"><code>JSDoc</code></h2>
<ul>
<li><a href="#Dokker-injectTemplate"><code>Dokker.injectTemplate</code></a></li>
<li><a href="#Dokker-jsdocHtml"><code>Dokker.jsdocHtml</code></a></li>
<li><a href="#Dokker-jsdocMarkdown"><code>Dokker.jsdocMarkdown</code></a></li>
</ul>
</div>
<div>
<h2 id="-literate-programming-"><code>Literate programming</code></h2>
<ul>
<li><a href="#Dokker-literate"><code>Dokker.literate</code></a></li>
</ul>
</div>
<div>
<h2 id="-mocha-"><code>Mocha</code></h2>
<ul>
<li><a href="#Dokker-createTests"><code>Dokker.createTests</code></a></li>
</ul>
</div>
<div>
<h2 id="-utility-"><code>Utility</code></h2>
<ul>
<li><a href="#Dokker-configure"><code>Dokker.configure</code></a></li>
<li><a href="#Dokker-copyTemplate"><code>Dokker.copyTemplate</code></a></li>
<li><a href="#Dokker-init"><code>Dokker.init</code></a></li>
<li><a href="#Dokker-watch"><code>Dokker.watch</code></a></li>
</ul>
</div>
<div>
<h2 id="-methods-"><code>Methods</code></h2>
</div>
<div>
<h2 id="-properties-"><code>Properties</code></h2>
<ul>
<li><a href="#Dokker-VERSION"><code>Dokker.VERSION</code></a></li>
</ul>
</div>
</div>
<div class="doc-container">
<div>
<p><img src="https://raw.githubusercontent.com/oceanhouse21/dokker/master/templates/logo.png" alt="dokker logo"></p>
<p>Dokker.js creates professional Javascript code documentations.</p>
<p><a href="http://dokkerjs.com">See Dokker.js documentation as example.</a></p>
<p><a href="https://travis-ci.org/oceanhouse21/dokker"><img src="https://travis-ci.org/oceanhouse21/dokker.svg?branch=master" alt="Build Status"></a></p>
<h2 id="features">Features</h2>
<ul>
<li>Create or <a href="http://dokkerjs.com/">HTML</a> or <a href="https://github.com/oceanhouse21/dokker/tree/master/docs#dokkerjs-api-documentation">markdown</a> documentation from <a href="http://usejsdoc.org/">JSDOC</a> tags</li>
<li>Support for <a href="https://en.wikipedia.org/?title=Literate_programming">literate programming</a> documentation</li>
<li>Live edit source code and watch changes</li>
<li>Include link to your Github repository</li>
<li>Customize your own templates with <a href="http://www.embeddedjs.com/">ejs</a> or use default style</li>
<li>Create feature description from <a href="http://mochajs.org/">mocha test suite</a></li>
<li>Automagically include your README.md into the documentation</li>
<li>Use your own logo to make an astonishing impression</li>
<li>Deploy documentation to Github pages on the fly</li>
</ul>
<h2 id="community">Community</h2>
<p><a href="https://gitter.im/oceanhouse21/dokker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter"></a></p>
<h2 id="installation">Installation</h2>
<p>Dokker is available as npm package. So the easiest way is to install dokker as global module into your project:</p>
<pre><code>npm install -g dokker
</code></pre><h2 id="usage">Usage</h2>
<p>After installation you can execute Dokker with the help of several terminal commands.</p>
<p><strong>Bootstrap Dokker project</strong></p>
<p>Dokker needs a configuration file to execute, such as a <a href="https://travis-ci.org/">.travis</a> or <a href="http://jshint.com/docs/">.jshintrc</a>. You can easily create .dokker.json file with the <code>dokker-init</code> command from the root directory of your project or copy an <a href="https://github.com/oceanhouse21/dokker/blob/master/.dokker.json">example file</a>.</p>
<p>Dokker provides a default template for your project. The template is based on an <a href="http://www.embeddedjs.com/">ejs</a> file. Either you use the default template or modify it. If you choose for the latter you can copy the <a href="https://github.com/oceanhouse21/dokker/tree/master/templates">templates directory</a> and tweak the ejs files how you like.</p>
<p><strong>Create documentation</strong></p>
<p>Creating a documentation is really simple with the help of Dokker. You just configure the <a href="https://github.com/oceanhouse21/dokker/blob/master/.dokker.json">.dokker.json</a> file and execute <code>dokker</code>. Then you’re done.</p>
<p><strong>Live edit your documentation</strong></p>
<p>If you want to work on your source file and see how the documentation evolves, you can do <code>dokker-watch</code> and it will open a browser with live preview.</p>
<!-- Node.js/Express server is started for you that serves your Dokker project at [localhost:9000](http://localhost:9000).
If you want to use the live edit function please install the [LiveReload](http://livereload.com/) plugin for your browser. You can then even start a ```nodemon docs/app.js``` and whenever you hit save the HTML site is reloading. But before you might need ```npm install -g nodemon```. -->
<p><strong>Deploy to Github Pages</strong></p>
<p>If you want to deploy your documentation to Github Pages, run <code>gh-pages</code>. Finally a separate branch, named <code>gh-pages</code> is created from the <code>docs</code> folder. That is enough for Github to serve your documentation. Please do not forget to <code>git commit</code> your changes before your run <code>gh-pages</code> command.</p>
<h2 id="dokker-in-the-wild">Dokker in the wild</h2>
<p>Some examples by our users. Let us know what you did with Dokker too!</p>
<ul>
<li><a href="http://dokkerjs.com">Dokker.js</a></li>
<li><a href="http://kengz.github.io/lomath/">lomath</a></li>
</ul>
<h2 id="further-reading">Further Reading</h2>
<ul>
<li><a href="http://dokkerjs.com">API Documentation</a></li>
<li><a href="https://github.com/oceanhouse21/dokker/wiki/Changelog">Changelog</a></li>
<li><a href="https://github.com/oceanhouse21/dokker/releases">Release Notes</a></li>
<li><a href="https://github.com/oceanhouse21/dokker/wiki/Roadmap">Roadmap</a></li>
<li><a href="https://github.com/oceanhouse21/dokker/wiki/Resources">More Resources</a></li>
</ul>
<h2 id="contributors">Contributors</h2>
<ul>
<li><a href="https://github.com/georgschlenkhoff">georgschlenkhoff</a></li>
<li><a href="https://github.com/kengz">kengz</a></li>
</ul>
<h2>API documentation</h2>
<div>
<h2 id="-github-pages-methods-"><code>“Github Pages” Methods</code></h2>
<div>
<h3 id="-a-id-dokker-ghpages-a-dokker-ghpages-"><a id="Dokker-ghPages"></a><code>Dokker.ghPages()</code></h3>
<p><a href="#Dokker-ghPages">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L152" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Runs a terminal shell with the git command to extract the docs branch
into a seperate gh-pages branch and finally pushes that branch to Github,
so that the Github page is updated.</p>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js">Dokker.ghPages()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-jsdoc-methods-"><code>“JSDoc” Methods</code></h2>
<div>
<h3 id="-a-id-dokker-injecttemplate-a-dokker-injecttemplate-options-"><a id="Dokker-injectTemplate"></a><code>Dokker.injectTemplate([options])</code></h3>
<p><a href="#Dokker-injectTemplate">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L56" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Creates a HTML file that transcludes the HTML snippet that was created
by the docdown module into an ejs template which is defined by the
.dokker.json configuration file.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.template='template/index.ejs.html']</code> <em>(String)</em>: The path to the ejs template file.</li>
<li><code>[options.html='docs/index.html']</code> <em>(string)</em>: The path to the docdown generated JSDoc documentation.</li>
<li><code>[options.readme='README.md']</code> <em>(string)</em>: The path to the README.md file.</li>
<li><code>[options.title='']</code> <em>(string)</em>: The title for the documentation.</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
template: <span class="hljs-string">'template/index.ejs.html'</span>,
html: <span class="hljs-string">'docs/index.html'</span>,
readme: <span class="hljs-string">'docs/README.md'</span>,
title: <span class="hljs-string">'Dokker.js API Documentation'</span>
};
Dokker.injectTemplate(options)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-dokker-jsdochtml-a-dokker-jsdochtml-options-"><a id="Dokker-jsdocHtml"></a><code>Dokker.jsdocHtml([options])</code></h3>
<p><a href="#Dokker-jsdocHtml">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L288" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Create an HTML file from the Markdown file that was create with
<a href="#Dokker-jsdocMarkdown">Dokker.jsdocMarkdown()</a></p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.markdown='docs/READMDE.md']</code> <em>(string)</em>: The path where to save the Markdown file.</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
markdown: <span class="hljs-string">'docs/README.md'</span>
};
Dokker.jsdocHtml()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-dokker-jsdocmarkdown-a-dokker-jsdocmarkdown-options-"><a id="Dokker-jsdocMarkdown"></a><code>Dokker.jsdocMarkdown([options])</code></h3>
<p><a href="#Dokker-jsdocMarkdown">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L237" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Create a Markdown file from JSDoc tags.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.source='app.js']</code> <em>(String)</em>: The path the source code with JSDoc tags.</li>
<li><code>[options.github ='']</code> <em>(String)</em>: The path the Github repository.</li>
<li><code>[options.markdown='docs/READMDE.md']</code> <em>(string)</em>: The path where to save the Markdown file.</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
source: <span class="hljs-string">'app.js'</span>,
markdown: <span class="hljs-string">'docs/README.md'</span>
};
Dokker.jsdocMarkdown()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-literate-programming-methods-"><code>“Literate programming” Methods</code></h2>
<div>
<h3 id="-a-id-dokker-literate-a-dokker-literate-options-"><a id="Dokker-literate"></a><code>Dokker.literate([options])</code></h3>
<p><a href="#Dokker-literate">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L189" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Create a styled HTML file from your source code with the help of <strong>docco</strong>
module.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.source='app.js']</code> <em>(String)</em>: The path the source code with comments</li>
<li><code>[options.dir='docs/annotated']</code> <em>(string)</em>: The directory where to save the generated HTML file.</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
dir: <span class="hljs-string">'docs'</span>,
source: <span class="hljs-string">'app.js'</span>
};
Dokker.literate()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-mocha-methods-"><code>“Mocha” Methods</code></h2>
<div>
<h3 id="-a-id-dokker-createtests-a-dokker-createtests-options-"><a id="Dokker-createTests"></a><code>Dokker.createTests([options])</code></h3>
<p><a href="#Dokker-createTests">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L113" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Creates an HTML file to describe the features of your module from your
<strong>Mocha</strong> tests. The module is using the mocha <strong>doc</strong> reporter to
generate the HTML contents.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.path='docs.html']</code> <em>(String)</em>: The path where to save the HTML file</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if file was created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
path: <span class="hljs-string">'docs/tests.html'</span>,
};
Dokker.createTests(options)
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-utility-methods-"><code>“Utility” Methods</code></h2>
<div>
<h3 id="-a-id-dokker-configure-a-dokker-configure-options-"><a id="Dokker-configure"></a><code>Dokker.configure([options])</code></h3>
<p><a href="#Dokker-configure">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L361" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Helper function that takes a couple of options arguments and
normalises them and subsequently returns them.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.li.markdown='docs/READMDE.md']</code> <em>(string)</em>: The path where to</li>
<li><code>[options.source='app.js']</code> <em>(String)</em>: The path the source code with JSDoc tags.</li>
<li><code>[options.jsdoc.markdown='docs/READMDE.md']</code> <em>(string)</em>: The path where to save the Markdown file.</li>
<li><code>[options.jsdoc.README ='READMDE.md']</code> <em>(string)</em>: The path to the project’s README.md file</li>
<li><code>[options.jsodc.template ='templates/index.ejs.html']</code> <em>(String)</em>: The path to the ejs template.</li>
<li><code>[options.mocha.template='templates/tests.ejs.html']</code> <em>(String)</em>: The path to the mocha template.</li>
<li><code>[options.dir='docs']</code> <em>(String)</em>: The path where to store the generated files</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise with edited options object</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
dir: <span class="hljs-string">'docs'</span>,
literate: {
source: <span class="hljs-string">'dokker.js'</span>,
dir: <span class="hljs-string">'annotated'</span>
},
jsdoc: {
title: <span class="hljs-string">'Dokker.js'</span>,
source: <span class="hljs-string">'dokker.js'</span>,
markdown: <span class="hljs-string">'README.md'</span>,
html: <span class="hljs-string">'index.html'</span>,
readme: <span class="hljs-string">'README.md'</span>,
}
};
Dokker.jsdocHtml()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => object with absolute pathes to the directory from</span>
<span class="hljs-comment">// which the command was executed</span>
});
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-dokker-copytemplate-a-dokker-copytemplate-options-"><a id="Dokker-copyTemplate"></a><code>Dokker.copyTemplate([options])</code></h3>
<p><a href="#Dokker-copyTemplate">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L403" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Copy the template to local directory so that one can make changes to ejs
files.</p>
<h4 id="arguments">Arguments</h4>
<ol>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.dir='templates']</code> <em>(string)</em>: The path where to save the template files</li>
</ol>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if files were created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> options = {
dir: <span class="hljs-string">'template'</span>
};
Dokker.copyTemplate()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-dokker-init-a-dokker-init-"><a id="Dokker-init"></a><code>Dokker.init()</code></h3>
<p><a href="#Dokker-init">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L437" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Create a .dokker.json file to bootstrap any Dokker project</p>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if files were created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js">Dokker.init()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-dokker-watch-a-dokker-watch-"><a id="Dokker-watch"></a><code>Dokker.watch()</code></h3>
<p><a href="#Dokker-watch">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L462" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>Starts a Node.js/Express webserver in docs directory to watch
the build Dokker project</p>
<h4 id="returns">Returns</h4>
<p><em>(Promise)</em>: Returns a resolved promise if files were created.</p>
<h4 id="example">Example</h4>
<pre><code class="lang-js">Dokker.init()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-comment">// => resolved promise</span>
});
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-methods-"><code>Methods</code></h2>
</div>
<div>
<h2 id="-properties-"><code>Properties</code></h2>
<div>
<h3 id="-a-id-dokker-version-a-dokker-version-"><a id="Dokker-VERSION"></a><code>Dokker.VERSION</code></h3>
<p><a href="#Dokker-VERSION">#</a> <a href="https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L23" title="View in source">Ⓢ</a> [Ⓣ][1]</p>
<p>(string): The semantic version number.</p>
<hr>
</div>
</div>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
</body>
</html>
================================================
FILE: docs/styles.css
================================================
body,
h1,
h2,
html,
p {
margin: 0;
padding: 0
}
html {
background: #d3d3d3;
height: 100%;
color: #222;
font-size: 100%
}
body {
background: #fff;
width: 60em;
margin: 0 auto;
-webkit-box-shadow: 0 0 2.5em #5d656c;
-moz-box-shadow: 0 0 2.5em #5d656c;
box-shadow: 0 0 2.5em #5d656c;
font: 1em/1.7'Helvetica Neue', Helvetica, Arial, sans-serif;
min-height: 100%
}
code {
/*font-family: 'Roboto', 'Helvetica Neue', sans-serif;*/
font-family: 'Source Code Pro', Consolas, 'Courier New', monospace;
letter-spacing: 0.03em;
}
.lang-js {
color: #78dbf9;
}
span.hljs-number {
color: #d59cf6;
}
span.hljs-string{
color: #8bdb97;
}
span.hljs-regexp{
color: #dbad83;
}
span.hljs-literal{
color: #e26a78;
}
span.hljs-keyword{
color: #d59cf6;
}
span.hljs-comment {
color: #99a4c7;
}
span.hljs-special {
color: #bdc4df;
}
pre {
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255);
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392);
box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
background: #2b303b;
margin: 1em 0;
padding: .5em 20px;
overflow-x: scroll;
-webkit-overflow-scrolling: touch
}
pre.intro {
font-size: 1.2em
}
pre::-webkit-scrollbar {
height: 8px
}
pre::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, .8);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .5);
-webkit-border-radius: 10px;
border-radius: 10px
}
pre::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255, 255, 255, .4)
}
h1 span,
pre {
color: #ddd
}
h1,
h2,
h3,
h4,
ol,
p,
ul {
font-weight: 400;
padding: 0 20px;
word-wrap: break-word
}
hgroup h1 {
display: inline
}
hgroup h2 {
font-size: 1.38em
}
h2,
h3,
h4 {
margin: 0 0 .5em
}
h4 {
font-weight: 700
}
a {
color: #222;
border-bottom: 1px solid #ddd;
text-decoration: none
}
a:focus,
a:hover {
border-color: #222
}
a img {
border: 0
}
abbr[title] {
border-bottom: 1px dotted #ddd;
cursor: help
}
hr {
display: none
}
p {
margin-bottom: 1em
}
ol,
ul {
margin-left: 2em
}
ol ol,
ul ul {
margin-left: 1em;
padding: 0
}
footer {
display: block;
background: #eee;
padding: 1em 0;
text-align: center
}
.a-img {
border: 0
}
.a-img img {
padding: .5em 0 0
}
.description {
word-wrap: break-word
}
.multiline-items li {
padding-bottom: 1em
}
.multiline-items li.last-item {
padding-bottom: 0
}
.br0 {
color: #090
}
.co1 {
color: #060
}
.co2 {
color: #096
}
.kw1,
.kw3 {
color: #006
}
.kw2 {
color: #036
}
.me1 {
color: #606
}
.nu0 {
color: #c00
}
.st0 {
color: #36c
}
.sy0 {
color: #393;
font-weight: 700
}
pre .co1 {
color: #aeaeae
}
.es0,
pre .st0 {
color: #61ce3c
}
pre .co2 {
color: #fff
}
pre .kw2,
pre .kw3,
pre .nu0 {
color: #fbde2d
}
pre .me1 {
color: #8da6ce
}
pre .br0,
pre .kw1,
pre .sy0 {
color: #ddd
}
#docs {
background: #fff
}
#docs body {
font-size: .85em;
width: 100%
}
#docs a.alias {
opacity: .5
}
#docs div div div div {
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255);
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392);
box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
#docs div div div {
border-top: 0;
margin: 0 .5em 1em
}
#docs h1,
#docs h2,
#docs h3,
#docs h4,
#docs ol,
#docs p,
#docs ul {
padding: 0 10px
}
#docs pre {
margin: 0;
padding: .5em 10px
}
#docs ul li {
list-style-type: none;
margin: 0 0 0 -.9em
}
#docs h1 {
padding: 0 10px
}
#docs h2 {
margin: .5em 0 0
}
#docs h3 {
background: rgb(63, 107, 196);
border-radius: 3px 3px 0 0;
border: 1px solid rgba(75, 71, 71, 0.14);
margin: .5em 0;
padding: .8em 0 .8em 10px;
position: relative
}
#docs h3>code {
color: #fbfbfb
}
#docs h3 a {
position: absolute;
top: 0
}
#docs h3 .br0 {
color: #fc83ff
}
#docs h3 .kw2 {
color: #71d0c9
}
#docs h3 .me1 {
color: #fff
}
#docs h3 .nu0 {
color: #d0cb71
}
#docs h3 .sy0 {
color: #df74e2;
font-weight: 700
}
#docs footer {
height: 3em;
margin-top: 1.5em;
width: 100%
}
#social {
height: 20px
}
#social .twitter-follow-button {
width: 127px!important
}
#social .twitter-follow-button,
.twitter-share-button {
font-size: .8em;
vertical-align: top
}
@media (max-width: 959px) {
body {
border: 0;
margin: 0;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
width: auto
}
h1,
h2,
h3,
h4,
ol,
p,
ul {
padding: 0 10px
}
pre {
padding: 5px 10px!important
}
#social {
height: auto
}
.toc-container a {
display: block;
padding: 5px
}
.toc-container a:focus,
.toc-container a:hover {
background-color: #EEE
}
.toc-container a:active {
background-color: #CCC
}
}
@media (min-width: 960px) {
#docs body {
box-shadow: none;
height: 100%;
margin: 0
}
#docs a[href="#docs"],
#docs footer {
display: none
}
#docs h1 {
position: fixed;
background-color: #fff;
top: 0;
left: 0;
right: 0;
z-index: 1
}
#docs h3 a {
display: block;
position: relative;
visibility: hidden;
top: -4em
}
#docs .toc-container {
background: #fff;
bottom: 0;
left: 0;
overflow-y: scroll;
overflow-x: hidden;
position: fixed;
top: 1.5em;
white-space: nowrap;
width: 20%;
-webkit-overflow-scrolling: touch
}
#docs .toc-container h2,
#docs .toc-container ul {
margin-top: 0;
padding: 0 10px
}
#docs .doc-container {
background: #fff;
width: 80%;
margin-left: 20%;
padding-top: 1.5em
}
#docs .doc-container .first-heading {
margin-top: 0
}
}
@media (-ms-high-contrast: active) and (max-width: 1280px),
(-ms-high-contrast: none) and (max-width: 1280px) {
#docs .doc-container,
#docs .toc-container {
position: relative;
top: auto;
width: 100%
}
#docs .doc-container .first-heading {
margin-top: .5em
}
#docs a[href="#docs"] {
display: inline
}
#docs footer {
display: block
}
}
@media (orientation: portrait) and (min-device-width: 720px) and (max-device-width: 768px),
(orientation: landscape) and (device-width: 1280px) and (max-device-height: 768px) {
@-ms-viewport{width:80%}}
================================================
FILE: docs/tests.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="Dokker.js">
<meta name="description" content="This API documentation is built with Dokker.js at dokkerjs.com">
<title>Dokker.js</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<style>
body {
font: 16px/1.6 "Helvetica Neue", arial, sans-serif;
padding: 60px;
}
pre { font-size: 14px; line-height: 1.3 }
code .init { color: #2F6FAD }
code .string { color: #5890AD }
code .keyword { color: #8A6343 }
code .number { color: #2F6FAD }
</style>
<script>
$(function(){
$('code').each(function(){
$(this).html(highlight($(this).text()));
});
});
function highlight(js) {
return js
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
.replace(/('.*')/gm, '<span class="string">$1</span>')
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
.replace(/(\d+)/gm, '<span class="number">$1</span>')
.replace(/\bnew *(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
}
</script>
</head>
<body>
<section class="suite">
<h1>Dokker</h1>
<dl>
<section class="suite">
<h1>.literate()</h1>
<dl>
<dt>creates a HTML file from annotated source code</dt>
<dd><pre><code>return Dokker.literate(options.literate)
.then(function(){
done();
}).done();</code></pre></dd>
</dl>
</section>
<section class="suite">
<h1>.jsdocMarkdown()</h1>
<dl>
docco: /Users/georgschlenkhoff/Downloads/dokker/.tmp/dokker.js -> /Users/georgschlenkhoff/Downloads/dokker/docs/annotated/dokker.html
<dt>creates a markdown file from JSDOC comments</dt>
<dd><pre><code>return Dokker.jsdocMarkdown(options.jsdoc)
.then(function(){
return read(options.jsdoc.markdown);
}).then(function(){
done();
}).done();</code></pre></dd>
</dl>
</section>
<section class="suite">
<h1>.jsdocHtml()</h1>
<dl>
<dt>creates a HTML file from JSDOC commments</dt>
<dd><pre><code>return Dokker.jsdocHtml(options.jsdoc)
.then(function(){
return read(options.jsdoc.html);
}).then(function(){
done();
}).done();</code></pre></dd>
</dl>
</section>
<section class="suite">
<h1>.injectTemplate()</h1>
<dl>
<dt>injects index.html file in ejs template</dt>
<dd><pre><code>return Dokker.injectTemplate(options.jsdoc)
.then(function() {
return read(options.jsdoc.html, 'utf8');
}).then(function(data){
assert(/<!DOCTYPE html>/.test(data));
done();
}).done();</code></pre></dd>
</dl>
</section>
<section class="suite">
<h1>.copyTemplate()</h1>
<dl>
<dt>copies styles and app.js from template folder</dt>
<dd><pre><code>return Dokker.copyTemplate(options)
.then(function(){
return read(path.join(__dirname, '..', options.dir, 'styles.css'));
}).then(function(data){
assert(data);
done();
}).done();</code></pre></dd>
</dl>
</section>
</dl>
</section>
</body>
</html>
================================================
FILE: dokker.js
================================================
// Dokker.js 0.0.1
// http://dokker.oceanhouse21.com
// (c) 2014-2015 Georg Schlenkhoff and Oceanhouse21
// Dokker.js may be freely distributed under the MIT license.
'use strict';
// Define required dependencies
var Promise = require('promise');
var fs = require('fs');
var path = require('path');
var read = Promise.denodeify(fs.readFile);
var write = Promise.denodeify(fs.writeFile);
var docco = require('docco');
var docdown = require('docdown');
var marked = require('marked');
var ejs = require('ejs');
var cheerio = require('cheerio');
var exec = require('child_process').exec;
var Dokker = {};
/**
* The semantic version number.
*
* @static
* @memberOf Dokker
* @type string
*/
Dokker.VERSION = '0.1.2';
/**
* Creates a HTML file that transcludes the HTML snippet that was created
* by the docdown module into an ejs template which is defined by the
* .dokker.json configuration file.
*
* @static
* @category JSDoc
* @memberOf Dokker
* @type Function
* @param {Object} [options] The options object.
* @param {String} [options.template='template/index.ejs.html'] The path to
* the ejs template file.
* @param {string} [options.html='docs/index.html'] The path to the docdown
* generated JSDoc documentation.
* @param {string} [options.readme='README.md'] The path to the README.md
* file.
* @param {string} [options.title=''] The title for the documentation.
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* var options = {
* template: 'template/index.ejs.html',
* html: 'docs/index.html',
* readme: 'docs/README.md',
* title: 'Dokker.js API Documentation'
* };
* Dokker.injectTemplate(options)
* .then(function(){
* // => resolved promise
* });
*/
// Transclude in a ejs template file the HTML snippet that was ultimately
// created with docdown. Also tweak the HTML page a bit and finally
// inject the README.md.
Dokker.injectTemplate = function(options) {
return new Promise(function(resolve, reject) {
var template, body, html, readme, $;
return read(options.template, 'utf8')
.then(function(data) {
template = data;
return read(options.readme, 'utf8');
}).then(function(data) {
readme = marked(data);
$ = cheerio.load(readme);
$('h1').remove();
readme = $.html();
return read(options.html, 'utf8');
}).then(function(data) {
$ = cheerio.load(data);
return ejs.render(template, {
apiToc: $('.toc-container').html(),
readme: readme,
apiDoc: $('.doc-container').html(),
// correctly setting links to your github/pages
page_url: options.site,
title: options.title,
github_url: options.github,
// fixed reference to generated annotation
// the 'literate' in .dokker.json shall not require a source since it's never used.
annotated_path: 'annotated/'+options.source
});
}).then(function(data) {
return write(options.html, data, 'utf8');
}).then(function() {
resolve();
}).then(null, function(err) {
reject(err);
});
});
};
/**
* Creates an HTML file to describe the features of your module from your
* **Mocha** tests. The module is using the mocha **doc** reporter to
* generate the HTML contents.
*
* @static
* @memberOf Dokker
* @category Mocha
* @type Function
* @param {Object} [options] The options object.
* @param {String} [options.path='docs.html'] The path where to save the
* HTML file
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* var options = {
* path: 'docs/tests.html',
* };
* Dokker.createTests(options)
* .then(function(){
* // => resolved promise
* });
*/
// Create a HTML site from any mocha tests find when executing mocha
// --reporter doc terminal command.
Dokker.createTests = function(options) {
return new Promise(function(resolve, reject) {
var template, tests;
// allows specification of mocha.command in .dokker.json, e.g. 'mocha -u tdd --reporter doc'
var cmd = options.command || 'mocha --reporter doc';
exec(cmd, {cwd: process.cwd()}, function(error, stdout) {
if(error) return reject(error);
tests = stdout;
return read(options.template, 'utf8')
.then(function(data) {
template = data;
return ejs.render(template, {tests: tests});
}).then(function(data) {
return write(options.path, data, 'utf8');
}).then(function() {
resolve();
}).then(null, function(err) {
reject(err);
});
});
});
};
/**
* Runs a terminal shell with the git command to extract the docs branch
* into a seperate gh-pages branch and finally pushes that branch to Github,
* so that the Github page is updated.
*
* @static
* @memberOf Dokker
* @category Github Pages
* @type Function
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* Dokker.ghPages()
* .then(function(){
* // => resolved promise
* });
*/
// Extract docs folder to separate git branch and finally push branch to
// Github repository
Dokker.ghPages = function(){
return new Promise(function(resolve, reject) {
exec('git subtree split -P docs -b gh-pages', function(error, stdout, stderr) {
if(error) return reject(stderr);
exec('git push origin gh-pages', function(error, stdout, stderr) {
if(error) return reject(stderr);
resolve();
});
});
});
};
/**
* Create a styled HTML file from your source code with the help of **docco**
* module.
*
* @static
* @memberOf Dokker
* @category Literate programming
* @type Function
* @param {Object} [options] The options object.
* @param {String} [options.source='app.js'] The path the source code with
* comments
* @param {string} [options.dir='docs/annotated'] The directory where to save
* the generated HTML file.
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* var options = {
* dir: 'docs',
* source: 'app.js'
* };
* Dokker.literate()
* .then(function(){
* // => resolved promise
* });
*/
// Create an HTML file from any source code comments in the style of
// [literate programming](https://de.wikipedia.org/wiki/Literate_programming)
Dokker.literate = function (options) {
return new Promise(function(resolve, reject) {
var tmpDir = path.join(process.cwd(), '/.tmp');
var tmpFile = path.join(tmpDir, options.source);
var sourceFile = (options.cwd) ?
path.join(process.cwd(), options.cwd, options.source) :
path.join(process.cwd(), options.source);
return read(sourceFile, 'utf8')
.then(function(data) {
var source = data.replace(/^\s*(\*|\/\*).*[\r\n]/gm, '');
return Dokker.mkdir(tmpDir)
.then(function() {
return write(tmpFile, source, 'utf8');
}).then(function(){
docco.run(['', '', tmpFile, '-o', options.dir]);
resolve();
});
}).then(null, function(err) {
if (err) return reject(err);
});
});
};
/**
* Create a Markdown file from JSDoc tags.
*
* @static
* @memberOf Dokker
* @category JSDoc
* @type Function
* @param {Object} [options] The options object.
* @param {String} [options.source='app.js'] The path the source code with
* JSDoc tags.
* @param {String} [options.github =''] The path the Github repository.
* @param {string} [options.markdown='docs/READMDE.md'] The path where to
* save the Markdown file.
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* var options = {
* source: 'app.js',
* markdown: 'docs/README.md'
* };
* Dokker.jsdocMarkdown()
* .then(function(){
* // => resolved promise
* });
*/
// Convert markdown from any source code comments with docdown module.
Dokker.jsdocMarkdown = function (options) {
return new Promise(function(resolve, reject) {
var source, tmpFile, tmpDir;
var sourceFile = (options.cwd) ?
path.join(process.cwd(), options.cwd, options.source) :
path.join(process.cwd(), options.source);
return read(sourceFile, 'utf8')
.then(function(data){
source = data.replace(/^\s*(\/\/).*[\r\n]/gm, '');
tmpDir = path.join(process.cwd(), '/.tmp');
return Dokker.mkdir(tmpDir);
}).then(function(){
tmpFile = path.join(tmpDir, options.source);
return write(tmpFile, source, 'utf8');
}).then(function(){
var markdown = docdown({
'path': tmpFile,
'url': options.github,
'toc': 'categories'
});
return write(options.markdown, markdown, 'utf8');
}).then(function() {
resolve();
}).then(null, function(err) {
reject(err);
});
});
};
/**
* Create an HTML file from the Markdown file that was create with
* [Dokker.jsdocMarkdown()](#Dokker-jsdocMarkdown)
*
* @static
* @memberOf Dokker
* @category JSDoc
* @type Function
* @param {Object} [options] The options object.
* @param {string} [options.markdown='docs/READMDE.md'] The path where to
* save the Markdown file.
* @returns {Promise} Returns a resolved promise if file was created.
* @example
*
* var options = {
* markdown: 'docs/README.md'
* };
* Dokker.jsdocHtml()
* .then(function(){
* // => resolved promise
* });
*/
// Create an HTML file from any source code comments in the style of
// [literate programming](https://de.wikipedia.org/wiki/Literate_programming)
Dokker.jsdocHtml = function (options) {
return new Promise(function(resolve, reject) {
return read(options.markdown, 'utf8')
.then(function(data) {
var html = marked(data).replace(/<!-- /g,'<').replace(/ -->/g,'>');
return write(options.html, html, 'utf8');
}).then(function() {
resolve();
}).then(null, function(err) {
reject(err);
});
});
};
// Internal helper function that creates any directory if not existing.
Dokker.mkdir = function(dir) {
return new Promise(function(resolve, reject) {
fs.exists(dir, function(exists) {
if (exists) {
resolve();
} else {
fs.mkdir(dir, function(err) {
if (err) return reject(err);
resolve();
});
}
});
});
};
/**
* Helper function that takes a couple of options arguments and
* normalises them and subsequently returns them.
*
* @static
* @memberOf Dokker
* @category Utility
* @type Function
* @param {Object} [options] The options object.
* @param {string} [options.li.markdown='docs/READMDE.md'] The path where to
* @param {String} [options.source='app.js'] The path the source code with
* JSDoc tags.
* @param {string} [options.jsdoc.markdown='docs/READMDE.md'] The path where to
* save the Markdown file.
* @param {string} [options.jsdoc.README ='READMDE.md'] The path to the
* project's README.md file
* @param {String} [options.jsodc.template ='templates/index.ejs.html'] The
* path to the ejs template.
* @param {String} [options.mocha.template='templates/tests.ejs.html'] The
* path to the mocha template.
* @param {String} [options.dir='docs'] The path where to store the generated
* files
* @returns {Promise} Returns a resolved promise with edited options object
* @example
*
* var options = {
* dir: 'docs',
* literate: {
* source: 'dokker.js',
* dir: 'annotated'
* },
* jsdoc: {
* title: 'Dokker.js',
* source: 'dokker.js',
* markdown: 'README.md',
* html: 'index.html',
* readme: 'README.md',
* }
* };
* Dokker.jsdocHtml()
* .then(function(){
* // => object with absolute pathes to the directory from
* // which the command was executed
* });
*/
// Parses the options file, .Dokker.json, and sets the default parameters.
Dokker.configure = function(options) {
return new Promise(function(resolve, reject){
var file = path.join(process.cwd(), '.dokker.json');
return read(file, 'utf8')
.then(function(data) {
data = JSON.parse(data);
data.jsdoc.template = (data.jsdoc.template) ? path.join(process.cwd(), data.jsdoc.template) : path.join(__dirname, 'templates/index.ejs.html');
data.mocha.template = (data.mocha.template) ? path.join(process.cwd(), data.mocha.template) : path.join(__dirname, 'templates/tests.ejs.html');
data.mocha.path = path.join(process.cwd(), data.dir, data.mocha.path);
// mocha.command commented out to fix build-breaking bug
// specifies mocha command in .dokker.json; e.g. mocha -u tdd -R spec
// data.mocha.command = path.join(process.cwd(), data.dir, data.mocha.command);
data.literate.dir = path.join(process.cwd(), data.dir, data.literate.dir);
data.jsdoc.markdown = path.join(process.cwd(), data.dir, data.jsdoc.markdown);
data.jsdoc.html = path.join(process.cwd(), data.dir, data.jsdoc.html);
data.jsdoc.readme = path.join(process.cwd(), data.jsdoc.readme);
resolve(data);
}).then(null, function(err) {
reject(err);
});
});
};
/**
* Copy the template to local directory so that one can make changes to ejs
* files.
*
* @static
* @memberOf Dokker
* @category Utility
* @type Function
* @param {Object} [options] The options object.
* @param {string} [options.dir='templates'] The path where to save the
* template files
* @returns {Promise} Returns a resolved promise if files were created.
* @example
*
* var options = {
* dir: 'template'
* };
* Dokker.copyTemplate()
* .then(function(){
* // => resolved promise
* });
*/
// Copy starter template to bootstrap any Dokker project.
Dokker.copyTemplate = function(options) {
return new Promise(function(resolve, reject) {
var templatesDir = path.join(process.cwd(), 'templates');
return Dokker.mkdir(templatesDir)
.then(function() {
var oldStyle = path.join(__dirname, 'templates', 'styles.css');
var newStyle = path.join(process.cwd(), options.dir, 'styles.css');
fs.createReadStream(oldStyle).pipe(fs.createWriteStream(newStyle));
var oldLogo = path.join(__dirname, 'templates', 'logo.png');
var newLogo = path.join(process.cwd(), options.dir, 'logo.png');
fs.createReadStream(oldLogo).pipe(fs.createWriteStream(newLogo));
var oldApp = path.join(__dirname, 'templates', 'app.js');
var newApp = path.join(process.cwd(), options.dir, 'app.js');
fs.createReadStream(oldApp).pipe(fs.createWriteStream(newApp));
resolve();
});
});
};
/**
* Create a .dokker.json file to bootstrap any Dokker project
*
* @static
* @memberOf Dokker
* @category Utility
* @type Function
* @returns {Promise} Returns a resolved promise if files were created.
* @example
*
* Dokker.init()
* .then(function(){
* // => resolved promise
* });
*/
// Copies the .Dokker.json file to bootstrap any Dokker project.
Dokker.init = function(){
return new Promise(function(resolve, reject) {
var oldDok = path.join(__dirname, '.dokker.json');
var newDok = path.join(process.cwd(), '.dokker.json');
fs.createReadStream(oldDok).pipe(fs.createWriteStream(newDok));
resolve();
});
};
/**
* Starts a Node.js/Express webserver in docs directory to watch
* the build Dokker project
*
* @static
* @memberOf Dokker
* @category Utility
* @type Function
* @returns {Promise} Returns a resolved promise if files were created.
* @example
*
* Dokker.init()
* .then(function(){
* // => resolved promise
* });
*/
// Starts the Node.js/Express server to watch Dokker.js project
// documentation.
Dokker.watch = function(options) {
var gulpex = require(__dirname + '/gulpfile.js').gulpex;
return gulpex();
// return new Promise(function(resolve, reject){
// exec('DIR='+ options.dir + ' node ' + options.dir + '/app.js', function(error, stdout, stderr){
// if(error) return reject(stderr);
// });
// });
};
module.exports = Dokker;
================================================
FILE: gulpfile.js
================================================
// dependencies
var browserSync = require('browser-sync').create();
var cp = require('child_process');
var gulp = require('gulp');
var path = require('path');
var q = require('q');
// working path
var wpath = path.join(process.cwd());
// gulp entry point
gulp.task('default', ['start']);
gulp.task('start', ['build', 'reload', 'watch']);
// watch for file changes in wpath
gulp.task('watch', ['reload'], function() {
gulp.watch(wpath + '/*.js', ['build', 'reload'])
})
// gulp.task('build', exec.bind('some build command here'))
gulp.task('build', exec.bind((wpath+'/node_modules/dokker/bin/dokker').replace(/\s/, '\\ ')))
// Reloading browserSync
gulp.task('reload', ['build'], reload);
// reload browserSync
function reload() {
var defer = q.defer();
if (browserSync.active) {
browserSync.reload();
defer.resolve();
} else
startServer().then(defer.resolve);
return defer.promise;
}
// start a browserSync server to index.html directly
function startServer() {
var defer = q.defer();
var serverConfig = {
server: {
baseDir: wpath,
directory: true
},
startPath: 'docs/index.html',
// browser: "google chrome",
logPrefix: 'SERVER'
};
browserSync.init(serverConfig, defer.resolve);
return defer.promise;
}
// terminal exec task with promise: use as exec.bind(<command>)
function exec() {
var defer = q.defer();
cp.exec(this, function(err, stdout, stderr) {
if (err) console.log('exec err: '+ err);
console.log(stdout);
defer.resolve(err)
})
return defer.promise;
}
// // export for normal render run
function gulpex(options){
// set process.env.DIR then run task
// return exec.bind('DIR='+ options.dir)()
// .done(gulp.start('default'))
return gulp.start('default')
}
exports.gulpex = gulpex;
================================================
FILE: package.json
================================================
{
"name": "dokker",
"version": "0.1.3",
"description": "Dokker.js creates professional Javascript code documentations.",
"preferGlobal": true,
"bin": {
"dokker": "./bin/dokker",
"gh-pages": "./bin/gh-pages",
"dokker-init": "./bin/dokker-init",
"dokker-watch": "./bin/dokker-watch"
},
"main": "dokker.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/oceanhouse21/dokker.git"
},
"keywords": [
"documentation",
"JSDOC",
"docca",
"Javascript"
],
"author": "Georg Schlenkhoff",
"license": "MIT",
"bugs": {
"url": "https://github.com/oceanhouse21/dokker/issues"
},
"homepage": "https://dokkerjs.com",
"dependencies": {
"browser-sync": "^2.7.12",
"cheerio": "^0.19.0",
"docco": "^0.7.0",
"docdown": "^0.2.0",
"ejs": "^2.3.1",
"gulp": "^3.9.0",
"lodash": "^3.9.3",
"marked": "^0.3.3",
"nodemon": "^1.3.7",
"promise": "^7.0.3",
"q": "^1.4.1"
},
"devDependencies": {
"express": "^4.13.0",
"mocha": "^2.2.5"
}
}
================================================
FILE: templates/app.js
================================================
var express = require('express');
var app = express();
var path = require('path');
var livereload = require('livereload');
var path = path.join(process.cwd(), process.env.DIR);
livereload.createServer({exts: ['applyJSLive']}).watch(path);
app.use(express.static(path));
app.listen(9000);
================================================
FILE: templates/index.ejs.html
================================================
<!DOCTYPE html>
<html lang="en" id="docs">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="author" content="Dokker.js">
<meta name="description" content="This API documentation is built with Dokker.js at dokkerjs.com">
<title><%= title %></title>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles.css" media="all">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/default.min.css">
</head>
<body>
<div class="toc-container">
<h2><code><a href=<%= page_url %>><%= title %></a></code></h2>
<ul>
<li><a href="#">Introduction</a></li>
<li><a href=<%= github_url %>>Github Repository</a></li>
<li><a href="tests.html">Test suite</a></li>
<li><a href=<%= annotated_path %>>Annotated Source</a></li>
</ul>
<%- apiToc %>
</div>
<div class="doc-container">
<div>
<%- readme %>
<h2>API documentation</h2>
<%- apiDoc %>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
</body>
</html>
================================================
FILE: templates/styles.css
================================================
body,
h1,
h2,
html,
p {
margin: 0;
padding: 0
}
html {
background: #d3d3d3;
height: 100%;
color: #222;
font-size: 100%
}
body {
background: #fff;
width: 60em;
margin: 0 auto;
-webkit-box-shadow: 0 0 2.5em #5d656c;
-moz-box-shadow: 0 0 2.5em #5d656c;
box-shadow: 0 0 2.5em #5d656c;
font: 1em/1.7'Helvetica Neue', Helvetica, Arial, sans-serif;
min-height: 100%
}
code {
/*font-family: 'Roboto', 'Helvetica Neue', sans-serif;*/
font-family: 'Source Code Pro', Consolas, 'Courier New', monospace;
letter-spacing: 0.03em;
}
.lang-js {
color: #78dbf9;
}
span.hljs-number {
color: #d59cf6;
}
span.hljs-string{
color: #8bdb97;
}
span.hljs-regexp{
color: #dbad83;
}
span.hljs-literal{
color: #e26a78;
}
span.hljs-keyword{
color: #d59cf6;
}
span.hljs-comment {
color: #99a4c7;
}
span.hljs-special {
color: #bdc4df;
}
pre {
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255);
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392);
box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
background: #2b303b;
margin: 1em 0;
padding: .5em 20px;
overflow-x: scroll;
-webkit-overflow-scrolling: touch
}
pre.intro {
font-size: 1.2em
}
pre::-webkit-scrollbar {
height: 8px
}
pre::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, .8);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .5);
-webkit-border-radius: 10px;
border-radius: 10px
}
pre::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255, 255, 255, .4)
}
h1 span,
pre {
color: #ddd
}
h1,
h2,
h3,
h4,
ol,
p,
ul {
font-weight: 400;
padding: 0 20px;
word-wrap: break-word
}
hgroup h1 {
display: inline
}
hgroup h2 {
font-size: 1.38em
}
h2,
h3,
h4 {
margin: 0 0 .5em
}
h4 {
font-weight: 700
}
a {
color: #222;
border-bottom: 1px solid #ddd;
text-decoration: none
}
a:focus,
a:hover {
border-color: #222
}
a img {
border: 0
}
abbr[title] {
border-bottom: 1px dotted #ddd;
cursor: help
}
hr {
display: none
}
p {
margin-bottom: 1em
}
ol,
ul {
margin-left: 2em
}
ol ol,
ul ul {
margin-left: 1em;
padding: 0
}
footer {
display: block;
background: #eee;
padding: 1em 0;
text-align: center
}
.a-img {
border: 0
}
.a-img img {
padding: .5em 0 0
}
.description {
word-wrap: break-word
}
.multiline-items li {
padding-bottom: 1em
}
.multiline-items li.last-item {
padding-bottom: 0
}
.br0 {
color: #090
}
.co1 {
color: #060
}
.co2 {
color: #096
}
.kw1,
.kw3 {
color: #006
}
.kw2 {
color: #036
}
.me1 {
color: #606
}
.nu0 {
color: #c00
}
.st0 {
color: #36c
}
.sy0 {
color: #393;
font-weight: 700
}
pre .co1 {
color: #aeaeae
}
.es0,
pre .st0 {
color: #61ce3c
}
pre .co2 {
color: #fff
}
pre .kw2,
pre .kw3,
pre .nu0 {
color: #fbde2d
}
pre .me1 {
color: #8da6ce
}
pre .br0,
pre .kw1,
pre .sy0 {
color: #ddd
}
#docs {
background: #fff
}
#docs body {
font-size: .85em;
width: 100%
}
#docs a.alias {
opacity: .5
}
#docs div div div div {
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255);
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392);
box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
#docs div div div {
border-top: 0;
margin: 0 .5em 1em
}
#docs h1,
#docs h2,
#docs h3,
#docs h4,
#docs ol,
#docs p,
#docs ul {
padding: 0 10px
}
#docs pre {
margin: 0;
padding: .5em 10px
}
#docs ul li {
list-style-type: none;
margin: 0 0 0 -.9em
}
#docs h1 {
padding: 0 10px
}
#docs h2 {
margin: .5em 0 0
}
#docs h3 {
background: rgb(63, 107, 196);
border-radius: 3px 3px 0 0;
border: 1px solid rgba(75, 71, 71, 0.14);
margin: .5em 0;
padding: .8em 0 .8em 10px;
position: relative
}
#docs h3>code {
color: #fbfbfb
}
#docs h3 a {
position: absolute;
top: 0
}
#docs h3 .br0 {
color: #fc83ff
}
#docs h3 .kw2 {
color: #71d0c9
}
#docs h3 .me1 {
color: #fff
}
#docs h3 .nu0 {
color: #d0cb71
}
#docs h3 .sy0 {
color: #df74e2;
font-weight: 700
}
#docs footer {
height: 3em;
margin-top: 1.5em;
width: 100%
}
#social {
height: 20px
}
#social .twitter-follow-button {
width: 127px!important
}
#social .twitter-follow-button,
.twitter-share-button {
font-size: .8em;
vertical-align: top
}
@media (max-width: 959px) {
body {
border: 0;
margin: 0;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
width: auto
}
h1,
h2,
h3,
h4,
ol,
p,
ul {
padding: 0 10px
}
pre {
padding: 5px 10px!important
}
#social {
height: auto
}
.toc-container a {
display: block;
padding: 5px
}
.toc-container a:focus,
.toc-container a:hover {
background-color: #EEE
}
.toc-container a:active {
background-color: #CCC
}
}
@media (min-width: 960px) {
#docs body {
box-shadow: none;
height: 100%;
margin: 0
}
#docs a[href="#docs"],
#docs footer {
display: none
}
#docs h1 {
position: fixed;
background-color: #fff;
top: 0;
left: 0;
right: 0;
z-index: 1
}
#docs h3 a {
display: block;
position: relative;
visibility: hidden;
top: -4em
}
#docs .toc-container {
background: #fff;
bottom: 0;
left: 0;
overflow-y: scroll;
overflow-x: hidden;
position: fixed;
top: 1.5em;
white-space: nowrap;
width: 20%;
-webkit-overflow-scrolling: touch
}
#docs .toc-container h2,
#docs .toc-container ul {
margin-top: 0;
padding: 0 10px
}
#docs .doc-container {
background: #fff;
width: 80%;
margin-left: 20%;
padding-top: 1.5em
}
#docs .doc-container .first-heading {
margin-top: 0
}
}
@media (-ms-high-contrast: active) and (max-width: 1280px),
(-ms-high-contrast: none) and (max-width: 1280px) {
#docs .doc-container,
#docs .toc-container {
position: relative;
top: auto;
width: 100%
}
#docs .doc-container .first-heading {
margin-top: .5em
}
#docs a[href="#docs"] {
display: inline
}
#docs footer {
display: block
}
}
@media (orientation: portrait) and (min-device-width: 720px) and (max-device-width: 768px),
(orientation: landscape) and (device-width: 1280px) and (max-device-height: 768px) {
@-ms-viewport{width:80%}}
================================================
FILE: templates/tests.ejs.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="Dokker.js">
<meta name="description" content="This API documentation is built with Dokker.js at dokkerjs.com">
<title>Dokker.js</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<style>
body {
font: 16px/1.6 "Helvetica Neue", arial, sans-serif;
padding: 60px;
}
pre { font-size: 14px; line-height: 1.3 }
code .init { color: #2F6FAD }
code .string { color: #5890AD }
code .keyword { color: #8A6343 }
code .number { color: #2F6FAD }
</style>
<script>
$(function(){
$('code').each(function(){
$(this).html(highlight($(this).text()));
});
});
function highlight(js) {
return js
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
.replace(/('.*')/gm, '<span class="string">$1</span>')
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
.replace(/(\d+)/gm, '<span class="number">$1</span>')
.replace(/\bnew *(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
}
</script>
</head>
<body>
<%- tests %>
</body>
</html>
================================================
FILE: test/dokker.js
================================================
'use strict';
var fs = require('fs');
var path = require('path');
var Dokker = require('../dokker');
var Promise = require('promise');
var read = Promise.denodeify(fs.readFile);
var assert = require('assert');
var options;
describe('Dokker', function(){
before(function(done){
Dokker.configure()
.then(function(data){
options = data;
done();
});
});
describe('.literate()', function(){
it('creates a HTML file from annotated source code', function(done){
return Dokker.literate(options.literate)
.then(function(){
done();
}).done();
});
});
describe('.jsdocMarkdown()', function() {
it('creates a markdown file from JSDOC comments', function(done){
return Dokker.jsdocMarkdown(options.jsdoc)
.then(function(){
return read(options.jsdoc.markdown);
}).then(function(){
done();
}).done();
});
});
describe('.jsdocHtml()', function() {
it('creates a HTML file from JSDOC commments', function(done){
return Dokker.jsdocHtml(options.jsdoc)
.then(function(){
return read(options.jsdoc.html);
}).then(function(){
done();
}).done();
});
});
describe('.injectTemplate()', function(){
it('injects index.html file in ejs template', function(done){
return Dokker.injectTemplate(options.jsdoc)
.then(function() {
return read(options.jsdoc.html, 'utf8');
}).then(function(data){
assert(/<!DOCTYPE html>/.test(data));
done();
}).done();
});
});
describe('.copyTemplate()', function() {
it('copies styles and app.js from template folder', function(done){
return Dokker.copyTemplate(options)
.then(function(){
return read(path.join(__dirname, '..', options.dir, 'styles.css'));
}).then(function(data){
assert(data);
done();
}).done();
});
});
});
gitextract_owqcwv6i/
├── .dokker.json
├── .gitignore
├── .jshintrc
├── .travis.yml
├── LICENSE
├── README.md
├── bin/
│ ├── dokker
│ ├── dokker-init
│ ├── dokker-watch
│ └── gh-pages
├── docs/
│ ├── CNAME
│ ├── README.md
│ ├── annotated/
│ │ ├── docco.css
│ │ ├── dokker.html
│ │ └── public/
│ │ └── stylesheets/
│ │ └── normalize.css
│ ├── app.js
│ ├── index.html
│ ├── styles.css
│ └── tests.html
├── dokker.js
├── gulpfile.js
├── package.json
├── templates/
│ ├── app.js
│ ├── index.ejs.html
│ ├── styles.css
│ └── tests.ejs.html
└── test/
└── dokker.js
SYMBOL INDEX (4 symbols across 1 files)
FILE: gulpfile.js
function reload (line 26) | function reload() {
function startServer (line 39) | function startServer() {
function exec (line 57) | function exec() {
function gulpex (line 68) | function gulpex(options){
Condensed preview — 27 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (132K chars).
[
{
"path": ".dokker.json",
"chars": 556,
"preview": "{\n \"dir\": \"docs\",\n \"literate\": {\n \"source\": \"dokker.js\",\n \"dir\": \"annotated\"\n },\n \"jsdoc\": {\n \"title\": \"Dok"
},
{
"path": ".gitignore",
"chars": 18,
"preview": ".tmp\nnode_modules\n"
},
{
"path": ".jshintrc",
"chars": 36,
"preview": "{\n \"node\": true,\n \"mocha\": true\n}\n"
},
{
"path": ".travis.yml",
"chars": 89,
"preview": "language: node_js\nnode_js:\n - \"0.12\"\n - \"0.11\"\n - \"0.10\"\n - \"iojs\"\n - \"iojs-v1.0.4\"\n"
},
{
"path": "LICENSE",
"chars": 1084,
"preview": "Copyright 2014-2015 Oceanhouse21 <http://oceanhouse21.com/>\n\nPermission is hereby granted, free of charge, to any person"
},
{
"path": "README.md",
"chars": 4249,
"preview": "\n\nDokker.js creates profe"
},
{
"path": "bin/dokker",
"chars": 633,
"preview": "#!/usr/bin/env node\n\nvar path = require('path');\nvar Dokker = require('../dokker');\nvar options;\nreturn Dokker.configure"
},
{
"path": "bin/dokker-init",
"chars": 407,
"preview": "#!/usr/bin/env node\n\nvar Dokker = require('../dokker');\nvar path = require('path');\nvar options;\n\nreturn Dokker.init()\n."
},
{
"path": "bin/dokker-watch",
"chars": 210,
"preview": "#!/usr/bin/env node\n\nvar Dokker = require('../dokker');\nvar options = Dokker.configure()\n.then(function(data){\n return "
},
{
"path": "bin/gh-pages",
"chars": 164,
"preview": "#!/usr/bin/env node\n\nvar dokker = require('../dokker');\nreturn dokker.ghPages()\n.then(function(){\n console.log('Success"
},
{
"path": "docs/CNAME",
"chars": 13,
"preview": "dokkerjs.com\n"
},
{
"path": "docs/README.md",
"chars": 9732,
"preview": "# dokker.js API documentation\n\n<!-- div class=\"toc-container\" -->\n\n<!-- div -->\n\n## `Github Pages`\n* <a href=\"#Dokker-gh"
},
{
"path": "docs/annotated/docco.css",
"chars": 9921,
"preview": "/*--------------------- Typography ----------------------------*/\n\n@font-face {\n font-family: 'aller-light';\n src:"
},
{
"path": "docs/annotated/dokker.html",
"chars": 28019,
"preview": "<!DOCTYPE html>\n\n<html>\n<head>\n <title>dokker.js</title>\n <meta http-equiv=\"content-type\" content=\"text/html; charset="
},
{
"path": "docs/annotated/public/stylesheets/normalize.css",
"chars": 6874,
"preview": "/*! normalize.css v2.0.1 | MIT License | git.io/normalize */\n\n/* ======================================================="
},
{
"path": "docs/app.js",
"chars": 288,
"preview": "var express = require('express');\nvar app = express();\nvar path = require('path');\nvar livereload = require('livereload'"
},
{
"path": "docs/index.html",
"chars": 21489,
"preview": "<!DOCTYPE html>\n<html lang=\"en\" id=\"docs\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device"
},
{
"path": "docs/styles.css",
"chars": 6828,
"preview": "body,\nh1,\nh2,\nhtml,\np {\n margin: 0;\n padding: 0\n}\nhtml {\n background: #d3d3d3;\n height: 100%;\n color: #22"
},
{
"path": "docs/tests.html",
"chars": 3510,
"preview": "<!DOCTYPE html>\n<html>\n <head>\n <meta name=\"author\" content=\"Dokker.js\">\n <meta name=\"description\" content=\"This "
},
{
"path": "dokker.js",
"chars": 15858,
"preview": "// Dokker.js 0.0.1\n// http://dokker.oceanhouse21.com\n// (c) 2014-2015 Georg Schlenkhoff and Oceanhouse21\n// "
},
{
"path": "gulpfile.js",
"chars": 1871,
"preview": "// dependencies\nvar browserSync = require('browser-sync').create();\nvar cp = require('child_process');\nvar gulp = requir"
},
{
"path": "package.json",
"chars": 1095,
"preview": "{\n \"name\": \"dokker\",\n \"version\": \"0.1.3\",\n \"description\": \"Dokker.js creates professional Javascript code documentati"
},
{
"path": "templates/app.js",
"chars": 288,
"preview": "var express = require('express');\nvar app = express();\nvar path = require('path');\nvar livereload = require('livereload'"
},
{
"path": "templates/index.ejs.html",
"chars": 1211,
"preview": "<!DOCTYPE html>\n<html lang=\"en\" id=\"docs\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device"
},
{
"path": "templates/styles.css",
"chars": 6828,
"preview": "body,\nh1,\nh2,\nhtml,\np {\n margin: 0;\n padding: 0\n}\nhtml {\n background: #d3d3d3;\n height: 100%;\n color: #22"
},
{
"path": "templates/tests.ejs.html",
"chars": 1435,
"preview": "<!DOCTYPE html>\n<html>\n <head>\n <meta name=\"author\" content=\"Dokker.js\">\n <meta name=\"description\" content=\"This "
},
{
"path": "test/dokker.js",
"chars": 1930,
"preview": "'use strict';\n\nvar fs = require('fs');\nvar path = require('path');\nvar Dokker = require('../dokker');\nvar Promise = requ"
}
]
About this extraction
This page contains the full source code of the oceanhouse21/dokker GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 27 files (121.7 KB), approximately 36.3k tokens, and a symbol index with 4 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.