├── .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 │ │ ├── fonts │ │ ├── aller-bold.eot │ │ ├── aller-bold.ttf │ │ ├── aller-bold.woff │ │ ├── aller-light.eot │ │ ├── aller-light.ttf │ │ ├── aller-light.woff │ │ ├── roboto-black.eot │ │ ├── roboto-black.ttf │ │ └── roboto-black.woff │ │ └── stylesheets │ │ └── normalize.css ├── app.js ├── index.html ├── logo.png ├── styles.css └── tests.html ├── dokker.js ├── gulpfile.js ├── package.json ├── templates ├── app.js ├── index.ejs.html ├── logo.png ├── styles.css └── tests.ejs.html └── test └── dokker.js /.dokker.json: -------------------------------------------------------------------------------- 1 | { 2 | "dir": "docs", 3 | "literate": { 4 | "source": "dokker.js", 5 | "dir": "annotated" 6 | }, 7 | "jsdoc": { 8 | "title": "Dokker.js", 9 | "source": "dokker.js", 10 | "markdown": "README.md", 11 | "html": "index.html", 12 | "readme": "README.md", 13 | "template": "templates/index.ejs.html", 14 | "github": "https://github.com/oceanhouse21/dokker/blob/master/dokker.js", 15 | "site": "http://dokkerjs.com" 16 | }, 17 | "mocha": { 18 | "command": "mocha --reporter doc", 19 | "test": "test/dokker.js", 20 | "path": "tests.html", 21 | "template": "templates/tests.ejs.html" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .tmp 2 | node_modules 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "mocha": true 4 | } 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | - "0.11" 5 | - "0.10" 6 | - "iojs" 7 | - "iojs-v1.0.4" 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014-2015 Oceanhouse21 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![dokker logo](https://raw.githubusercontent.com/oceanhouse21/dokker/master/templates/logo.png) 2 | 3 | Dokker.js creates professional Javascript code documentations. 4 | 5 | [See Dokker.js documentation as example.](http://dokkerjs.com) 6 | 7 | [![Build Status](https://travis-ci.org/oceanhouse21/dokker.svg?branch=master)](https://travis-ci.org/oceanhouse21/dokker) 8 | 9 | 10 | ## Features 11 | 12 | * 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 13 | * Support for [literate programming](https://en.wikipedia.org/?title=Literate_programming) documentation 14 | * Live edit source code and watch changes 15 | * Include link to your Github repository 16 | * Customize your own templates with [ejs](http://www.embeddedjs.com/) or use default style 17 | * Create feature description from [mocha test suite](http://mochajs.org/) 18 | * Automagically include your README.md into the documentation 19 | * Use your own logo to make an astonishing impression 20 | * Deploy documentation to Github pages on the fly 21 | 22 | ## Community 23 | 24 | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/oceanhouse21/dokker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 25 | 26 | ## Installation 27 | 28 | Dokker is available as npm package. So the easiest way is to install dokker as global module into your project: 29 | 30 | ``` 31 | npm install -g dokker 32 | ``` 33 | 34 | ## Usage 35 | 36 | After installation you can execute Dokker with the help of several terminal commands. 37 | 38 | **Bootstrap Dokker project** 39 | 40 | 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). 41 | 42 | 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. 43 | 44 | **Create documentation** 45 | 46 | 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. 47 | 48 | **Live edit your documentation** 49 | 50 | 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. 51 | 52 | 55 | 56 | **Deploy to Github Pages** 57 | 58 | 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. 59 | 60 | ## Dokker in the wild 61 | Some examples by our users. Let us know what you did with Dokker too! 62 | 63 | - [Dokker.js](http://dokkerjs.com) 64 | - [lomath](http://kengz.github.io/lomath/) 65 | 66 | ## Further Reading 67 | 68 | * [API Documentation](http://dokkerjs.com) 69 | * [Changelog](https://github.com/oceanhouse21/dokker/wiki/Changelog) 70 | * [Release Notes](https://github.com/oceanhouse21/dokker/releases) 71 | * [Roadmap](https://github.com/oceanhouse21/dokker/wiki/Roadmap) 72 | * [More Resources](https://github.com/oceanhouse21/dokker/wiki/Resources) 73 | 74 | ## Contributors 75 | 76 | 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. 77 | 78 | * [georgschlenkhoff](https://github.com/georgschlenkhoff) *(original author)* 79 | * [kengz](https://github.com/kengz) 80 | -------------------------------------------------------------------------------- /bin/dokker: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | var Dokker = require('../dokker'); 5 | var options; 6 | return Dokker.configure() 7 | .then(function(data) { 8 | options = data; 9 | return Dokker.mkdir(path.join(process.cwd(), options.dir)); 10 | }).then(function() { 11 | return Dokker.jsdocMarkdown(options.jsdoc); 12 | }).then(function() { 13 | return Dokker.jsdocHtml(options.jsdoc); 14 | }).then(function() { 15 | return Dokker.injectTemplate(options.jsdoc); 16 | }).then(function() { 17 | return Dokker.createTests(options.mocha); 18 | }).then(function() { 19 | return Dokker.literate(options.literate); 20 | }).then(function() { 21 | console.log('Dokker executed successfully'); 22 | }).done(); 23 | -------------------------------------------------------------------------------- /bin/dokker-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var Dokker = require('../dokker'); 4 | var path = require('path'); 5 | var options; 6 | 7 | return Dokker.init() 8 | .then(function(){ 9 | return Dokker.configure(); 10 | }).then(function(data){ 11 | options = data; 12 | return Dokker.mkdir(path.join(process.cwd(), options.dir)); 13 | }).then(function(){ 14 | return Dokker.copyTemplate(options); 15 | }).then(function(){ 16 | console.log('Templates copied sucessfully'); 17 | }).done(); 18 | -------------------------------------------------------------------------------- /bin/dokker-watch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var Dokker = require('../dokker'); 4 | var options = Dokker.configure() 5 | .then(function(data){ 6 | return Dokker.watch(data); 7 | }).then(function(){ 8 | console.log('Watching for changes'); 9 | }).done(); 10 | -------------------------------------------------------------------------------- /bin/gh-pages: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var dokker = require('../dokker'); 4 | return dokker.ghPages() 5 | .then(function(){ 6 | console.log('Successfully created gh-pages branch'); 7 | }).done(); 8 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | dokkerjs.com 2 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # dokker.js API documentation 2 | 3 | 4 | 5 | 6 | 7 | ## `Github Pages` 8 | * `Dokker.ghPages` 9 | 10 | 11 | 12 | 13 | 14 | ## `JSDoc` 15 | * `Dokker.injectTemplate` 16 | * `Dokker.jsdocHtml` 17 | * `Dokker.jsdocMarkdown` 18 | 19 | 20 | 21 | 22 | 23 | ## `Literate programming` 24 | * `Dokker.literate` 25 | 26 | 27 | 28 | 29 | 30 | ## `Mocha` 31 | * `Dokker.createTests` 32 | 33 | 34 | 35 | 36 | 37 | ## `Utility` 38 | * `Dokker.configure` 39 | * `Dokker.copyTemplate` 40 | * `Dokker.init` 41 | * `Dokker.watch` 42 | 43 | 44 | 45 | 46 | 47 | ## `Methods` 48 | 49 | 50 | 51 | 52 | 53 | ## `Properties` 54 | * `Dokker.VERSION` 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | ## `“Github Pages” Methods` 65 | 66 | 67 | 68 | ### `Dokker.ghPages()` 69 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L152 "View in source") [Ⓣ][1] 70 | 71 | Runs a terminal shell with the git command to extract the docs branch 72 | into a seperate gh-pages branch and finally pushes that branch to Github, 73 | so that the Github page is updated. 74 | 75 | #### Returns 76 | *(Promise)*: Returns a resolved promise if file was created. 77 | 78 | #### Example 79 | ```js 80 | Dokker.ghPages() 81 | .then(function(){ 82 | // => resolved promise 83 | }); 84 | ``` 85 | * * * 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | ## `“JSDoc” Methods` 94 | 95 | 96 | 97 | ### `Dokker.injectTemplate([options])` 98 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L56 "View in source") [Ⓣ][1] 99 | 100 | Creates a HTML file that transcludes the HTML snippet that was created 101 | by the docdown module into an ejs template which is defined by the 102 | .dokker.json configuration file. 103 | 104 | #### Arguments 105 | 1. `[options]` *(Object)*: The options object. 106 | 2. `[options.template='template/index.ejs.html']` *(String)*: The path to the ejs template file. 107 | 3. `[options.html='docs/index.html']` *(string)*: The path to the docdown generated JSDoc documentation. 108 | 4. `[options.readme='README.md']` *(string)*: The path to the README.md file. 109 | 5. `[options.title='']` *(string)*: The title for the documentation. 110 | 111 | #### Returns 112 | *(Promise)*: Returns a resolved promise if file was created. 113 | 114 | #### Example 115 | ```js 116 | var options = { 117 | template: 'template/index.ejs.html', 118 | html: 'docs/index.html', 119 | readme: 'docs/README.md', 120 | title: 'Dokker.js API Documentation' 121 | }; 122 | Dokker.injectTemplate(options) 123 | .then(function(){ 124 | // => resolved promise 125 | }); 126 | ``` 127 | * * * 128 | 129 | 130 | 131 | 132 | 133 | ### `Dokker.jsdocHtml([options])` 134 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L288 "View in source") [Ⓣ][1] 135 | 136 | Create an HTML file from the Markdown file that was create with 137 | [Dokker.jsdocMarkdown()](#Dokker-jsdocMarkdown) 138 | 139 | #### Arguments 140 | 1. `[options]` *(Object)*: The options object. 141 | 2. `[options.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file. 142 | 143 | #### Returns 144 | *(Promise)*: Returns a resolved promise if file was created. 145 | 146 | #### Example 147 | ```js 148 | var options = { 149 | markdown: 'docs/README.md' 150 | }; 151 | Dokker.jsdocHtml() 152 | .then(function(){ 153 | // => resolved promise 154 | }); 155 | ``` 156 | * * * 157 | 158 | 159 | 160 | 161 | 162 | ### `Dokker.jsdocMarkdown([options])` 163 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L237 "View in source") [Ⓣ][1] 164 | 165 | Create a Markdown file from JSDoc tags. 166 | 167 | #### Arguments 168 | 1. `[options]` *(Object)*: The options object. 169 | 2. `[options.source='app.js']` *(String)*: The path the source code with JSDoc tags. 170 | 3. `[options.github ='']` *(String)*: The path the Github repository. 171 | 4. `[options.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file. 172 | 173 | #### Returns 174 | *(Promise)*: Returns a resolved promise if file was created. 175 | 176 | #### Example 177 | ```js 178 | var options = { 179 | source: 'app.js', 180 | markdown: 'docs/README.md' 181 | }; 182 | Dokker.jsdocMarkdown() 183 | .then(function(){ 184 | // => resolved promise 185 | }); 186 | ``` 187 | * * * 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | ## `“Literate programming” Methods` 196 | 197 | 198 | 199 | ### `Dokker.literate([options])` 200 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L189 "View in source") [Ⓣ][1] 201 | 202 | Create a styled HTML file from your source code with the help of **docco** 203 | module. 204 | 205 | #### Arguments 206 | 1. `[options]` *(Object)*: The options object. 207 | 2. `[options.source='app.js']` *(String)*: The path the source code with comments 208 | 3. `[options.dir='docs/annotated']` *(string)*: The directory where to save the generated HTML file. 209 | 210 | #### Returns 211 | *(Promise)*: Returns a resolved promise if file was created. 212 | 213 | #### Example 214 | ```js 215 | var options = { 216 | dir: 'docs', 217 | source: 'app.js' 218 | }; 219 | Dokker.literate() 220 | .then(function(){ 221 | // => resolved promise 222 | }); 223 | ``` 224 | * * * 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | ## `“Mocha” Methods` 233 | 234 | 235 | 236 | ### `Dokker.createTests([options])` 237 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L113 "View in source") [Ⓣ][1] 238 | 239 | Creates an HTML file to describe the features of your module from your 240 | **Mocha** tests. The module is using the mocha **doc** reporter to 241 | generate the HTML contents. 242 | 243 | #### Arguments 244 | 1. `[options]` *(Object)*: The options object. 245 | 2. `[options.path='docs.html']` *(String)*: The path where to save the HTML file 246 | 247 | #### Returns 248 | *(Promise)*: Returns a resolved promise if file was created. 249 | 250 | #### Example 251 | ```js 252 | var options = { 253 | path: 'docs/tests.html', 254 | }; 255 | Dokker.createTests(options) 256 | .then(function(){ 257 | // => resolved promise 258 | }); 259 | ``` 260 | * * * 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | ## `“Utility” Methods` 269 | 270 | 271 | 272 | ### `Dokker.configure([options])` 273 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L361 "View in source") [Ⓣ][1] 274 | 275 | Helper function that takes a couple of options arguments and 276 | normalises them and subsequently returns them. 277 | 278 | #### Arguments 279 | 1. `[options]` *(Object)*: The options object. 280 | 2. `[options.li.markdown='docs/READMDE.md']` *(string)*: The path where to 281 | 3. `[options.source='app.js']` *(String)*: The path the source code with JSDoc tags. 282 | 4. `[options.jsdoc.markdown='docs/READMDE.md']` *(string)*: The path where to save the Markdown file. 283 | 5. `[options.jsdoc.README ='READMDE.md']` *(string)*: The path to the project's README.md file 284 | 6. `[options.jsodc.template ='templates/index.ejs.html']` *(String)*: The path to the ejs template. 285 | 7. `[options.mocha.template='templates/tests.ejs.html']` *(String)*: The path to the mocha template. 286 | 8. `[options.dir='docs']` *(String)*: The path where to store the generated files 287 | 288 | #### Returns 289 | *(Promise)*: Returns a resolved promise with edited options object 290 | 291 | #### Example 292 | ```js 293 | var options = { 294 | dir: 'docs', 295 | literate: { 296 | source: 'dokker.js', 297 | dir: 'annotated' 298 | }, 299 | jsdoc: { 300 | title: 'Dokker.js', 301 | source: 'dokker.js', 302 | markdown: 'README.md', 303 | html: 'index.html', 304 | readme: 'README.md', 305 | } 306 | }; 307 | Dokker.jsdocHtml() 308 | .then(function(){ 309 | // => object with absolute pathes to the directory from 310 | // which the command was executed 311 | }); 312 | ``` 313 | * * * 314 | 315 | 316 | 317 | 318 | 319 | ### `Dokker.copyTemplate([options])` 320 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L403 "View in source") [Ⓣ][1] 321 | 322 | Copy the template to local directory so that one can make changes to ejs 323 | files. 324 | 325 | #### Arguments 326 | 1. `[options]` *(Object)*: The options object. 327 | 2. `[options.dir='templates']` *(string)*: The path where to save the template files 328 | 329 | #### Returns 330 | *(Promise)*: Returns a resolved promise if files were created. 331 | 332 | #### Example 333 | ```js 334 | var options = { 335 | dir: 'template' 336 | }; 337 | Dokker.copyTemplate() 338 | .then(function(){ 339 | // => resolved promise 340 | }); 341 | ``` 342 | * * * 343 | 344 | 345 | 346 | 347 | 348 | ### `Dokker.init()` 349 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L437 "View in source") [Ⓣ][1] 350 | 351 | Create a .dokker.json file to bootstrap any Dokker project 352 | 353 | #### Returns 354 | *(Promise)*: Returns a resolved promise if files were created. 355 | 356 | #### Example 357 | ```js 358 | Dokker.init() 359 | .then(function(){ 360 | // => resolved promise 361 | }); 362 | ``` 363 | * * * 364 | 365 | 366 | 367 | 368 | 369 | ### `Dokker.watch()` 370 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L462 "View in source") [Ⓣ][1] 371 | 372 | Starts a Node.js/Express webserver in docs directory to watch 373 | the build Dokker project 374 | 375 | #### Returns 376 | *(Promise)*: Returns a resolved promise if files were created. 377 | 378 | #### Example 379 | ```js 380 | Dokker.init() 381 | .then(function(){ 382 | // => resolved promise 383 | }); 384 | ``` 385 | * * * 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | ## `Methods` 394 | 395 | 396 | 397 | 398 | 399 | ## `Properties` 400 | 401 | 402 | 403 | ### `Dokker.VERSION` 404 | # [Ⓢ](https://github.com/oceanhouse21/dokker/blob/master/dokker.js#L23 "View in source") [Ⓣ][1] 405 | 406 | (string): The semantic version number. 407 | 408 | * * * 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | [1]: #github pages "Jump back to the TOC." 417 | -------------------------------------------------------------------------------- /docs/annotated/docco.css: -------------------------------------------------------------------------------- 1 | /*--------------------- Typography ----------------------------*/ 2 | 3 | @font-face { 4 | font-family: 'aller-light'; 5 | src: url('public/fonts/aller-light.eot'); 6 | src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), 7 | url('public/fonts/aller-light.woff') format('woff'), 8 | url('public/fonts/aller-light.ttf') format('truetype'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | @font-face { 14 | font-family: 'aller-bold'; 15 | src: url('public/fonts/aller-bold.eot'); 16 | src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), 17 | url('public/fonts/aller-bold.woff') format('woff'), 18 | url('public/fonts/aller-bold.ttf') format('truetype'); 19 | font-weight: normal; 20 | font-style: normal; 21 | } 22 | 23 | @font-face { 24 | font-family: 'roboto-black'; 25 | src: url('public/fonts/roboto-black.eot'); 26 | src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'), 27 | url('public/fonts/roboto-black.woff') format('woff'), 28 | url('public/fonts/roboto-black.ttf') format('truetype'); 29 | font-weight: normal; 30 | font-style: normal; 31 | } 32 | 33 | /*--------------------- Layout ----------------------------*/ 34 | html { height: 100%; } 35 | body { 36 | font-family: "aller-light"; 37 | font-size: 14px; 38 | line-height: 18px; 39 | color: #30404f; 40 | margin: 0; padding: 0; 41 | height:100%; 42 | } 43 | #container { min-height: 100%; } 44 | 45 | a { 46 | color: #000; 47 | } 48 | 49 | b, strong { 50 | font-weight: normal; 51 | font-family: "aller-bold"; 52 | } 53 | 54 | p { 55 | margin: 15px 0 0px; 56 | } 57 | .annotation ul, .annotation ol { 58 | margin: 25px 0; 59 | } 60 | .annotation ul li, .annotation ol li { 61 | font-size: 14px; 62 | line-height: 18px; 63 | margin: 10px 0; 64 | } 65 | 66 | h1, h2, h3, h4, h5, h6 { 67 | color: #112233; 68 | line-height: 1em; 69 | font-weight: normal; 70 | font-family: "roboto-black"; 71 | text-transform: uppercase; 72 | margin: 30px 0 15px 0; 73 | } 74 | 75 | h1 { 76 | margin-top: 40px; 77 | } 78 | h2 { 79 | font-size: 1.26em; 80 | } 81 | 82 | hr { 83 | border: 0; 84 | background: 1px #ddd; 85 | height: 1px; 86 | margin: 20px 0; 87 | } 88 | 89 | pre, tt, code { 90 | font-size: 12px; line-height: 16px; 91 | font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; 92 | margin: 0; padding: 0; 93 | } 94 | .annotation pre { 95 | display: block; 96 | margin: 0; 97 | padding: 7px 10px; 98 | background: #fcfcfc; 99 | -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 100 | -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 101 | box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 102 | overflow-x: auto; 103 | } 104 | .annotation pre code { 105 | border: 0; 106 | padding: 0; 107 | background: transparent; 108 | } 109 | 110 | 111 | blockquote { 112 | border-left: 5px solid #ccc; 113 | margin: 0; 114 | padding: 1px 0 1px 1em; 115 | } 116 | .sections blockquote p { 117 | font-family: Menlo, Consolas, Monaco, monospace; 118 | font-size: 12px; line-height: 16px; 119 | color: #999; 120 | margin: 10px 0 0; 121 | white-space: pre-wrap; 122 | } 123 | 124 | ul.sections { 125 | list-style: none; 126 | padding:0 0 5px 0;; 127 | margin:0; 128 | } 129 | 130 | /* 131 | Force border-box so that % widths fit the parent 132 | container without overlap because of margin/padding. 133 | 134 | More Info : http://www.quirksmode.org/css/box.html 135 | */ 136 | ul.sections > li > div { 137 | -moz-box-sizing: border-box; /* firefox */ 138 | -ms-box-sizing: border-box; /* ie */ 139 | -webkit-box-sizing: border-box; /* webkit */ 140 | -khtml-box-sizing: border-box; /* konqueror */ 141 | box-sizing: border-box; /* css3 */ 142 | } 143 | 144 | 145 | /*---------------------- Jump Page -----------------------------*/ 146 | #jump_to, #jump_page { 147 | margin: 0; 148 | background: white; 149 | -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; 150 | -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; 151 | font: 16px Arial; 152 | cursor: pointer; 153 | text-align: right; 154 | list-style: none; 155 | } 156 | 157 | #jump_to a { 158 | text-decoration: none; 159 | } 160 | 161 | #jump_to a.large { 162 | display: none; 163 | } 164 | #jump_to a.small { 165 | font-size: 22px; 166 | font-weight: bold; 167 | color: #676767; 168 | } 169 | 170 | #jump_to, #jump_wrapper { 171 | position: fixed; 172 | right: 0; top: 0; 173 | padding: 10px 15px; 174 | margin:0; 175 | } 176 | 177 | #jump_wrapper { 178 | display: none; 179 | padding:0; 180 | } 181 | 182 | #jump_to:hover #jump_wrapper { 183 | display: block; 184 | } 185 | 186 | #jump_page_wrapper{ 187 | position: fixed; 188 | right: 0; 189 | top: 0; 190 | bottom: 0; 191 | } 192 | 193 | #jump_page { 194 | padding: 5px 0 3px; 195 | margin: 0 0 25px 25px; 196 | max-height: 100%; 197 | overflow: auto; 198 | } 199 | 200 | #jump_page .source { 201 | display: block; 202 | padding: 15px; 203 | text-decoration: none; 204 | border-top: 1px solid #eee; 205 | } 206 | 207 | #jump_page .source:hover { 208 | background: #f5f5ff; 209 | } 210 | 211 | #jump_page .source:first-child { 212 | } 213 | 214 | /*---------------------- Low resolutions (> 320px) ---------------------*/ 215 | @media only screen and (min-width: 320px) { 216 | .pilwrap { display: none; } 217 | 218 | ul.sections > li > div { 219 | display: block; 220 | padding:5px 10px 0 10px; 221 | } 222 | 223 | ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { 224 | padding-left: 30px; 225 | } 226 | 227 | ul.sections > li > div.content { 228 | overflow-x:auto; 229 | -webkit-box-shadow: inset 0 0 5px #e5e5ee; 230 | box-shadow: inset 0 0 5px #e5e5ee; 231 | border: 1px solid #dedede; 232 | margin:5px 10px 5px 10px; 233 | padding-bottom: 5px; 234 | } 235 | 236 | ul.sections > li > div.annotation pre { 237 | margin: 7px 0 7px; 238 | padding-left: 15px; 239 | } 240 | 241 | ul.sections > li > div.annotation p tt, .annotation code { 242 | background: #f8f8ff; 243 | border: 1px solid #dedede; 244 | font-size: 12px; 245 | padding: 0 0.2em; 246 | } 247 | } 248 | 249 | /*---------------------- (> 481px) ---------------------*/ 250 | @media only screen and (min-width: 481px) { 251 | #container { 252 | position: relative; 253 | } 254 | body { 255 | background-color: #F5F5FF; 256 | font-size: 15px; 257 | line-height: 21px; 258 | } 259 | pre, tt, code { 260 | line-height: 18px; 261 | } 262 | p, ul, ol { 263 | margin: 0 0 15px; 264 | } 265 | 266 | 267 | #jump_to { 268 | padding: 5px 10px; 269 | } 270 | #jump_wrapper { 271 | padding: 0; 272 | } 273 | #jump_to, #jump_page { 274 | font: 10px Arial; 275 | text-transform: uppercase; 276 | } 277 | #jump_page .source { 278 | padding: 5px 10px; 279 | } 280 | #jump_to a.large { 281 | display: inline-block; 282 | } 283 | #jump_to a.small { 284 | display: none; 285 | } 286 | 287 | 288 | 289 | #background { 290 | position: absolute; 291 | top: 0; bottom: 0; 292 | width: 350px; 293 | background: #fff; 294 | border-right: 1px solid #e5e5ee; 295 | z-index: -1; 296 | } 297 | 298 | ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { 299 | padding-left: 40px; 300 | } 301 | 302 | ul.sections > li { 303 | white-space: nowrap; 304 | } 305 | 306 | ul.sections > li > div { 307 | display: inline-block; 308 | } 309 | 310 | ul.sections > li > div.annotation { 311 | max-width: 350px; 312 | min-width: 350px; 313 | min-height: 5px; 314 | padding: 13px; 315 | overflow-x: hidden; 316 | white-space: normal; 317 | vertical-align: top; 318 | text-align: left; 319 | } 320 | ul.sections > li > div.annotation pre { 321 | margin: 15px 0 15px; 322 | padding-left: 15px; 323 | } 324 | 325 | ul.sections > li > div.content { 326 | padding: 13px; 327 | vertical-align: top; 328 | border: none; 329 | -webkit-box-shadow: none; 330 | box-shadow: none; 331 | } 332 | 333 | .pilwrap { 334 | position: relative; 335 | display: inline; 336 | } 337 | 338 | .pilcrow { 339 | font: 12px Arial; 340 | text-decoration: none; 341 | color: #454545; 342 | position: absolute; 343 | top: 3px; left: -20px; 344 | padding: 1px 2px; 345 | opacity: 0; 346 | -webkit-transition: opacity 0.2s linear; 347 | } 348 | .for-h1 .pilcrow { 349 | top: 47px; 350 | } 351 | .for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { 352 | top: 35px; 353 | } 354 | 355 | ul.sections > li > div.annotation:hover .pilcrow { 356 | opacity: 1; 357 | } 358 | } 359 | 360 | /*---------------------- (> 1025px) ---------------------*/ 361 | @media only screen and (min-width: 1025px) { 362 | 363 | body { 364 | font-size: 16px; 365 | line-height: 24px; 366 | } 367 | 368 | #background { 369 | width: 525px; 370 | } 371 | ul.sections > li > div.annotation { 372 | max-width: 525px; 373 | min-width: 525px; 374 | padding: 10px 25px 1px 50px; 375 | } 376 | ul.sections > li > div.content { 377 | padding: 9px 15px 16px 25px; 378 | } 379 | } 380 | 381 | /*---------------------- Syntax Highlighting -----------------------------*/ 382 | 383 | td.linenos { background-color: #f0f0f0; padding-right: 10px; } 384 | span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } 385 | /* 386 | 387 | github.com style (c) Vasily Polovnyov 388 | 389 | */ 390 | 391 | pre code { 392 | display: block; padding: 0.5em; 393 | color: #000; 394 | background: #f8f8ff 395 | } 396 | 397 | pre .hljs-comment, 398 | pre .hljs-template_comment, 399 | pre .hljs-diff .hljs-header, 400 | pre .hljs-javadoc { 401 | color: #408080; 402 | font-style: italic 403 | } 404 | 405 | pre .hljs-keyword, 406 | pre .hljs-assignment, 407 | pre .hljs-literal, 408 | pre .hljs-css .hljs-rule .hljs-keyword, 409 | pre .hljs-winutils, 410 | pre .hljs-javascript .hljs-title, 411 | pre .hljs-lisp .hljs-title, 412 | pre .hljs-subst { 413 | color: #954121; 414 | /*font-weight: bold*/ 415 | } 416 | 417 | pre .hljs-number, 418 | pre .hljs-hexcolor { 419 | color: #40a070 420 | } 421 | 422 | pre .hljs-string, 423 | pre .hljs-tag .hljs-value, 424 | pre .hljs-phpdoc, 425 | pre .hljs-tex .hljs-formula { 426 | color: #219161; 427 | } 428 | 429 | pre .hljs-title, 430 | pre .hljs-id { 431 | color: #19469D; 432 | } 433 | pre .hljs-params { 434 | color: #00F; 435 | } 436 | 437 | pre .hljs-javascript .hljs-title, 438 | pre .hljs-lisp .hljs-title, 439 | pre .hljs-subst { 440 | font-weight: normal 441 | } 442 | 443 | pre .hljs-class .hljs-title, 444 | pre .hljs-haskell .hljs-label, 445 | pre .hljs-tex .hljs-command { 446 | color: #458; 447 | font-weight: bold 448 | } 449 | 450 | pre .hljs-tag, 451 | pre .hljs-tag .hljs-title, 452 | pre .hljs-rules .hljs-property, 453 | pre .hljs-django .hljs-tag .hljs-keyword { 454 | color: #000080; 455 | font-weight: normal 456 | } 457 | 458 | pre .hljs-attribute, 459 | pre .hljs-variable, 460 | pre .hljs-instancevar, 461 | pre .hljs-lisp .hljs-body { 462 | color: #008080 463 | } 464 | 465 | pre .hljs-regexp { 466 | color: #B68 467 | } 468 | 469 | pre .hljs-class { 470 | color: #458; 471 | font-weight: bold 472 | } 473 | 474 | pre .hljs-symbol, 475 | pre .hljs-ruby .hljs-symbol .hljs-string, 476 | pre .hljs-ruby .hljs-symbol .hljs-keyword, 477 | pre .hljs-ruby .hljs-symbol .hljs-keymethods, 478 | pre .hljs-lisp .hljs-keyword, 479 | pre .hljs-tex .hljs-special, 480 | pre .hljs-input_number { 481 | color: #990073 482 | } 483 | 484 | pre .hljs-builtin, 485 | pre .hljs-constructor, 486 | pre .hljs-built_in, 487 | pre .hljs-lisp .hljs-title { 488 | color: #0086b3 489 | } 490 | 491 | pre .hljs-preprocessor, 492 | pre .hljs-pi, 493 | pre .hljs-doctype, 494 | pre .hljs-shebang, 495 | pre .hljs-cdata { 496 | color: #999; 497 | font-weight: bold 498 | } 499 | 500 | pre .hljs-deletion { 501 | background: #fdd 502 | } 503 | 504 | pre .hljs-addition { 505 | background: #dfd 506 | } 507 | 508 | pre .hljs-diff .hljs-change { 509 | background: #0086b3 510 | } 511 | 512 | pre .hljs-chunk { 513 | color: #aaa 514 | } 515 | 516 | pre .hljs-tex .hljs-formula { 517 | opacity: 0.5; 518 | } 519 | -------------------------------------------------------------------------------- /docs/annotated/dokker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dokker.js 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
    15 | 16 |
  • 17 |
    18 |

    dokker.js

    19 |
    20 |
  • 21 | 22 | 23 | 24 |
  • 25 |
    26 | 27 |
    28 | 29 |
    30 |
    Dokker.js 0.0.1
     31 | http://dokker.oceanhouse21.com
     32 | (c) 2014-2015 Georg Schlenkhoff and Oceanhouse21
     33 | Dokker.js may be freely distributed under the MIT license.
     34 | 
    35 |
    36 | 37 |
    
     38 | 'use strict';
    39 | 40 |
  • 41 | 42 | 43 |
  • 44 |
    45 | 46 |
    47 | 48 |
    49 |

    Define required dependencies

    50 | 51 |
    52 | 53 |
    var Promise = require('promise');
     54 | var fs = require('fs');
     55 | var path = require('path');
     56 | var read = Promise.denodeify(fs.readFile);
     57 | var write = Promise.denodeify(fs.writeFile);
     58 | var docco = require('docco');
     59 | var docdown = require('docdown');
     60 | var marked = require('marked');
     61 | var ejs = require('ejs');
     62 | var cheerio = require('cheerio');
     63 | var exec = require('child_process').exec;
     64 | var Dokker = {};
     65 | Dokker.VERSION = '0.1.2';
    66 | 67 |
  • 68 | 69 | 70 |
  • 71 |
    72 | 73 |
    74 | 75 |
    76 |

    Transclude in a ejs template file the HTML snippet that was ultimately 77 | created with docdown. Also tweak the HTML page a bit and finally 78 | inject the README.md.

    79 | 80 |
    81 | 82 |
    Dokker.injectTemplate = function(options) {
     83 |   return new Promise(function(resolve, reject) {
     84 |     var template, body, html, readme, $;
     85 |     return read(options.template, 'utf8')
     86 |     .then(function(data) {
     87 |       template = data;
     88 |       return read(options.readme, 'utf8');
     89 |     }).then(function(data) {
     90 |       readme = marked(data);
     91 |       $ = cheerio.load(readme);
     92 |       $('h1').remove();
     93 |       readme = $.html();
     94 |       return read(options.html, 'utf8');
     95 |     }).then(function(data) {
     96 |       $ = cheerio.load(data);
     97 |       return ejs.render(template, {
     98 |         apiToc: $('.toc-container').html(),
     99 |         readme: readme,
    100 |         apiDoc: $('.doc-container').html(),
    101 | 102 |
  • 103 | 104 | 105 |
  • 106 |
    107 | 108 |
    109 | 110 |
    111 |

    correctly setting links to your github/pages

    112 | 113 |
    114 | 115 |
            page_url: options.site,
    116 |         title: options.title,
    117 |         github_url: options.github,
    118 | 119 |
  • 120 | 121 | 122 |
  • 123 |
    124 | 125 |
    126 | 127 |
    128 |

    fixed reference to generated annotation 129 | the ‘literate’ in .dokker.json shall not require a source since it’s never used.

    130 | 131 |
    132 | 133 |
            annotated_path: 'annotated/'+options.source
    134 |       });
    135 |     }).then(function(data) {
    136 |       return write(options.html, data, 'utf8');
    137 |     }).then(function() {
    138 |       resolve();
    139 |     }).then(null, function(err) {
    140 |       reject(err);
    141 |     });
    142 |   });
    143 | };
    144 | 145 |
  • 146 | 147 | 148 |
  • 149 |
    150 | 151 |
    152 | 153 |
    154 |

    Create a HTML site from any mocha tests find when executing mocha 155 | —reporter doc terminal command.

    156 | 157 |
    158 | 159 |
    Dokker.createTests = function(options) {
    160 |   return new Promise(function(resolve, reject) {
    161 |     var template, tests;
    162 | 163 |
  • 164 | 165 | 166 |
  • 167 |
    168 | 169 |
    170 | 171 |
    172 |

    allows specification of mocha.command in .dokker.json, e.g. ‘mocha -u tdd —reporter doc’

    173 | 174 |
    175 | 176 |
        var cmd = options.command || 'mocha --reporter doc';
    177 |     exec(cmd, {cwd: process.cwd()}, function(error, stdout) {
    178 |       if(error) return reject(error);
    179 |       tests = stdout;
    180 |       return read(options.template, 'utf8')
    181 |       .then(function(data) {
    182 |         template = data;
    183 |         return ejs.render(template, {tests: tests});
    184 |       }).then(function(data) {
    185 |         return write(options.path, data, 'utf8');
    186 |       }).then(function() {
    187 |         resolve();
    188 |       }).then(null, function(err) {
    189 |         reject(err);
    190 |       });
    191 |     });
    192 |   });
    193 | };
    194 | 195 |
  • 196 | 197 | 198 |
  • 199 |
    200 | 201 |
    202 | 203 |
    204 |

    Extract docs folder to separate git branch and finally push branch to 205 | Github repository

    206 | 207 |
    208 | 209 |
    Dokker.ghPages = function(){
    210 |   return new Promise(function(resolve, reject) {
    211 |     exec('git subtree split -P docs -b gh-pages', function(error, stdout, stderr) {
    212 |       if(error) return reject(stderr);
    213 |       exec('git push origin gh-pages', function(error, stdout, stderr) {
    214 |         if(error) return reject(stderr);
    215 |         resolve();
    216 |       });
    217 |     });
    218 |   });
    219 | };
    220 | 221 |
  • 222 | 223 | 224 |
  • 225 |
    226 | 227 |
    228 | 229 |
    230 |

    Create an HTML file from any source code comments in the style of 231 | literate programming

    232 | 233 |
    234 | 235 |
    Dokker.literate = function (options) {
    236 |   return new Promise(function(resolve, reject) {
    237 |     var tmpDir = path.join(process.cwd(), '/.tmp');
    238 |     var tmpFile = path.join(tmpDir, options.source);
    239 |     var sourceFile = (options.cwd) ?
    240 |       path.join(process.cwd(), options.cwd, options.source) :
    241 |       path.join(process.cwd(), options.source);
    242 |     return read(sourceFile, 'utf8')
    243 |     .then(function(data) {
    244 |       var source = data.replace(/^\s*(\*|\/\*).*[\r\n]/gm, '');
    245 |       return Dokker.mkdir(tmpDir)
    246 |       .then(function() {
    247 |         return write(tmpFile, source, 'utf8');
    248 |       }).then(function(){
    249 |         docco.run(['', '', tmpFile, '-o', options.dir]);
    250 |         resolve();
    251 |       });
    252 |     }).then(null, function(err) {
    253 |       if (err) return reject(err);
    254 |     });
    255 |   });
    256 | };
    257 | 258 |
  • 259 | 260 | 261 |
  • 262 |
    263 | 264 |
    265 | 266 |
    267 |

    Convert markdown from any source code comments with docdown module.

    268 | 269 |
    270 | 271 |
    Dokker.jsdocMarkdown = function (options) {
    272 |   return new Promise(function(resolve, reject) {
    273 |     var source, tmpFile, tmpDir;
    274 |     var sourceFile = (options.cwd) ?
    275 |       path.join(process.cwd(), options.cwd, options.source) :
    276 |       path.join(process.cwd(), options.source);
    277 |     return read(sourceFile, 'utf8')
    278 |     .then(function(data){
    279 |       source = data.replace(/^\s*(\/\/).*[\r\n]/gm, '');
    280 |       tmpDir = path.join(process.cwd(), '/.tmp');
    281 |       return Dokker.mkdir(tmpDir);
    282 |     }).then(function(){
    283 |       tmpFile = path.join(tmpDir, options.source);
    284 |       return write(tmpFile, source, 'utf8');
    285 |     }).then(function(){
    286 |       var markdown = docdown({
    287 |         'path': tmpFile,
    288 |         'url': options.github,
    289 |         'toc': 'categories'
    290 |       });
    291 |       return write(options.markdown, markdown, 'utf8');
    292 |     }).then(function() {
    293 |       resolve();
    294 |     }).then(null, function(err) {
    295 |       reject(err);
    296 |     });
    297 |   });
    298 | };
    299 | 300 |
  • 301 | 302 | 303 |
  • 304 |
    305 | 306 |
    307 | 308 |
    309 |

    Create an HTML file from any source code comments in the style of 310 | literate programming

    311 | 312 |
    313 | 314 |
    Dokker.jsdocHtml = function (options) {
    315 |   return new Promise(function(resolve, reject) {
    316 |     return read(options.markdown, 'utf8')
    317 |     .then(function(data) {
    318 |       var html = marked(data).replace(/<!-- /g,'<').replace(/ -->/g,'>');
    319 |       return write(options.html, html, 'utf8');
    320 |     }).then(function() {
    321 |       resolve();
    322 |     }).then(null, function(err) {
    323 |       reject(err);
    324 |     });
    325 |   });
    326 | };
    327 | 328 |
  • 329 | 330 | 331 |
  • 332 |
    333 | 334 |
    335 | 336 |
    337 |

    Internal helper function that creates any directory if not existing.

    338 | 339 |
    340 | 341 |
    Dokker.mkdir = function(dir) {
    342 |   return new Promise(function(resolve, reject) {
    343 |     fs.exists(dir, function(exists) {
    344 |       if (exists) {
    345 |         resolve();
    346 |       } else {
    347 |         fs.mkdir(dir, function(err) {
    348 |           if (err) return reject(err);
    349 |           resolve();
    350 |         });
    351 |       }
    352 |     });
    353 |   });
    354 | };
    355 | 356 |
  • 357 | 358 | 359 |
  • 360 |
    361 | 362 |
    363 | 364 |
    365 |

    Parses the options file, .Dokker.json, and sets the default parameters.

    366 | 367 |
    368 | 369 |
    Dokker.configure = function(options) {
    370 |   return new Promise(function(resolve, reject){
    371 |     var file = path.join(process.cwd(), '.dokker.json');
    372 |     return read(file, 'utf8')
    373 |     .then(function(data) {
    374 |       data = JSON.parse(data);
    375 |       data.jsdoc.template = (data.jsdoc.template) ? path.join(process.cwd(), data.jsdoc.template) : path.join(__dirname, 'templates/index.ejs.html');
    376 |       data.mocha.template = (data.mocha.template) ? path.join(process.cwd(), data.mocha.template) : path.join(__dirname, 'templates/tests.ejs.html');
    377 |       data.mocha.path = path.join(process.cwd(), data.dir, data.mocha.path);
    378 | 379 |
  • 380 | 381 | 382 |
  • 383 |
    384 | 385 |
    386 | 387 |
    388 |

    mocha.command commented out to fix build-breaking bug 389 | specifies mocha command in .dokker.json; e.g. mocha -u tdd -R spec 390 | data.mocha.command = path.join(process.cwd(), data.dir, data.mocha.command);

    391 | 392 |
    393 | 394 |
          data.literate.dir = path.join(process.cwd(), data.dir, data.literate.dir);
    395 |       data.jsdoc.markdown = path.join(process.cwd(), data.dir, data.jsdoc.markdown);
    396 |       data.jsdoc.html = path.join(process.cwd(), data.dir, data.jsdoc.html);
    397 |       data.jsdoc.readme = path.join(process.cwd(), data.jsdoc.readme);
    398 |       resolve(data);
    399 |     }).then(null, function(err) {
    400 |       reject(err);
    401 |     });
    402 |   });
    403 | };
    404 | 405 |
  • 406 | 407 | 408 |
  • 409 |
    410 | 411 |
    412 | 413 |
    414 |

    Copy starter template to bootstrap any Dokker project.

    415 | 416 |
    417 | 418 |
    Dokker.copyTemplate = function(options) {
    419 |   return new Promise(function(resolve, reject) {
    420 |     var templatesDir = path.join(process.cwd(), 'templates');
    421 |     return Dokker.mkdir(templatesDir)
    422 |     .then(function() {
    423 |       var oldStyle = path.join(__dirname, 'templates', 'styles.css');
    424 |       var newStyle = path.join(process.cwd(), options.dir, 'styles.css');
    425 |       fs.createReadStream(oldStyle).pipe(fs.createWriteStream(newStyle));
    426 |       var oldLogo = path.join(__dirname, 'templates', 'logo.png');
    427 |       var newLogo = path.join(process.cwd(), options.dir, 'logo.png');
    428 |       fs.createReadStream(oldLogo).pipe(fs.createWriteStream(newLogo));
    429 |       var oldApp = path.join(__dirname, 'templates', 'app.js');
    430 |       var newApp = path.join(process.cwd(), options.dir, 'app.js');
    431 |       fs.createReadStream(oldApp).pipe(fs.createWriteStream(newApp));
    432 |       resolve();
    433 |     });
    434 |   });
    435 | };
    436 | 437 |
  • 438 | 439 | 440 |
  • 441 |
    442 | 443 |
    444 | 445 |
    446 |

    Copies the .Dokker.json file to bootstrap any Dokker project.

    447 | 448 |
    449 | 450 |
    Dokker.init = function(){
    451 |   return new Promise(function(resolve, reject) {
    452 |     var oldDok = path.join(__dirname, '.dokker.json');
    453 |     var newDok = path.join(process.cwd(), '.dokker.json');
    454 |     fs.createReadStream(oldDok).pipe(fs.createWriteStream(newDok));
    455 |     resolve();
    456 |   });
    457 | };
    458 | 459 |
  • 460 | 461 | 462 |
  • 463 |
    464 | 465 |
    466 | 467 |
    468 |

    Starts the Node.js/Express server to watch Dokker.js project 469 | documentation.

    470 | 471 |
    472 | 473 |
    Dokker.watch = function(options) {
    474 |   var gulpex = require(__dirname + '/gulpfile.js').gulpex;
    475 |   return gulpex();
    476 | 477 |
  • 478 | 479 | 480 |
  • 481 |
    482 | 483 |
    484 | 485 |
    486 |

    return new Promise(function(resolve, reject){ 487 | exec(‘DIR=’+ options.dir + ‘ node ‘ + options.dir + ‘/app.js’, function(error, stdout, stderr){ 488 | if(error) return reject(stderr); 489 | }); 490 | });

    491 | 492 |
    493 | 494 |
    };
    495 | 
    496 | module.exports = Dokker;
    497 | 498 |
  • 499 | 500 |
501 |
502 | 503 | 504 | -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-bold.eot -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-bold.ttf -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-bold.woff -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-light.eot -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-light.ttf -------------------------------------------------------------------------------- /docs/annotated/public/fonts/aller-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/aller-light.woff -------------------------------------------------------------------------------- /docs/annotated/public/fonts/roboto-black.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/roboto-black.eot -------------------------------------------------------------------------------- /docs/annotated/public/fonts/roboto-black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/roboto-black.ttf -------------------------------------------------------------------------------- /docs/annotated/public/fonts/roboto-black.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/annotated/public/fonts/roboto-black.woff -------------------------------------------------------------------------------- /docs/annotated/public/stylesheets/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v2.0.1 | MIT License | git.io/normalize */ 2 | 3 | /* ========================================================================== 4 | HTML5 display definitions 5 | ========================================================================== */ 6 | 7 | /* 8 | * Corrects `block` display not defined in IE 8/9. 9 | */ 10 | 11 | article, 12 | aside, 13 | details, 14 | figcaption, 15 | figure, 16 | footer, 17 | header, 18 | hgroup, 19 | nav, 20 | section, 21 | summary { 22 | display: block; 23 | } 24 | 25 | /* 26 | * Corrects `inline-block` display not defined in IE 8/9. 27 | */ 28 | 29 | audio, 30 | canvas, 31 | video { 32 | display: inline-block; 33 | } 34 | 35 | /* 36 | * Prevents modern browsers from displaying `audio` without controls. 37 | * Remove excess height in iOS 5 devices. 38 | */ 39 | 40 | audio:not([controls]) { 41 | display: none; 42 | height: 0; 43 | } 44 | 45 | /* 46 | * Addresses styling for `hidden` attribute not present in IE 8/9. 47 | */ 48 | 49 | [hidden] { 50 | display: none; 51 | } 52 | 53 | /* ========================================================================== 54 | Base 55 | ========================================================================== */ 56 | 57 | /* 58 | * 1. Sets default font family to sans-serif. 59 | * 2. Prevents iOS text size adjust after orientation change, without disabling 60 | * user zoom. 61 | */ 62 | 63 | html { 64 | font-family: sans-serif; /* 1 */ 65 | -webkit-text-size-adjust: 100%; /* 2 */ 66 | -ms-text-size-adjust: 100%; /* 2 */ 67 | } 68 | 69 | /* 70 | * Removes default margin. 71 | */ 72 | 73 | body { 74 | margin: 0; 75 | } 76 | 77 | /* ========================================================================== 78 | Links 79 | ========================================================================== */ 80 | 81 | /* 82 | * Addresses `outline` inconsistency between Chrome and other browsers. 83 | */ 84 | 85 | a:focus { 86 | outline: thin dotted; 87 | } 88 | 89 | /* 90 | * Improves readability when focused and also mouse hovered in all browsers. 91 | */ 92 | 93 | a:active, 94 | a:hover { 95 | outline: 0; 96 | } 97 | 98 | /* ========================================================================== 99 | Typography 100 | ========================================================================== */ 101 | 102 | /* 103 | * Addresses `h1` font sizes within `section` and `article` in Firefox 4+, 104 | * Safari 5, and Chrome. 105 | */ 106 | 107 | h1 { 108 | font-size: 2em; 109 | } 110 | 111 | /* 112 | * Addresses styling not present in IE 8/9, Safari 5, and Chrome. 113 | */ 114 | 115 | abbr[title] { 116 | border-bottom: 1px dotted; 117 | } 118 | 119 | /* 120 | * Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome. 121 | */ 122 | 123 | b, 124 | strong { 125 | font-weight: bold; 126 | } 127 | 128 | /* 129 | * Addresses styling not present in Safari 5 and Chrome. 130 | */ 131 | 132 | dfn { 133 | font-style: italic; 134 | } 135 | 136 | /* 137 | * Addresses styling not present in IE 8/9. 138 | */ 139 | 140 | mark { 141 | background: #ff0; 142 | color: #000; 143 | } 144 | 145 | 146 | /* 147 | * Corrects font family set oddly in Safari 5 and Chrome. 148 | */ 149 | 150 | code, 151 | kbd, 152 | pre, 153 | samp { 154 | font-family: monospace, serif; 155 | font-size: 1em; 156 | } 157 | 158 | /* 159 | * Improves readability of pre-formatted text in all browsers. 160 | */ 161 | 162 | pre { 163 | white-space: pre; 164 | white-space: pre-wrap; 165 | word-wrap: break-word; 166 | } 167 | 168 | /* 169 | * Sets consistent quote types. 170 | */ 171 | 172 | q { 173 | quotes: "\201C" "\201D" "\2018" "\2019"; 174 | } 175 | 176 | /* 177 | * Addresses inconsistent and variable font size in all browsers. 178 | */ 179 | 180 | small { 181 | font-size: 80%; 182 | } 183 | 184 | /* 185 | * Prevents `sub` and `sup` affecting `line-height` in all browsers. 186 | */ 187 | 188 | sub, 189 | sup { 190 | font-size: 75%; 191 | line-height: 0; 192 | position: relative; 193 | vertical-align: baseline; 194 | } 195 | 196 | sup { 197 | top: -0.5em; 198 | } 199 | 200 | sub { 201 | bottom: -0.25em; 202 | } 203 | 204 | /* ========================================================================== 205 | Embedded content 206 | ========================================================================== */ 207 | 208 | /* 209 | * Removes border when inside `a` element in IE 8/9. 210 | */ 211 | 212 | img { 213 | border: 0; 214 | } 215 | 216 | /* 217 | * Corrects overflow displayed oddly in IE 9. 218 | */ 219 | 220 | svg:not(:root) { 221 | overflow: hidden; 222 | } 223 | 224 | /* ========================================================================== 225 | Figures 226 | ========================================================================== */ 227 | 228 | /* 229 | * Addresses margin not present in IE 8/9 and Safari 5. 230 | */ 231 | 232 | figure { 233 | margin: 0; 234 | } 235 | 236 | /* ========================================================================== 237 | Forms 238 | ========================================================================== */ 239 | 240 | /* 241 | * Define consistent border, margin, and padding. 242 | */ 243 | 244 | fieldset { 245 | border: 1px solid #c0c0c0; 246 | margin: 0 2px; 247 | padding: 0.35em 0.625em 0.75em; 248 | } 249 | 250 | /* 251 | * 1. Corrects color not being inherited in IE 8/9. 252 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 253 | */ 254 | 255 | legend { 256 | border: 0; /* 1 */ 257 | padding: 0; /* 2 */ 258 | } 259 | 260 | /* 261 | * 1. Corrects font family not being inherited in all browsers. 262 | * 2. Corrects font size not being inherited in all browsers. 263 | * 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome 264 | */ 265 | 266 | button, 267 | input, 268 | select, 269 | textarea { 270 | font-family: inherit; /* 1 */ 271 | font-size: 100%; /* 2 */ 272 | margin: 0; /* 3 */ 273 | } 274 | 275 | /* 276 | * Addresses Firefox 4+ setting `line-height` on `input` using `!important` in 277 | * the UA stylesheet. 278 | */ 279 | 280 | button, 281 | input { 282 | line-height: normal; 283 | } 284 | 285 | /* 286 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 287 | * and `video` controls. 288 | * 2. Corrects inability to style clickable `input` types in iOS. 289 | * 3. Improves usability and consistency of cursor style between image-type 290 | * `input` and others. 291 | */ 292 | 293 | button, 294 | html input[type="button"], /* 1 */ 295 | input[type="reset"], 296 | input[type="submit"] { 297 | -webkit-appearance: button; /* 2 */ 298 | cursor: pointer; /* 3 */ 299 | } 300 | 301 | /* 302 | * Re-set default cursor for disabled elements. 303 | */ 304 | 305 | button[disabled], 306 | input[disabled] { 307 | cursor: default; 308 | } 309 | 310 | /* 311 | * 1. Addresses box sizing set to `content-box` in IE 8/9. 312 | * 2. Removes excess padding in IE 8/9. 313 | */ 314 | 315 | input[type="checkbox"], 316 | input[type="radio"] { 317 | box-sizing: border-box; /* 1 */ 318 | padding: 0; /* 2 */ 319 | } 320 | 321 | /* 322 | * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. 323 | * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome 324 | * (include `-moz` to future-proof). 325 | */ 326 | 327 | input[type="search"] { 328 | -webkit-appearance: textfield; /* 1 */ 329 | -moz-box-sizing: content-box; 330 | -webkit-box-sizing: content-box; /* 2 */ 331 | box-sizing: content-box; 332 | } 333 | 334 | /* 335 | * Removes inner padding and search cancel button in Safari 5 and Chrome 336 | * on OS X. 337 | */ 338 | 339 | input[type="search"]::-webkit-search-cancel-button, 340 | input[type="search"]::-webkit-search-decoration { 341 | -webkit-appearance: none; 342 | } 343 | 344 | /* 345 | * Removes inner padding and border in Firefox 4+. 346 | */ 347 | 348 | button::-moz-focus-inner, 349 | input::-moz-focus-inner { 350 | border: 0; 351 | padding: 0; 352 | } 353 | 354 | /* 355 | * 1. Removes default vertical scrollbar in IE 8/9. 356 | * 2. Improves readability and alignment in all browsers. 357 | */ 358 | 359 | textarea { 360 | overflow: auto; /* 1 */ 361 | vertical-align: top; /* 2 */ 362 | } 363 | 364 | /* ========================================================================== 365 | Tables 366 | ========================================================================== */ 367 | 368 | /* 369 | * Remove most spacing between table cells. 370 | */ 371 | 372 | table { 373 | border-collapse: collapse; 374 | border-spacing: 0; 375 | } -------------------------------------------------------------------------------- /docs/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var path = require('path'); 4 | var livereload = require('livereload'); 5 | var path = path.join(process.cwd(), process.env.DIR); 6 | livereload.createServer({exts: ['applyJSLive']}).watch(path); 7 | app.use(express.static(path)); 8 | app.listen(9000); 9 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Dokker.js 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Dokker.js

16 | 22 | 23 |
24 |

Github Pages

25 | 28 |
29 |
30 |

JSDoc

31 | 36 |
37 |
38 |

Literate programming

39 | 42 |
43 |
44 |

Mocha

45 | 48 |
49 |
50 |

Utility

51 | 57 |
58 |
59 |

Methods

60 |
61 |
62 |

Properties

63 | 66 |
67 | 68 |
69 |
70 |
71 |

dokker logo

72 |

Dokker.js creates professional Javascript code documentations.

73 |

See Dokker.js documentation as example.

74 |

Build Status

75 |

Features

76 |
    77 |
  • Create or HTML or markdown documentation from JSDOC tags
  • 78 |
  • Support for literate programming documentation
  • 79 |
  • Live edit source code and watch changes
  • 80 |
  • Include link to your Github repository
  • 81 |
  • Customize your own templates with ejs or use default style
  • 82 |
  • Create feature description from mocha test suite
  • 83 |
  • Automagically include your README.md into the documentation
  • 84 |
  • Use your own logo to make an astonishing impression
  • 85 |
  • Deploy documentation to Github pages on the fly
  • 86 |
87 |

Community

88 |

Gitter

89 |

Installation

90 |

Dokker is available as npm package. So the easiest way is to install dokker as global module into your project:

91 |
npm install -g dokker
 92 | 

Usage

93 |

After installation you can execute Dokker with the help of several terminal commands.

94 |

Bootstrap Dokker project

95 |

Dokker needs a configuration file to execute, such as a .travis or .jshintrc. You can easily create .dokker.json file with the dokker-init command from the root directory of your project or copy an example file.

96 |

Dokker provides a default template for your project. The template is based on an ejs file. Either you use the default template or modify it. If you choose for the latter you can copy the templates directory and tweak the ejs files how you like.

97 |

Create documentation

98 |

Creating a documentation is really simple with the help of Dokker. You just configure the .dokker.json file and execute dokker. Then you’re done.

99 |

Live edit your documentation

100 |

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.

101 | 104 |

Deploy to Github Pages

105 |

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.

106 |

Dokker in the wild

107 |

Some examples by our users. Let us know what you did with Dokker too!

108 | 112 |

Further Reading

113 | 120 |

Contributors

121 | 125 | 126 |

API documentation

127 | 128 |
129 |

“Github Pages” Methods

130 |
131 |

Dokker.ghPages()

132 |

# [Ⓣ][1]

133 |

Runs a terminal shell with the git command to extract the docs branch 134 | into a seperate gh-pages branch and finally pushes that branch to Github, 135 | so that the Github page is updated.

136 |

Returns

137 |

(Promise): Returns a resolved promise if file was created.

138 |

Example

139 |
Dokker.ghPages()
140 | .then(function(){
141 |   // => resolved promise
142 | });
143 | 
144 |
145 |
146 |
147 |
148 |

“JSDoc” Methods

149 |
150 |

Dokker.injectTemplate([options])

151 |

# [Ⓣ][1]

152 |

Creates a HTML file that transcludes the HTML snippet that was created 153 | by the docdown module into an ejs template which is defined by the 154 | .dokker.json configuration file.

155 |

Arguments

156 |
    157 |
  1. [options] (Object): The options object.
  2. 158 |
  3. [options.template='template/index.ejs.html'] (String): The path to the ejs template file.
  4. 159 |
  5. [options.html='docs/index.html'] (string): The path to the docdown generated JSDoc documentation.
  6. 160 |
  7. [options.readme='README.md'] (string): The path to the README.md file.
  8. 161 |
  9. [options.title=''] (string): The title for the documentation.
  10. 162 |
163 |

Returns

164 |

(Promise): Returns a resolved promise if file was created.

165 |

Example

166 |
var options = {
167 |   template: 'template/index.ejs.html',
168 |   html: 'docs/index.html',
169 |   readme: 'docs/README.md',
170 |   title: 'Dokker.js API Documentation'
171 | };
172 | Dokker.injectTemplate(options)
173 | .then(function(){
174 |   // => resolved promise
175 | });
176 | 
177 |
178 |
179 |
180 |

Dokker.jsdocHtml([options])

181 |

# [Ⓣ][1]

182 |

Create an HTML file from the Markdown file that was create with 183 | Dokker.jsdocMarkdown()

184 |

Arguments

185 |
    186 |
  1. [options] (Object): The options object.
  2. 187 |
  3. [options.markdown='docs/READMDE.md'] (string): The path where to save the Markdown file.
  4. 188 |
189 |

Returns

190 |

(Promise): Returns a resolved promise if file was created.

191 |

Example

192 |
var options = {
193 |   markdown: 'docs/README.md'
194 | };
195 | Dokker.jsdocHtml()
196 | .then(function(){
197 |   // => resolved promise
198 | });
199 | 
200 |
201 |
202 |
203 |

Dokker.jsdocMarkdown([options])

204 |

# [Ⓣ][1]

205 |

Create a Markdown file from JSDoc tags.

206 |

Arguments

207 |
    208 |
  1. [options] (Object): The options object.
  2. 209 |
  3. [options.source='app.js'] (String): The path the source code with JSDoc tags.
  4. 210 |
  5. [options.github =''] (String): The path the Github repository.
  6. 211 |
  7. [options.markdown='docs/READMDE.md'] (string): The path where to save the Markdown file.
  8. 212 |
213 |

Returns

214 |

(Promise): Returns a resolved promise if file was created.

215 |

Example

216 |
var options = {
217 |   source: 'app.js',
218 |   markdown: 'docs/README.md'
219 | };
220 | Dokker.jsdocMarkdown()
221 | .then(function(){
222 |   // => resolved promise
223 | });
224 | 
225 |
226 |
227 |
228 |
229 |

“Literate programming” Methods

230 |
231 |

Dokker.literate([options])

232 |

# [Ⓣ][1]

233 |

Create a styled HTML file from your source code with the help of docco 234 | module.

235 |

Arguments

236 |
    237 |
  1. [options] (Object): The options object.
  2. 238 |
  3. [options.source='app.js'] (String): The path the source code with comments
  4. 239 |
  5. [options.dir='docs/annotated'] (string): The directory where to save the generated HTML file.
  6. 240 |
241 |

Returns

242 |

(Promise): Returns a resolved promise if file was created.

243 |

Example

244 |
var options = {
245 |   dir: 'docs',
246 |   source: 'app.js'
247 | };
248 | Dokker.literate()
249 | .then(function(){
250 |   // => resolved promise
251 | });
252 | 
253 |
254 |
255 |
256 |
257 |

“Mocha” Methods

258 |
259 |

Dokker.createTests([options])

260 |

# [Ⓣ][1]

261 |

Creates an HTML file to describe the features of your module from your 262 | Mocha tests. The module is using the mocha doc reporter to 263 | generate the HTML contents.

264 |

Arguments

265 |
    266 |
  1. [options] (Object): The options object.
  2. 267 |
  3. [options.path='docs.html'] (String): The path where to save the HTML file
  4. 268 |
269 |

Returns

270 |

(Promise): Returns a resolved promise if file was created.

271 |

Example

272 |
var options = {
273 |   path: 'docs/tests.html',
274 | };
275 | Dokker.createTests(options)
276 | .then(function(){
277 |   // => resolved promise
278 | });
279 | 
280 |
281 |
282 |
283 |
284 |

“Utility” Methods

285 |
286 |

Dokker.configure([options])

287 |

# [Ⓣ][1]

288 |

Helper function that takes a couple of options arguments and 289 | normalises them and subsequently returns them.

290 |

Arguments

291 |
    292 |
  1. [options] (Object): The options object.
  2. 293 |
  3. [options.li.markdown='docs/READMDE.md'] (string): The path where to
  4. 294 |
  5. [options.source='app.js'] (String): The path the source code with JSDoc tags.
  6. 295 |
  7. [options.jsdoc.markdown='docs/READMDE.md'] (string): The path where to save the Markdown file.
  8. 296 |
  9. [options.jsdoc.README ='READMDE.md'] (string): The path to the project’s README.md file
  10. 297 |
  11. [options.jsodc.template ='templates/index.ejs.html'] (String): The path to the ejs template.
  12. 298 |
  13. [options.mocha.template='templates/tests.ejs.html'] (String): The path to the mocha template.
  14. 299 |
  15. [options.dir='docs'] (String): The path where to store the generated files
  16. 300 |
301 |

Returns

302 |

(Promise): Returns a resolved promise with edited options object

303 |

Example

304 |
var options = {
305 |   dir: 'docs',
306 |   literate: {
307 |     source: 'dokker.js',
308 |     dir: 'annotated'
309 |   },
310 |   jsdoc: {
311 |     title: 'Dokker.js',
312 |     source: 'dokker.js',
313 |     markdown: 'README.md',
314 |     html: 'index.html',
315 |     readme: 'README.md',
316 |   }
317 | };
318 | Dokker.jsdocHtml()
319 | .then(function(){
320 |   // => object with absolute pathes to the directory from
321 |   // which the command was executed
322 | });
323 | 
324 |
325 |
326 |
327 |

Dokker.copyTemplate([options])

328 |

# [Ⓣ][1]

329 |

Copy the template to local directory so that one can make changes to ejs 330 | files.

331 |

Arguments

332 |
    333 |
  1. [options] (Object): The options object.
  2. 334 |
  3. [options.dir='templates'] (string): The path where to save the template files
  4. 335 |
336 |

Returns

337 |

(Promise): Returns a resolved promise if files were created.

338 |

Example

339 |
var options = {
340 |   dir: 'template'
341 | };
342 | Dokker.copyTemplate()
343 | .then(function(){
344 |   // => resolved promise
345 | });
346 | 
347 |
348 |
349 |
350 |

Dokker.init()

351 |

# [Ⓣ][1]

352 |

Create a .dokker.json file to bootstrap any Dokker project

353 |

Returns

354 |

(Promise): Returns a resolved promise if files were created.

355 |

Example

356 |
Dokker.init()
357 | .then(function(){
358 |   // => resolved promise
359 | });
360 | 
361 |
362 |
363 |
364 |

Dokker.watch()

365 |

# [Ⓣ][1]

366 |

Starts a Node.js/Express webserver in docs directory to watch 367 | the build Dokker project

368 |

Returns

369 |

(Promise): Returns a resolved promise if files were created.

370 |

Example

371 |
Dokker.init()
372 | .then(function(){
373 |   // => resolved promise
374 | });
375 | 
376 |
377 |
378 |
379 |
380 |

Methods

381 |
382 |
383 |

Properties

384 |
385 |

Dokker.VERSION

386 |

# [Ⓣ][1]

387 |

(string): The semantic version number.

388 |
389 |
390 |
391 | 392 |
393 |
394 | 395 | 396 | 397 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/docs/logo.png -------------------------------------------------------------------------------- /docs/styles.css: -------------------------------------------------------------------------------- 1 | body, 2 | h1, 3 | h2, 4 | html, 5 | p { 6 | margin: 0; 7 | padding: 0 8 | } 9 | html { 10 | background: #d3d3d3; 11 | height: 100%; 12 | color: #222; 13 | font-size: 100% 14 | } 15 | body { 16 | background: #fff; 17 | width: 60em; 18 | margin: 0 auto; 19 | -webkit-box-shadow: 0 0 2.5em #5d656c; 20 | -moz-box-shadow: 0 0 2.5em #5d656c; 21 | box-shadow: 0 0 2.5em #5d656c; 22 | font: 1em/1.7'Helvetica Neue', Helvetica, Arial, sans-serif; 23 | min-height: 100% 24 | } 25 | code { 26 | /*font-family: 'Roboto', 'Helvetica Neue', sans-serif;*/ 27 | font-family: 'Source Code Pro', Consolas, 'Courier New', monospace; 28 | letter-spacing: 0.03em; 29 | } 30 | .lang-js { 31 | color: #78dbf9; 32 | } 33 | span.hljs-number { 34 | color: #d59cf6; 35 | } 36 | span.hljs-string{ 37 | color: #8bdb97; 38 | } 39 | span.hljs-regexp{ 40 | color: #dbad83; 41 | } 42 | span.hljs-literal{ 43 | color: #e26a78; 44 | } 45 | span.hljs-keyword{ 46 | color: #d59cf6; 47 | } 48 | span.hljs-comment { 49 | color: #99a4c7; 50 | } 51 | span.hljs-special { 52 | color: #bdc4df; 53 | } 54 | pre { 55 | box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255); 56 | box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392); 57 | box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529); 58 | border-bottom-left-radius: 5px; 59 | border-bottom-right-radius: 5px; 60 | background: #2b303b; 61 | margin: 1em 0; 62 | padding: .5em 20px; 63 | overflow-x: scroll; 64 | -webkit-overflow-scrolling: touch 65 | } 66 | pre.intro { 67 | font-size: 1.2em 68 | } 69 | pre::-webkit-scrollbar { 70 | height: 8px 71 | } 72 | pre::-webkit-scrollbar-thumb { 73 | background: rgba(255, 255, 255, .8); 74 | -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .5); 75 | -webkit-border-radius: 10px; 76 | border-radius: 10px 77 | } 78 | pre::-webkit-scrollbar-thumb:window-inactive { 79 | background: rgba(255, 255, 255, .4) 80 | } 81 | h1 span, 82 | pre { 83 | color: #ddd 84 | } 85 | h1, 86 | h2, 87 | h3, 88 | h4, 89 | ol, 90 | p, 91 | ul { 92 | font-weight: 400; 93 | padding: 0 20px; 94 | word-wrap: break-word 95 | } 96 | hgroup h1 { 97 | display: inline 98 | } 99 | hgroup h2 { 100 | font-size: 1.38em 101 | } 102 | h2, 103 | h3, 104 | h4 { 105 | margin: 0 0 .5em 106 | } 107 | h4 { 108 | font-weight: 700 109 | } 110 | a { 111 | color: #222; 112 | border-bottom: 1px solid #ddd; 113 | text-decoration: none 114 | } 115 | a:focus, 116 | a:hover { 117 | border-color: #222 118 | } 119 | a img { 120 | border: 0 121 | } 122 | abbr[title] { 123 | border-bottom: 1px dotted #ddd; 124 | cursor: help 125 | } 126 | hr { 127 | display: none 128 | } 129 | p { 130 | margin-bottom: 1em 131 | } 132 | ol, 133 | ul { 134 | margin-left: 2em 135 | } 136 | ol ol, 137 | ul ul { 138 | margin-left: 1em; 139 | padding: 0 140 | } 141 | footer { 142 | display: block; 143 | background: #eee; 144 | padding: 1em 0; 145 | text-align: center 146 | } 147 | .a-img { 148 | border: 0 149 | } 150 | .a-img img { 151 | padding: .5em 0 0 152 | } 153 | .description { 154 | word-wrap: break-word 155 | } 156 | .multiline-items li { 157 | padding-bottom: 1em 158 | } 159 | .multiline-items li.last-item { 160 | padding-bottom: 0 161 | } 162 | .br0 { 163 | color: #090 164 | } 165 | .co1 { 166 | color: #060 167 | } 168 | .co2 { 169 | color: #096 170 | } 171 | .kw1, 172 | .kw3 { 173 | color: #006 174 | } 175 | .kw2 { 176 | color: #036 177 | } 178 | .me1 { 179 | color: #606 180 | } 181 | .nu0 { 182 | color: #c00 183 | } 184 | .st0 { 185 | color: #36c 186 | } 187 | .sy0 { 188 | color: #393; 189 | font-weight: 700 190 | } 191 | pre .co1 { 192 | color: #aeaeae 193 | } 194 | .es0, 195 | pre .st0 { 196 | color: #61ce3c 197 | } 198 | pre .co2 { 199 | color: #fff 200 | } 201 | pre .kw2, 202 | pre .kw3, 203 | pre .nu0 { 204 | color: #fbde2d 205 | } 206 | pre .me1 { 207 | color: #8da6ce 208 | } 209 | pre .br0, 210 | pre .kw1, 211 | pre .sy0 { 212 | color: #ddd 213 | } 214 | #docs { 215 | background: #fff 216 | } 217 | #docs body { 218 | font-size: .85em; 219 | width: 100% 220 | } 221 | #docs a.alias { 222 | opacity: .5 223 | } 224 | #docs div div div div { 225 | box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255); 226 | box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392); 227 | box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529); 228 | border-bottom-left-radius: 5px; 229 | border-bottom-right-radius: 5px; 230 | } 231 | #docs div div div { 232 | border-top: 0; 233 | margin: 0 .5em 1em 234 | } 235 | #docs h1, 236 | #docs h2, 237 | #docs h3, 238 | #docs h4, 239 | #docs ol, 240 | #docs p, 241 | #docs ul { 242 | padding: 0 10px 243 | } 244 | #docs pre { 245 | margin: 0; 246 | padding: .5em 10px 247 | } 248 | #docs ul li { 249 | list-style-type: none; 250 | margin: 0 0 0 -.9em 251 | } 252 | #docs h1 { 253 | padding: 0 10px 254 | } 255 | #docs h2 { 256 | margin: .5em 0 0 257 | } 258 | #docs h3 { 259 | background: rgb(63, 107, 196); 260 | border-radius: 3px 3px 0 0; 261 | border: 1px solid rgba(75, 71, 71, 0.14); 262 | margin: .5em 0; 263 | padding: .8em 0 .8em 10px; 264 | position: relative 265 | } 266 | #docs h3>code { 267 | color: #fbfbfb 268 | } 269 | #docs h3 a { 270 | position: absolute; 271 | top: 0 272 | } 273 | #docs h3 .br0 { 274 | color: #fc83ff 275 | } 276 | #docs h3 .kw2 { 277 | color: #71d0c9 278 | } 279 | #docs h3 .me1 { 280 | color: #fff 281 | } 282 | #docs h3 .nu0 { 283 | color: #d0cb71 284 | } 285 | #docs h3 .sy0 { 286 | color: #df74e2; 287 | font-weight: 700 288 | } 289 | #docs footer { 290 | height: 3em; 291 | margin-top: 1.5em; 292 | width: 100% 293 | } 294 | #social { 295 | height: 20px 296 | } 297 | #social .twitter-follow-button { 298 | width: 127px!important 299 | } 300 | #social .twitter-follow-button, 301 | .twitter-share-button { 302 | font-size: .8em; 303 | vertical-align: top 304 | } 305 | @media (max-width: 959px) { 306 | body { 307 | border: 0; 308 | margin: 0; 309 | -moz-box-shadow: none; 310 | -webkit-box-shadow: none; 311 | box-shadow: none; 312 | width: auto 313 | } 314 | h1, 315 | h2, 316 | h3, 317 | h4, 318 | ol, 319 | p, 320 | ul { 321 | padding: 0 10px 322 | } 323 | pre { 324 | padding: 5px 10px!important 325 | } 326 | #social { 327 | height: auto 328 | } 329 | .toc-container a { 330 | display: block; 331 | padding: 5px 332 | } 333 | .toc-container a:focus, 334 | .toc-container a:hover { 335 | background-color: #EEE 336 | } 337 | .toc-container a:active { 338 | background-color: #CCC 339 | } 340 | } 341 | @media (min-width: 960px) { 342 | #docs body { 343 | box-shadow: none; 344 | height: 100%; 345 | margin: 0 346 | } 347 | #docs a[href="#docs"], 348 | #docs footer { 349 | display: none 350 | } 351 | #docs h1 { 352 | position: fixed; 353 | background-color: #fff; 354 | top: 0; 355 | left: 0; 356 | right: 0; 357 | z-index: 1 358 | } 359 | #docs h3 a { 360 | display: block; 361 | position: relative; 362 | visibility: hidden; 363 | top: -4em 364 | } 365 | #docs .toc-container { 366 | background: #fff; 367 | bottom: 0; 368 | left: 0; 369 | overflow-y: scroll; 370 | overflow-x: hidden; 371 | position: fixed; 372 | top: 1.5em; 373 | white-space: nowrap; 374 | width: 20%; 375 | -webkit-overflow-scrolling: touch 376 | } 377 | #docs .toc-container h2, 378 | #docs .toc-container ul { 379 | margin-top: 0; 380 | padding: 0 10px 381 | } 382 | #docs .doc-container { 383 | background: #fff; 384 | width: 80%; 385 | margin-left: 20%; 386 | padding-top: 1.5em 387 | } 388 | #docs .doc-container .first-heading { 389 | margin-top: 0 390 | } 391 | } 392 | @media (-ms-high-contrast: active) and (max-width: 1280px), 393 | (-ms-high-contrast: none) and (max-width: 1280px) { 394 | #docs .doc-container, 395 | #docs .toc-container { 396 | position: relative; 397 | top: auto; 398 | width: 100% 399 | } 400 | #docs .doc-container .first-heading { 401 | margin-top: .5em 402 | } 403 | #docs a[href="#docs"] { 404 | display: inline 405 | } 406 | #docs footer { 407 | display: block 408 | } 409 | } 410 | @media (orientation: portrait) and (min-device-width: 720px) and (max-device-width: 768px), 411 | (orientation: landscape) and (device-width: 1280px) and (max-device-height: 768px) { 412 | @-ms-viewport{width:80%}} 413 | -------------------------------------------------------------------------------- /docs/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dokker.js 7 | 8 | 19 | 38 | 39 | 40 |
41 |

Dokker

42 |
43 |
44 |

.literate()

45 |
46 |
creates a HTML file from annotated source code
47 |
return Dokker.literate(options.literate)
 48 | .then(function(){
 49 |   done();
 50 | }).done();
51 |
52 |
53 |
54 |

.jsdocMarkdown()

55 |
56 | docco: /Users/georgschlenkhoff/Downloads/dokker/.tmp/dokker.js -> /Users/georgschlenkhoff/Downloads/dokker/docs/annotated/dokker.html 57 |
creates a markdown file from JSDOC comments
58 |
return Dokker.jsdocMarkdown(options.jsdoc)
 59 | .then(function(){
 60 |   return read(options.jsdoc.markdown);
 61 | }).then(function(){
 62 |   done();
 63 | }).done();
64 |
65 |
66 |
67 |

.jsdocHtml()

68 |
69 |
creates a HTML file from JSDOC commments
70 |
return Dokker.jsdocHtml(options.jsdoc)
 71 | .then(function(){
 72 |   return read(options.jsdoc.html);
 73 | }).then(function(){
 74 |   done();
 75 | }).done();
76 |
77 |
78 |
79 |

.injectTemplate()

80 |
81 |
injects index.html file in ejs template
82 |
return Dokker.injectTemplate(options.jsdoc)
 83 | .then(function() {
 84 |   return read(options.jsdoc.html, 'utf8');
 85 | }).then(function(data){
 86 |   assert(/<!DOCTYPE html>/.test(data));
 87 |   done();
 88 | }).done();
89 |
90 |
91 |
92 |

.copyTemplate()

93 |
94 |
copies styles and app.js from template folder
95 |
return Dokker.copyTemplate(options)
 96 | .then(function(){
 97 |   return read(path.join(__dirname, '..', options.dir, 'styles.css'));
 98 | }).then(function(data){
 99 |   assert(data);
100 |   done();
101 | }).done();
102 |
103 |
104 |
105 |
106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /dokker.js: -------------------------------------------------------------------------------- 1 | // Dokker.js 0.0.1 2 | // http://dokker.oceanhouse21.com 3 | // (c) 2014-2015 Georg Schlenkhoff and Oceanhouse21 4 | // Dokker.js may be freely distributed under the MIT license. 5 | 6 | 'use strict'; 7 | 8 | // Define required dependencies 9 | var Promise = require('promise'); 10 | var fs = require('fs'); 11 | var path = require('path'); 12 | var read = Promise.denodeify(fs.readFile); 13 | var write = Promise.denodeify(fs.writeFile); 14 | var docco = require('docco'); 15 | var docdown = require('docdown'); 16 | var marked = require('marked'); 17 | var ejs = require('ejs'); 18 | var cheerio = require('cheerio'); 19 | var exec = require('child_process').exec; 20 | var Dokker = {}; 21 | 22 | /** 23 | * The semantic version number. 24 | * 25 | * @static 26 | * @memberOf Dokker 27 | * @type string 28 | */ 29 | Dokker.VERSION = '0.1.2'; 30 | 31 | /** 32 | * Creates a HTML file that transcludes the HTML snippet that was created 33 | * by the docdown module into an ejs template which is defined by the 34 | * .dokker.json configuration file. 35 | * 36 | * @static 37 | * @category JSDoc 38 | * @memberOf Dokker 39 | * @type Function 40 | * @param {Object} [options] The options object. 41 | * @param {String} [options.template='template/index.ejs.html'] The path to 42 | * the ejs template file. 43 | * @param {string} [options.html='docs/index.html'] The path to the docdown 44 | * generated JSDoc documentation. 45 | * @param {string} [options.readme='README.md'] The path to the README.md 46 | * file. 47 | * @param {string} [options.title=''] The title for the documentation. 48 | * @returns {Promise} Returns a resolved promise if file was created. 49 | * @example 50 | * 51 | * var options = { 52 | * template: 'template/index.ejs.html', 53 | * html: 'docs/index.html', 54 | * readme: 'docs/README.md', 55 | * title: 'Dokker.js API Documentation' 56 | * }; 57 | * Dokker.injectTemplate(options) 58 | * .then(function(){ 59 | * // => resolved promise 60 | * }); 61 | */ 62 | // Transclude in a ejs template file the HTML snippet that was ultimately 63 | // created with docdown. Also tweak the HTML page a bit and finally 64 | // inject the README.md. 65 | Dokker.injectTemplate = function(options) { 66 | return new Promise(function(resolve, reject) { 67 | var template, body, html, readme, $; 68 | return read(options.template, 'utf8') 69 | .then(function(data) { 70 | template = data; 71 | return read(options.readme, 'utf8'); 72 | }).then(function(data) { 73 | readme = marked(data); 74 | $ = cheerio.load(readme); 75 | $('h1').remove(); 76 | readme = $.html(); 77 | return read(options.html, 'utf8'); 78 | }).then(function(data) { 79 | $ = cheerio.load(data); 80 | return ejs.render(template, { 81 | apiToc: $('.toc-container').html(), 82 | readme: readme, 83 | apiDoc: $('.doc-container').html(), 84 | // correctly setting links to your github/pages 85 | page_url: options.site, 86 | title: options.title, 87 | github_url: options.github, 88 | // fixed reference to generated annotation 89 | // the 'literate' in .dokker.json shall not require a source since it's never used. 90 | annotated_path: 'annotated/'+options.source 91 | }); 92 | }).then(function(data) { 93 | return write(options.html, data, 'utf8'); 94 | }).then(function() { 95 | resolve(); 96 | }).then(null, function(err) { 97 | reject(err); 98 | }); 99 | }); 100 | }; 101 | 102 | /** 103 | * Creates an HTML file to describe the features of your module from your 104 | * **Mocha** tests. The module is using the mocha **doc** reporter to 105 | * generate the HTML contents. 106 | * 107 | * @static 108 | * @memberOf Dokker 109 | * @category Mocha 110 | * @type Function 111 | * @param {Object} [options] The options object. 112 | * @param {String} [options.path='docs.html'] The path where to save the 113 | * HTML file 114 | * @returns {Promise} Returns a resolved promise if file was created. 115 | * @example 116 | * 117 | * var options = { 118 | * path: 'docs/tests.html', 119 | * }; 120 | * Dokker.createTests(options) 121 | * .then(function(){ 122 | * // => resolved promise 123 | * }); 124 | */ 125 | // Create a HTML site from any mocha tests find when executing mocha 126 | // --reporter doc terminal command. 127 | Dokker.createTests = function(options) { 128 | return new Promise(function(resolve, reject) { 129 | var template, tests; 130 | // allows specification of mocha.command in .dokker.json, e.g. 'mocha -u tdd --reporter doc' 131 | var cmd = options.command || 'mocha --reporter doc'; 132 | exec(cmd, {cwd: process.cwd()}, function(error, stdout) { 133 | if(error) return reject(error); 134 | tests = stdout; 135 | return read(options.template, 'utf8') 136 | .then(function(data) { 137 | template = data; 138 | return ejs.render(template, {tests: tests}); 139 | }).then(function(data) { 140 | return write(options.path, data, 'utf8'); 141 | }).then(function() { 142 | resolve(); 143 | }).then(null, function(err) { 144 | reject(err); 145 | }); 146 | }); 147 | }); 148 | }; 149 | 150 | /** 151 | * Runs a terminal shell with the git command to extract the docs branch 152 | * into a seperate gh-pages branch and finally pushes that branch to Github, 153 | * so that the Github page is updated. 154 | * 155 | * @static 156 | * @memberOf Dokker 157 | * @category Github Pages 158 | * @type Function 159 | * @returns {Promise} Returns a resolved promise if file was created. 160 | * @example 161 | * 162 | * Dokker.ghPages() 163 | * .then(function(){ 164 | * // => resolved promise 165 | * }); 166 | */ 167 | // Extract docs folder to separate git branch and finally push branch to 168 | // Github repository 169 | Dokker.ghPages = function(){ 170 | return new Promise(function(resolve, reject) { 171 | exec('git subtree split -P docs -b gh-pages', function(error, stdout, stderr) { 172 | if(error) return reject(stderr); 173 | exec('git push origin gh-pages', function(error, stdout, stderr) { 174 | if(error) return reject(stderr); 175 | resolve(); 176 | }); 177 | }); 178 | }); 179 | }; 180 | 181 | /** 182 | * Create a styled HTML file from your source code with the help of **docco** 183 | * module. 184 | * 185 | * @static 186 | * @memberOf Dokker 187 | * @category Literate programming 188 | * @type Function 189 | * @param {Object} [options] The options object. 190 | * @param {String} [options.source='app.js'] The path the source code with 191 | * comments 192 | * @param {string} [options.dir='docs/annotated'] The directory where to save 193 | * the generated HTML file. 194 | * @returns {Promise} Returns a resolved promise if file was created. 195 | * @example 196 | * 197 | * var options = { 198 | * dir: 'docs', 199 | * source: 'app.js' 200 | * }; 201 | * Dokker.literate() 202 | * .then(function(){ 203 | * // => resolved promise 204 | * }); 205 | */ 206 | // Create an HTML file from any source code comments in the style of 207 | // [literate programming](https://de.wikipedia.org/wiki/Literate_programming) 208 | Dokker.literate = function (options) { 209 | return new Promise(function(resolve, reject) { 210 | var tmpDir = path.join(process.cwd(), '/.tmp'); 211 | var tmpFile = path.join(tmpDir, options.source); 212 | var sourceFile = (options.cwd) ? 213 | path.join(process.cwd(), options.cwd, options.source) : 214 | path.join(process.cwd(), options.source); 215 | return read(sourceFile, 'utf8') 216 | .then(function(data) { 217 | var source = data.replace(/^\s*(\*|\/\*).*[\r\n]/gm, ''); 218 | return Dokker.mkdir(tmpDir) 219 | .then(function() { 220 | return write(tmpFile, source, 'utf8'); 221 | }).then(function(){ 222 | docco.run(['', '', tmpFile, '-o', options.dir]); 223 | resolve(); 224 | }); 225 | }).then(null, function(err) { 226 | if (err) return reject(err); 227 | }); 228 | }); 229 | }; 230 | 231 | /** 232 | * Create a Markdown file from JSDoc tags. 233 | * 234 | * @static 235 | * @memberOf Dokker 236 | * @category JSDoc 237 | * @type Function 238 | * @param {Object} [options] The options object. 239 | * @param {String} [options.source='app.js'] The path the source code with 240 | * JSDoc tags. 241 | * @param {String} [options.github =''] The path the Github repository. 242 | * @param {string} [options.markdown='docs/READMDE.md'] The path where to 243 | * save the Markdown file. 244 | * @returns {Promise} Returns a resolved promise if file was created. 245 | * @example 246 | * 247 | * var options = { 248 | * source: 'app.js', 249 | * markdown: 'docs/README.md' 250 | * }; 251 | * Dokker.jsdocMarkdown() 252 | * .then(function(){ 253 | * // => resolved promise 254 | * }); 255 | */ 256 | // Convert markdown from any source code comments with docdown module. 257 | Dokker.jsdocMarkdown = function (options) { 258 | return new Promise(function(resolve, reject) { 259 | var source, tmpFile, tmpDir; 260 | var sourceFile = (options.cwd) ? 261 | path.join(process.cwd(), options.cwd, options.source) : 262 | path.join(process.cwd(), options.source); 263 | return read(sourceFile, 'utf8') 264 | .then(function(data){ 265 | source = data.replace(/^\s*(\/\/).*[\r\n]/gm, ''); 266 | tmpDir = path.join(process.cwd(), '/.tmp'); 267 | return Dokker.mkdir(tmpDir); 268 | }).then(function(){ 269 | tmpFile = path.join(tmpDir, options.source); 270 | return write(tmpFile, source, 'utf8'); 271 | }).then(function(){ 272 | var markdown = docdown({ 273 | 'path': tmpFile, 274 | 'url': options.github, 275 | 'toc': 'categories' 276 | }); 277 | return write(options.markdown, markdown, 'utf8'); 278 | }).then(function() { 279 | resolve(); 280 | }).then(null, function(err) { 281 | reject(err); 282 | }); 283 | }); 284 | }; 285 | 286 | /** 287 | * Create an HTML file from the Markdown file that was create with 288 | * [Dokker.jsdocMarkdown()](#Dokker-jsdocMarkdown) 289 | * 290 | * @static 291 | * @memberOf Dokker 292 | * @category JSDoc 293 | * @type Function 294 | * @param {Object} [options] The options object. 295 | * @param {string} [options.markdown='docs/READMDE.md'] The path where to 296 | * save the Markdown file. 297 | * @returns {Promise} Returns a resolved promise if file was created. 298 | * @example 299 | * 300 | * var options = { 301 | * markdown: 'docs/README.md' 302 | * }; 303 | * Dokker.jsdocHtml() 304 | * .then(function(){ 305 | * // => resolved promise 306 | * }); 307 | */ 308 | // Create an HTML file from any source code comments in the style of 309 | // [literate programming](https://de.wikipedia.org/wiki/Literate_programming) 310 | Dokker.jsdocHtml = function (options) { 311 | return new Promise(function(resolve, reject) { 312 | return read(options.markdown, 'utf8') 313 | .then(function(data) { 314 | var html = marked(data).replace(//g,'>'); 315 | return write(options.html, html, 'utf8'); 316 | }).then(function() { 317 | resolve(); 318 | }).then(null, function(err) { 319 | reject(err); 320 | }); 321 | }); 322 | }; 323 | 324 | // Internal helper function that creates any directory if not existing. 325 | Dokker.mkdir = function(dir) { 326 | return new Promise(function(resolve, reject) { 327 | fs.exists(dir, function(exists) { 328 | if (exists) { 329 | resolve(); 330 | } else { 331 | fs.mkdir(dir, function(err) { 332 | if (err) return reject(err); 333 | resolve(); 334 | }); 335 | } 336 | }); 337 | }); 338 | }; 339 | 340 | /** 341 | * Helper function that takes a couple of options arguments and 342 | * normalises them and subsequently returns them. 343 | * 344 | * @static 345 | * @memberOf Dokker 346 | * @category Utility 347 | * @type Function 348 | * @param {Object} [options] The options object. 349 | * @param {string} [options.li.markdown='docs/READMDE.md'] The path where to 350 | * @param {String} [options.source='app.js'] The path the source code with 351 | * JSDoc tags. 352 | * @param {string} [options.jsdoc.markdown='docs/READMDE.md'] The path where to 353 | * save the Markdown file. 354 | * @param {string} [options.jsdoc.README ='READMDE.md'] The path to the 355 | * project's README.md file 356 | * @param {String} [options.jsodc.template ='templates/index.ejs.html'] The 357 | * path to the ejs template. 358 | * @param {String} [options.mocha.template='templates/tests.ejs.html'] The 359 | * path to the mocha template. 360 | * @param {String} [options.dir='docs'] The path where to store the generated 361 | * files 362 | * @returns {Promise} Returns a resolved promise with edited options object 363 | * @example 364 | * 365 | * var options = { 366 | * dir: 'docs', 367 | * literate: { 368 | * source: 'dokker.js', 369 | * dir: 'annotated' 370 | * }, 371 | * jsdoc: { 372 | * title: 'Dokker.js', 373 | * source: 'dokker.js', 374 | * markdown: 'README.md', 375 | * html: 'index.html', 376 | * readme: 'README.md', 377 | * } 378 | * }; 379 | * Dokker.jsdocHtml() 380 | * .then(function(){ 381 | * // => object with absolute pathes to the directory from 382 | * // which the command was executed 383 | * }); 384 | */ 385 | // Parses the options file, .Dokker.json, and sets the default parameters. 386 | Dokker.configure = function(options) { 387 | return new Promise(function(resolve, reject){ 388 | var file = path.join(process.cwd(), '.dokker.json'); 389 | return read(file, 'utf8') 390 | .then(function(data) { 391 | data = JSON.parse(data); 392 | data.jsdoc.template = (data.jsdoc.template) ? path.join(process.cwd(), data.jsdoc.template) : path.join(__dirname, 'templates/index.ejs.html'); 393 | data.mocha.template = (data.mocha.template) ? path.join(process.cwd(), data.mocha.template) : path.join(__dirname, 'templates/tests.ejs.html'); 394 | data.mocha.path = path.join(process.cwd(), data.dir, data.mocha.path); 395 | // mocha.command commented out to fix build-breaking bug 396 | // specifies mocha command in .dokker.json; e.g. mocha -u tdd -R spec 397 | // data.mocha.command = path.join(process.cwd(), data.dir, data.mocha.command); 398 | data.literate.dir = path.join(process.cwd(), data.dir, data.literate.dir); 399 | data.jsdoc.markdown = path.join(process.cwd(), data.dir, data.jsdoc.markdown); 400 | data.jsdoc.html = path.join(process.cwd(), data.dir, data.jsdoc.html); 401 | data.jsdoc.readme = path.join(process.cwd(), data.jsdoc.readme); 402 | resolve(data); 403 | }).then(null, function(err) { 404 | reject(err); 405 | }); 406 | }); 407 | }; 408 | 409 | /** 410 | * Copy the template to local directory so that one can make changes to ejs 411 | * files. 412 | * 413 | * @static 414 | * @memberOf Dokker 415 | * @category Utility 416 | * @type Function 417 | * @param {Object} [options] The options object. 418 | * @param {string} [options.dir='templates'] The path where to save the 419 | * template files 420 | * @returns {Promise} Returns a resolved promise if files were created. 421 | * @example 422 | * 423 | * var options = { 424 | * dir: 'template' 425 | * }; 426 | * Dokker.copyTemplate() 427 | * .then(function(){ 428 | * // => resolved promise 429 | * }); 430 | */ 431 | // Copy starter template to bootstrap any Dokker project. 432 | Dokker.copyTemplate = function(options) { 433 | return new Promise(function(resolve, reject) { 434 | var templatesDir = path.join(process.cwd(), 'templates'); 435 | return Dokker.mkdir(templatesDir) 436 | .then(function() { 437 | var oldStyle = path.join(__dirname, 'templates', 'styles.css'); 438 | var newStyle = path.join(process.cwd(), options.dir, 'styles.css'); 439 | fs.createReadStream(oldStyle).pipe(fs.createWriteStream(newStyle)); 440 | var oldLogo = path.join(__dirname, 'templates', 'logo.png'); 441 | var newLogo = path.join(process.cwd(), options.dir, 'logo.png'); 442 | fs.createReadStream(oldLogo).pipe(fs.createWriteStream(newLogo)); 443 | var oldApp = path.join(__dirname, 'templates', 'app.js'); 444 | var newApp = path.join(process.cwd(), options.dir, 'app.js'); 445 | fs.createReadStream(oldApp).pipe(fs.createWriteStream(newApp)); 446 | resolve(); 447 | }); 448 | }); 449 | }; 450 | 451 | /** 452 | * Create a .dokker.json file to bootstrap any Dokker project 453 | * 454 | * @static 455 | * @memberOf Dokker 456 | * @category Utility 457 | * @type Function 458 | * @returns {Promise} Returns a resolved promise if files were created. 459 | * @example 460 | * 461 | * Dokker.init() 462 | * .then(function(){ 463 | * // => resolved promise 464 | * }); 465 | */ 466 | // Copies the .Dokker.json file to bootstrap any Dokker project. 467 | Dokker.init = function(){ 468 | return new Promise(function(resolve, reject) { 469 | var oldDok = path.join(__dirname, '.dokker.json'); 470 | var newDok = path.join(process.cwd(), '.dokker.json'); 471 | fs.createReadStream(oldDok).pipe(fs.createWriteStream(newDok)); 472 | resolve(); 473 | }); 474 | }; 475 | 476 | /** 477 | * Starts a Node.js/Express webserver in docs directory to watch 478 | * the build Dokker project 479 | * 480 | * @static 481 | * @memberOf Dokker 482 | * @category Utility 483 | * @type Function 484 | * @returns {Promise} Returns a resolved promise if files were created. 485 | * @example 486 | * 487 | * Dokker.init() 488 | * .then(function(){ 489 | * // => resolved promise 490 | * }); 491 | */ 492 | // Starts the Node.js/Express server to watch Dokker.js project 493 | // documentation. 494 | Dokker.watch = function(options) { 495 | var gulpex = require(__dirname + '/gulpfile.js').gulpex; 496 | return gulpex(); 497 | // return new Promise(function(resolve, reject){ 498 | // exec('DIR='+ options.dir + ' node ' + options.dir + '/app.js', function(error, stdout, stderr){ 499 | // if(error) return reject(stderr); 500 | // }); 501 | // }); 502 | }; 503 | 504 | module.exports = Dokker; 505 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | // dependencies 2 | var browserSync = require('browser-sync').create(); 3 | var cp = require('child_process'); 4 | var gulp = require('gulp'); 5 | var path = require('path'); 6 | var q = require('q'); 7 | 8 | // working path 9 | var wpath = path.join(process.cwd()); 10 | 11 | // gulp entry point 12 | gulp.task('default', ['start']); 13 | gulp.task('start', ['build', 'reload', 'watch']); 14 | 15 | // watch for file changes in wpath 16 | gulp.task('watch', ['reload'], function() { 17 | gulp.watch(wpath + '/*.js', ['build', 'reload']) 18 | }) 19 | 20 | // gulp.task('build', exec.bind('some build command here')) 21 | gulp.task('build', exec.bind((wpath+'/node_modules/dokker/bin/dokker').replace(/\s/, '\\ '))) 22 | // Reloading browserSync 23 | gulp.task('reload', ['build'], reload); 24 | 25 | // reload browserSync 26 | function reload() { 27 | var defer = q.defer(); 28 | 29 | if (browserSync.active) { 30 | browserSync.reload(); 31 | defer.resolve(); 32 | } else 33 | startServer().then(defer.resolve); 34 | 35 | return defer.promise; 36 | } 37 | 38 | // start a browserSync server to index.html directly 39 | function startServer() { 40 | var defer = q.defer(); 41 | 42 | var serverConfig = { 43 | server: { 44 | baseDir: wpath, 45 | directory: true 46 | }, 47 | startPath: 'docs/index.html', 48 | // browser: "google chrome", 49 | logPrefix: 'SERVER' 50 | }; 51 | browserSync.init(serverConfig, defer.resolve); 52 | 53 | return defer.promise; 54 | } 55 | 56 | // terminal exec task with promise: use as exec.bind() 57 | function exec() { 58 | var defer = q.defer(); 59 | cp.exec(this, function(err, stdout, stderr) { 60 | if (err) console.log('exec err: '+ err); 61 | console.log(stdout); 62 | defer.resolve(err) 63 | }) 64 | return defer.promise; 65 | } 66 | 67 | // // export for normal render run 68 | function gulpex(options){ 69 | // set process.env.DIR then run task 70 | // return exec.bind('DIR='+ options.dir)() 71 | // .done(gulp.start('default')) 72 | return gulp.start('default') 73 | } 74 | exports.gulpex = gulpex; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dokker", 3 | "version": "0.1.3", 4 | "description": "Dokker.js creates professional Javascript code documentations.", 5 | "preferGlobal": true, 6 | "bin": { 7 | "dokker": "./bin/dokker", 8 | "gh-pages": "./bin/gh-pages", 9 | "dokker-init": "./bin/dokker-init", 10 | "dokker-watch": "./bin/dokker-watch" 11 | }, 12 | "main": "dokker.js", 13 | "scripts": { 14 | "test": "mocha" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/oceanhouse21/dokker.git" 19 | }, 20 | "keywords": [ 21 | "documentation", 22 | "JSDOC", 23 | "docca", 24 | "Javascript" 25 | ], 26 | "author": "Georg Schlenkhoff", 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/oceanhouse21/dokker/issues" 30 | }, 31 | "homepage": "https://dokkerjs.com", 32 | "dependencies": { 33 | "browser-sync": "^2.7.12", 34 | "cheerio": "^0.19.0", 35 | "docco": "^0.7.0", 36 | "docdown": "^0.2.0", 37 | "ejs": "^2.3.1", 38 | "gulp": "^3.9.0", 39 | "lodash": "^3.9.3", 40 | "marked": "^0.3.3", 41 | "nodemon": "^1.3.7", 42 | "promise": "^7.0.3", 43 | "q": "^1.4.1" 44 | }, 45 | "devDependencies": { 46 | "express": "^4.13.0", 47 | "mocha": "^2.2.5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /templates/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var path = require('path'); 4 | var livereload = require('livereload'); 5 | var path = path.join(process.cwd(), process.env.DIR); 6 | livereload.createServer({exts: ['applyJSLive']}).watch(path); 7 | app.use(express.static(path)); 8 | app.listen(9000); 9 | -------------------------------------------------------------------------------- /templates/index.ejs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= title %> 9 | 10 | 11 | 12 | 13 | 14 |
15 |

><%= title %>

16 | 22 | <%- apiToc %> 23 |
24 |
25 |
26 | <%- readme %> 27 |

API documentation

28 | <%- apiDoc %> 29 |
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /templates/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kengz/dokker/34e15326023bf6f27fe87135e02c1d4b2b080780/templates/logo.png -------------------------------------------------------------------------------- /templates/styles.css: -------------------------------------------------------------------------------- 1 | body, 2 | h1, 3 | h2, 4 | html, 5 | p { 6 | margin: 0; 7 | padding: 0 8 | } 9 | html { 10 | background: #d3d3d3; 11 | height: 100%; 12 | color: #222; 13 | font-size: 100% 14 | } 15 | body { 16 | background: #fff; 17 | width: 60em; 18 | margin: 0 auto; 19 | -webkit-box-shadow: 0 0 2.5em #5d656c; 20 | -moz-box-shadow: 0 0 2.5em #5d656c; 21 | box-shadow: 0 0 2.5em #5d656c; 22 | font: 1em/1.7'Helvetica Neue', Helvetica, Arial, sans-serif; 23 | min-height: 100% 24 | } 25 | code { 26 | /*font-family: 'Roboto', 'Helvetica Neue', sans-serif;*/ 27 | font-family: 'Source Code Pro', Consolas, 'Courier New', monospace; 28 | letter-spacing: 0.03em; 29 | } 30 | .lang-js { 31 | color: #78dbf9; 32 | } 33 | span.hljs-number { 34 | color: #d59cf6; 35 | } 36 | span.hljs-string{ 37 | color: #8bdb97; 38 | } 39 | span.hljs-regexp{ 40 | color: #dbad83; 41 | } 42 | span.hljs-literal{ 43 | color: #e26a78; 44 | } 45 | span.hljs-keyword{ 46 | color: #d59cf6; 47 | } 48 | span.hljs-comment { 49 | color: #99a4c7; 50 | } 51 | span.hljs-special { 52 | color: #bdc4df; 53 | } 54 | pre { 55 | box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255); 56 | box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392); 57 | box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529); 58 | border-bottom-left-radius: 5px; 59 | border-bottom-right-radius: 5px; 60 | background: #2b303b; 61 | margin: 1em 0; 62 | padding: .5em 20px; 63 | overflow-x: scroll; 64 | -webkit-overflow-scrolling: touch 65 | } 66 | pre.intro { 67 | font-size: 1.2em 68 | } 69 | pre::-webkit-scrollbar { 70 | height: 8px 71 | } 72 | pre::-webkit-scrollbar-thumb { 73 | background: rgba(255, 255, 255, .8); 74 | -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .5); 75 | -webkit-border-radius: 10px; 76 | border-radius: 10px 77 | } 78 | pre::-webkit-scrollbar-thumb:window-inactive { 79 | background: rgba(255, 255, 255, .4) 80 | } 81 | h1 span, 82 | pre { 83 | color: #ddd 84 | } 85 | h1, 86 | h2, 87 | h3, 88 | h4, 89 | ol, 90 | p, 91 | ul { 92 | font-weight: 400; 93 | padding: 0 20px; 94 | word-wrap: break-word 95 | } 96 | hgroup h1 { 97 | display: inline 98 | } 99 | hgroup h2 { 100 | font-size: 1.38em 101 | } 102 | h2, 103 | h3, 104 | h4 { 105 | margin: 0 0 .5em 106 | } 107 | h4 { 108 | font-weight: 700 109 | } 110 | a { 111 | color: #222; 112 | border-bottom: 1px solid #ddd; 113 | text-decoration: none 114 | } 115 | a:focus, 116 | a:hover { 117 | border-color: #222 118 | } 119 | a img { 120 | border: 0 121 | } 122 | abbr[title] { 123 | border-bottom: 1px dotted #ddd; 124 | cursor: help 125 | } 126 | hr { 127 | display: none 128 | } 129 | p { 130 | margin-bottom: 1em 131 | } 132 | ol, 133 | ul { 134 | margin-left: 2em 135 | } 136 | ol ol, 137 | ul ul { 138 | margin-left: 1em; 139 | padding: 0 140 | } 141 | footer { 142 | display: block; 143 | background: #eee; 144 | padding: 1em 0; 145 | text-align: center 146 | } 147 | .a-img { 148 | border: 0 149 | } 150 | .a-img img { 151 | padding: .5em 0 0 152 | } 153 | .description { 154 | word-wrap: break-word 155 | } 156 | .multiline-items li { 157 | padding-bottom: 1em 158 | } 159 | .multiline-items li.last-item { 160 | padding-bottom: 0 161 | } 162 | .br0 { 163 | color: #090 164 | } 165 | .co1 { 166 | color: #060 167 | } 168 | .co2 { 169 | color: #096 170 | } 171 | .kw1, 172 | .kw3 { 173 | color: #006 174 | } 175 | .kw2 { 176 | color: #036 177 | } 178 | .me1 { 179 | color: #606 180 | } 181 | .nu0 { 182 | color: #c00 183 | } 184 | .st0 { 185 | color: #36c 186 | } 187 | .sy0 { 188 | color: #393; 189 | font-weight: 700 190 | } 191 | pre .co1 { 192 | color: #aeaeae 193 | } 194 | .es0, 195 | pre .st0 { 196 | color: #61ce3c 197 | } 198 | pre .co2 { 199 | color: #fff 200 | } 201 | pre .kw2, 202 | pre .kw3, 203 | pre .nu0 { 204 | color: #fbde2d 205 | } 206 | pre .me1 { 207 | color: #8da6ce 208 | } 209 | pre .br0, 210 | pre .kw1, 211 | pre .sy0 { 212 | color: #ddd 213 | } 214 | #docs { 215 | background: #fff 216 | } 217 | #docs body { 218 | font-size: .85em; 219 | width: 100% 220 | } 221 | #docs a.alias { 222 | opacity: .5 223 | } 224 | #docs div div div div { 225 | box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.137255); 226 | box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.0980392); 227 | box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.0823529); 228 | border-bottom-left-radius: 5px; 229 | border-bottom-right-radius: 5px; 230 | } 231 | #docs div div div { 232 | border-top: 0; 233 | margin: 0 .5em 1em 234 | } 235 | #docs h1, 236 | #docs h2, 237 | #docs h3, 238 | #docs h4, 239 | #docs ol, 240 | #docs p, 241 | #docs ul { 242 | padding: 0 10px 243 | } 244 | #docs pre { 245 | margin: 0; 246 | padding: .5em 10px 247 | } 248 | #docs ul li { 249 | list-style-type: none; 250 | margin: 0 0 0 -.9em 251 | } 252 | #docs h1 { 253 | padding: 0 10px 254 | } 255 | #docs h2 { 256 | margin: .5em 0 0 257 | } 258 | #docs h3 { 259 | background: rgb(63, 107, 196); 260 | border-radius: 3px 3px 0 0; 261 | border: 1px solid rgba(75, 71, 71, 0.14); 262 | margin: .5em 0; 263 | padding: .8em 0 .8em 10px; 264 | position: relative 265 | } 266 | #docs h3>code { 267 | color: #fbfbfb 268 | } 269 | #docs h3 a { 270 | position: absolute; 271 | top: 0 272 | } 273 | #docs h3 .br0 { 274 | color: #fc83ff 275 | } 276 | #docs h3 .kw2 { 277 | color: #71d0c9 278 | } 279 | #docs h3 .me1 { 280 | color: #fff 281 | } 282 | #docs h3 .nu0 { 283 | color: #d0cb71 284 | } 285 | #docs h3 .sy0 { 286 | color: #df74e2; 287 | font-weight: 700 288 | } 289 | #docs footer { 290 | height: 3em; 291 | margin-top: 1.5em; 292 | width: 100% 293 | } 294 | #social { 295 | height: 20px 296 | } 297 | #social .twitter-follow-button { 298 | width: 127px!important 299 | } 300 | #social .twitter-follow-button, 301 | .twitter-share-button { 302 | font-size: .8em; 303 | vertical-align: top 304 | } 305 | @media (max-width: 959px) { 306 | body { 307 | border: 0; 308 | margin: 0; 309 | -moz-box-shadow: none; 310 | -webkit-box-shadow: none; 311 | box-shadow: none; 312 | width: auto 313 | } 314 | h1, 315 | h2, 316 | h3, 317 | h4, 318 | ol, 319 | p, 320 | ul { 321 | padding: 0 10px 322 | } 323 | pre { 324 | padding: 5px 10px!important 325 | } 326 | #social { 327 | height: auto 328 | } 329 | .toc-container a { 330 | display: block; 331 | padding: 5px 332 | } 333 | .toc-container a:focus, 334 | .toc-container a:hover { 335 | background-color: #EEE 336 | } 337 | .toc-container a:active { 338 | background-color: #CCC 339 | } 340 | } 341 | @media (min-width: 960px) { 342 | #docs body { 343 | box-shadow: none; 344 | height: 100%; 345 | margin: 0 346 | } 347 | #docs a[href="#docs"], 348 | #docs footer { 349 | display: none 350 | } 351 | #docs h1 { 352 | position: fixed; 353 | background-color: #fff; 354 | top: 0; 355 | left: 0; 356 | right: 0; 357 | z-index: 1 358 | } 359 | #docs h3 a { 360 | display: block; 361 | position: relative; 362 | visibility: hidden; 363 | top: -4em 364 | } 365 | #docs .toc-container { 366 | background: #fff; 367 | bottom: 0; 368 | left: 0; 369 | overflow-y: scroll; 370 | overflow-x: hidden; 371 | position: fixed; 372 | top: 1.5em; 373 | white-space: nowrap; 374 | width: 20%; 375 | -webkit-overflow-scrolling: touch 376 | } 377 | #docs .toc-container h2, 378 | #docs .toc-container ul { 379 | margin-top: 0; 380 | padding: 0 10px 381 | } 382 | #docs .doc-container { 383 | background: #fff; 384 | width: 80%; 385 | margin-left: 20%; 386 | padding-top: 1.5em 387 | } 388 | #docs .doc-container .first-heading { 389 | margin-top: 0 390 | } 391 | } 392 | @media (-ms-high-contrast: active) and (max-width: 1280px), 393 | (-ms-high-contrast: none) and (max-width: 1280px) { 394 | #docs .doc-container, 395 | #docs .toc-container { 396 | position: relative; 397 | top: auto; 398 | width: 100% 399 | } 400 | #docs .doc-container .first-heading { 401 | margin-top: .5em 402 | } 403 | #docs a[href="#docs"] { 404 | display: inline 405 | } 406 | #docs footer { 407 | display: block 408 | } 409 | } 410 | @media (orientation: portrait) and (min-device-width: 720px) and (max-device-width: 768px), 411 | (orientation: landscape) and (device-width: 1280px) and (max-device-height: 768px) { 412 | @-ms-viewport{width:80%}} 413 | -------------------------------------------------------------------------------- /templates/tests.ejs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dokker.js 7 | 8 | 19 | 38 | 39 | 40 | <%- tests %> 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/dokker.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var fs = require('fs'); 4 | var path = require('path'); 5 | var Dokker = require('../dokker'); 6 | var Promise = require('promise'); 7 | var read = Promise.denodeify(fs.readFile); 8 | var assert = require('assert'); 9 | var options; 10 | 11 | describe('Dokker', function(){ 12 | 13 | before(function(done){ 14 | Dokker.configure() 15 | .then(function(data){ 16 | options = data; 17 | done(); 18 | }); 19 | }); 20 | 21 | describe('.literate()', function(){ 22 | it('creates a HTML file from annotated source code', function(done){ 23 | return Dokker.literate(options.literate) 24 | .then(function(){ 25 | done(); 26 | }).done(); 27 | }); 28 | }); 29 | 30 | describe('.jsdocMarkdown()', function() { 31 | it('creates a markdown file from JSDOC comments', function(done){ 32 | return Dokker.jsdocMarkdown(options.jsdoc) 33 | .then(function(){ 34 | return read(options.jsdoc.markdown); 35 | }).then(function(){ 36 | done(); 37 | }).done(); 38 | }); 39 | }); 40 | 41 | describe('.jsdocHtml()', function() { 42 | it('creates a HTML file from JSDOC commments', function(done){ 43 | return Dokker.jsdocHtml(options.jsdoc) 44 | .then(function(){ 45 | return read(options.jsdoc.html); 46 | }).then(function(){ 47 | done(); 48 | }).done(); 49 | }); 50 | }); 51 | 52 | describe('.injectTemplate()', function(){ 53 | it('injects index.html file in ejs template', function(done){ 54 | return Dokker.injectTemplate(options.jsdoc) 55 | .then(function() { 56 | return read(options.jsdoc.html, 'utf8'); 57 | }).then(function(data){ 58 | assert(//.test(data)); 59 | done(); 60 | }).done(); 61 | }); 62 | }); 63 | 64 | describe('.copyTemplate()', function() { 65 | it('copies styles and app.js from template folder', function(done){ 66 | return Dokker.copyTemplate(options) 67 | .then(function(){ 68 | return read(path.join(__dirname, '..', options.dir, 'styles.css')); 69 | }).then(function(data){ 70 | assert(data); 71 | done(); 72 | }).done(); 73 | }); 74 | }); 75 | 76 | }); 77 | --------------------------------------------------------------------------------