Skip to content

Commit 0db2297

Browse files
committed
Merge branch 'feature/dash-export'
2 parents dfa7391 + e2e8796 commit 0db2297

File tree

7 files changed

+303
-14
lines changed

7 files changed

+303
-14
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#doxdox
44

5-
> HTML and Markdown documentation generator.
5+
> HTML, Markdown and Dash documentation generator.
66
7-
A documentation generator that takes output from [dox](https://github.com/visionmedia/dox/) and builds a [Bootstrap](http://getbootstrap.com/) or [Markdown](http://daringfireball.net/projects/markdown/) based documentation file.
7+
A documentation generator that takes output from [dox](https://github.com/tj/dox/) and builds either a [Bootstrap](http://getbootstrap.com/), [Markdown](http://daringfireball.net/projects/markdown/) or [Dash](http://kapeli.com/dash) based documentation file.
88

99
##Installation
1010

@@ -29,10 +29,17 @@ $ npm install doxdox -g
2929
3030
Available Layouts:
3131
32-
- Bootstrap (default) (http://getbootstrap.com/)
33-
- Markdown (http://daringfireball.net/projects/markdown/)
32+
- Bootstrap (default) (http://getbootstrap.com/)
33+
- Markdown (http://daringfireball.net/projects/markdown/)
34+
- Dash (http://kapeli.com/docsets/)
3435
```
3536

37+
##Exporting
38+
39+
###Dash
40+
41+
Exporting to Dash generates a zip file and is only available through the `--output` flag.
42+
3643
##Examples:
3744

3845
- [Facade.js](http://facadejs.com/) - [Documentation](http://docs.facadejs.com/)

lib/doxdox.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var fs = require('fs'),
77

88
var templates = {
99
bootstrap: require('../templates/bootstrap.hbs'),
10-
markdown: require('../templates/markdown.hbs')
10+
markdown: require('../templates/markdown.hbs'),
11+
dash: utils.buildDashDocSet
1112
};
1213

1314
exports.parseInput = function (input, output, config) {
@@ -86,7 +87,8 @@ exports.parseScripts = function (scripts, output, config) {
8687
content = template({
8788
title: config.title,
8889
description: config.description,
89-
files: files
90+
files: files,
91+
output: output
9092
});
9193

9294
if (output) {

lib/utils.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,78 @@
11
var fs = require('fs'),
2-
path = require('path');
2+
path = require('path'),
3+
hbs = require('handlebars'),
4+
helpers = require('../lib/helpers')(hbs),
5+
admzip = require('adm-zip'),
6+
temp = require('temp').track(),
7+
sqlite3 = require('sqlite3').verbose();
8+
9+
module.exports.buildDashDocSet = function (input) {
10+
11+
var zip = new admzip(),
12+
tempdb = temp.openSync('temp.sqlite'),
13+
db = new sqlite3.Database(tempdb.path);
14+
15+
input.uid = module.exports.formatStringForUID(input.title);
16+
17+
zip.addFile(
18+
input.title + '.docset/Contents/Resources/Documents/index.html',
19+
require('../templates/dash/index.hbs')(input)
20+
);
21+
22+
zip.addFile(
23+
input.title + '.docset/Contents/Info.plist',
24+
require('../templates/dash/plist.hbs')(input)
25+
);
26+
27+
db.serialize(function() {
28+
29+
db.run('CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);');
30+
db.run('CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);');
31+
32+
input.files.forEach(function (file) {
33+
34+
file.methods.forEach(function (method) {
35+
36+
if (!method.ignore && method.ctx) {
37+
38+
db.run('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ($name, $type, $path);', {
39+
$name: hbs.helpers.formatName(method.ctx.string),
40+
$type: method.ctx.type.replace(/^[a-z]/, function (match) { return match.toUpperCase(); }),
41+
$path: 'index.html#' + method.ctx.uid
42+
});
43+
44+
}
45+
46+
});
47+
48+
});
49+
50+
});
51+
52+
db.close(function () {
53+
54+
zip.addFile(
55+
input.title + '.docset/Contents/Resources/docSet.dsidx',
56+
fs.readFileSync(tempdb.path)
57+
);
58+
59+
if (input.output) {
60+
61+
fs.writeFileSync(input.output, zip.toBuffer(), 'utf8');
62+
63+
}
64+
65+
});
66+
67+
if (!input.output) {
68+
69+
console.error('Not avalible through stdout. Please use the --output flag instead.');
70+
71+
}
72+
73+
return false;
74+
75+
};
376

477
module.exports.findPackage = function (input) {
578

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
{
22
"name": "doxdox",
3-
"description": "HTML and Markdown documentation generator.",
3+
"description": "HTML, Markdown and Dash documentation generator.",
44
"version": "0.0.13",
55
"bin": "./bin/doxdox",
66
"license": "MIT",
77
"dependencies": {
88
"chalk": "0.5.1",
9-
"dox": "0.5.3",
9+
"dox": "0.6.1",
1010
"handlebars": "2.0.0",
11-
"highlight.js": "8.3.0"
11+
"highlight.js": "8.4.0",
12+
"sqlite3": "3.0.4",
13+
"adm-zip": "0.4.4",
14+
"temp": "0.8.1"
1215
},
1316
"keywords": [
1417
"documentation",
1518
"html",
1619
"bootstrap",
17-
"markdown"
20+
"markdown",
21+
"dash"
1822
],
1923
"authors": [
2024
{

templates/bootstrap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
var protocol = w.location.protocol === 'file:' ? 'http:' : w.location.protocol,
99
resource = [
10-
'//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css',
11-
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css',
10+
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css',
11+
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css',
1212
'//code.jquery.com/jquery-2.1.1.js',
13-
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js'
13+
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js'
1414
];
1515

1616
function loadResource(url) {

templates/dash/index.hbs

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="initial-scale=1">
6+
<title>{{title}}</title>
7+
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
8+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
9+
<style>
10+
11+
.wrap {
12+
padding: 0 2em 2em 2em;
13+
}
14+
15+
.method h2 {
16+
line-height: 1.3em;
17+
text-overflow: ellipsis;
18+
overflow: hidden;
19+
}
20+
21+
.bs-footer {
22+
margin: 50px auto;
23+
color: #777;
24+
text-align: center;
25+
}
26+
27+
pre .hljs {
28+
padding: 0;
29+
background: none;
30+
}
31+
32+
</style>
33+
</head>
34+
35+
<body>
36+
37+
<div class="wrap">
38+
39+
<h1>{{title}}{{#if description}} <small>{{description}}</small>{{/if}}</h1>
40+
41+
{{#each files}}
42+
43+
{{#each methods}}
44+
45+
{{#unless ignore}}
46+
47+
{{#if ctx}}
48+
49+
<div class="method scope-{{#if isPrivate}}private{{else}}public{{/if}}">
50+
51+
{{registerContext this}}
52+
53+
<h2 id="{{ctx.uid}}">
54+
{{formatName ctx.string}}
55+
{{#if isPrivate}}
56+
<small>private method</small>
57+
{{/if}}
58+
</h2>
59+
60+
{{{description.summary}}}
61+
62+
{{#each tags}}{{#ifCond type "param"}}
63+
{{registerVariable "displayParameters" true}}
64+
{{/ifCond}}{{/each}}
65+
66+
{{#if displayParameters}}
67+
68+
<section class="parameters">
69+
70+
<h3>Parameters</h3>
71+
72+
{{#each tags}}
73+
74+
{{#ifCond type "param"}}
75+
76+
<p>
77+
<b>{{name}}</b>
78+
{{#each types}}
79+
<code>{{.}}</code>
80+
{{/each}}
81+
{{#if optional}}
82+
<span class="label label-default">Optional</span>
83+
{{/if}}
84+
</p>
85+
<p>{{{description}}}</p>
86+
87+
{{/ifCond}}
88+
89+
{{/each}}
90+
91+
</section>
92+
93+
{{/if}}
94+
95+
{{#each tags}}{{#ifCond type "property"}}
96+
{{registerVariable "displayProperties" true}}
97+
{{/ifCond}}{{/each}}
98+
99+
{{#if displayProperties}}
100+
101+
<section class="properties">
102+
103+
<h3>Properties</h3>
104+
105+
{{#each tags}}
106+
107+
{{#ifCond type "property"}}
108+
109+
<p>
110+
<b>{{name}}</b>
111+
{{#each types}}
112+
<code>{{.}}</code>
113+
{{/each}}
114+
{{#if optional}}
115+
<span class="label label-default">Optional</span>
116+
{{/if}}
117+
</p>
118+
<p>{{{description}}}</p>
119+
120+
{{/ifCond}}
121+
122+
{{/each}}
123+
124+
</section>
125+
126+
{{/if}}
127+
128+
<section class="examples">
129+
130+
<h3>Examples</h3>
131+
132+
{{{description.body}}}
133+
134+
{{#each tags}}
135+
136+
{{#ifCond type "example"}}
137+
138+
<pre><code class="hljs">{{{highlightBlock string}}}</code></pre>
139+
140+
{{/ifCond}}
141+
142+
{{/each}}
143+
144+
</section>
145+
146+
<section class="code">
147+
148+
<h3>Code</h3>
149+
150+
<pre><code class="hljs">{{{highlightBlock code}}}</code></pre>
151+
152+
</section>
153+
154+
<h3>Returns</h3>
155+
156+
{{#each tags}}
157+
158+
{{#ifCondMatch type "return"}}
159+
160+
<p>{{#each types}}<code>{{.}}</code> {{/each}} {{{description}}}</p>
161+
162+
{{/ifCondMatch}}
163+
164+
{{/each}}
165+
166+
</div>
167+
168+
{{/if}}
169+
170+
{{/unless}}
171+
172+
{{/each}}
173+
174+
{{/each}}
175+
176+
</div>
177+
178+
<footer class="bs-footer">
179+
180+
<div class="container">
181+
182+
<p>Documentation generated with <a href="https://github.com/neogeek/doxdox">doxdox</a>.</p>
183+
184+
</div>
185+
186+
</footer>
187+
188+
</body>
189+
</html>

templates/dash/plist.hbs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>{{uid}}</string>
7+
<key>CFBundleName</key>
8+
<string>{{title}}</string>
9+
<key>isDashDocset</key>
10+
<true/>
11+
<key>dashIndexFilePath</key>
12+
<string>index.html</string>
13+
</dict>
14+
</plist>

0 commit comments

Comments
 (0)