Skip to content

Commit fae27b9

Browse files
committed
Merge branch 'edge'
2 parents 204ffba + c0d2741 commit fae27b9

File tree

7 files changed

+156
-82
lines changed

7 files changed

+156
-82
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#Changelog
22

3+
##0.0.2 (August 7, 2014)
4+
5+
- Added output flag.
6+
- Added syntax highlighting to Bootstrap layout.
7+
38
##0.0.1 (August 3, 2014)
49

510
- Initial public release.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![](https://david-dm.org/neogeek/doxdox.svg)](https://david-dm.org/neogeek/doxdox/)
1+
[![](https://david-dm.org/neogeek/doxdox.svg)](https://david-dm.org/neogeek/doxdox/) [![](http://img.shields.io/npm/v/doxdox.svg)](https://www.npmjs.org/package/doxdox)
22

33
#doxdox
44

@@ -24,6 +24,7 @@ $ npm install doxdox -g
2424
-t, --title Sets title.
2525
-d, --description Sets description.
2626
-l, --layout Template to render the documentation with.
27+
-o, --output File to save documentation to. Default to stdout.
2728

2829
Available Layouts:
2930

bin/doxdox

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var pkg = require('../package'),
44
fs = require('fs'),
5+
chalk = require('chalk'),
56
dox = require('dox'),
67
hbs = require('handlebars'),
78
helpers = require('../lib/helpers')(hbs),
@@ -15,14 +16,15 @@ var templates = {
1516
var title = 'Untitled Project',
1617
description = '',
1718
layout = 'bootstrap',
18-
filename = '';
19+
script = '',
20+
output = '';
1921

2022
var args = process.argv.slice(2),
2123
value;
2224

2325
if (args.length && !args[0].match(/^\-/)) {
2426

25-
filename = args.shift();
27+
script = args.shift();
2628

2729
}
2830

@@ -47,6 +49,11 @@ while (args.length) {
4749
layout = args.shift();
4850
break;
4951

52+
case '-o':
53+
case '--output':
54+
output = args.shift();
55+
break;
56+
5057
case '-v':
5158
case '--version':
5259
process.stdout.write(pkg.version + '\n');
@@ -55,17 +62,19 @@ while (args.length) {
5562

5663
default:
5764
process.stdout.write('\n');
58-
process.stdout.write(' Usage: doxdox <file> [options]' + '\n\n');
65+
process.stdout.write(chalk.blue(' Usage:') + ' doxdox <file> [options]' + '\n\n');
5966
process.stdout.write(' Options:' + '\n\n');
60-
process.stdout.write(' -h, --help\t\tDisplay this help message.' + '\n');
61-
process.stdout.write(' -v, --version\t\tDisplay the current installed version.' + '\n');
62-
process.stdout.write(' -t, --title\t\tSets title.' + '\n');
63-
process.stdout.write(' -d, --description\tSets description.' + '\n');
64-
process.stdout.write(' -l, --layout\t\tTemplate to render the documentation with.' + '\n');
67+
process.stdout.write(chalk.yellow(' -h, --help') + '\t\tDisplay this help message.' + '\n');
68+
process.stdout.write(chalk.yellow(' -v, --version') + '\t\tDisplay the current installed version.' + '\n');
69+
process.stdout.write(chalk.yellow(' -t, --title') + '\t\tSets title.' + '\n');
70+
process.stdout.write(chalk.yellow(' -d, --description') + '\tSets description.' + '\n');
71+
process.stdout.write(chalk.yellow(' -l, --layout') + '\t\tTemplate to render the documentation with.' + '\n');
72+
process.stdout.write(chalk.yellow(' -l, --layout') + '\t\tTemplate to render the documentation with.' + '\n');
73+
process.stdout.write(chalk.yellow(' -o, --output') + '\t\tFile to save documentation to. Default to stdout.' + '\n');
6574
process.stdout.write('\n');
6675
process.stdout.write(' Available Layouts:' + '\n\n');
67-
process.stdout.write(' - Bootstrap (default)\t\t(http://getbootstrap.com/)' + '\n');
68-
process.stdout.write(' - Markdown\t\t\t(http://daringfireball.net/projects/markdown/)' + '\n');
76+
process.stdout.write(' - Bootstrap (default)\t (http://getbootstrap.com/)' + '\n');
77+
process.stdout.write(' - Markdown\t\t (http://daringfireball.net/projects/markdown/)' + '\n');
6978
process.stdout.write('\n');
7079
process.kill();
7180
break;
@@ -74,21 +83,32 @@ while (args.length) {
7483

7584
}
7685

77-
fs.exists(filename, function (exists) {
86+
fs.exists(script, function (exists) {
7887

79-
var data;
88+
var content,
89+
data;
8090

8191
if (exists) {
8292

83-
data = dox.parseComments(fs.readFileSync(filename, 'utf8'));
93+
data = dox.parseComments(fs.readFileSync(script, 'utf8'));
8494

8595
if (templates[layout]) {
8696

87-
process.stdout.write(templates[layout]({
97+
content = templates[layout]({
8898
title: title,
8999
description: description,
90100
methods: utils.parseData(data)
91-
}));
101+
});
102+
103+
if (output) {
104+
105+
fs.writeFileSync(output, content, 'utf8');
106+
107+
} else {
108+
109+
process.stdout.write(content);
110+
111+
}
92112

93113
} else {
94114

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "doxdox",
33
"description": "HTML and Markdown documentation generator.",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"bin": "./bin/doxdox",
66
"license": "MIT",
77
"dependencies": {
8+
"chalk": "0.5.1",
89
"dox": "0.4.6",
910
"handlebars": "1.3.0"
1011
},

templates/bootstrap.hbs

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,14 @@
2929
text-align: center;
3030
}
3131
32+
pre .hljs {
33+
padding: 0;
34+
background: none;
35+
}
36+
3237
</style>
3338
<script>
34-
35-
(function () {
36-
37-
'use strict';
38-
39-
var css = document.createElement('link'),
40-
protocol = window.location.protocol;
41-
42-
if (protocol === 'file:') {
43-
protocol = 'http:';
44-
}
45-
46-
css.setAttribute('rel', 'stylesheet');
47-
css.setAttribute('href', protocol + '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css');
48-
49-
document.head.appendChild(css);
50-
51-
}());
52-
39+
(function(e,t,i){"use strict";var s=e.location.protocol==="file:"?"http:":e.location.protocol,c=["//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css","//cdn.jsdelivr.net/highlight.js/8.0/styles/github.css","//cdn.jsdelivr.net/highlight.js/8.0/highlight.min.js","//cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js"];c.forEach(function(e){var o;if(e.match(/\.js$/)){o=t.createElement("script");o.setAttribute("src",s+e)}else if(e.match(/\.css$/)){o=t.createElement("link");o.setAttribute("rel","stylesheet");o.setAttribute("href",s+e)}o.addEventListener("load",function(){if(this.hasAttribute("src")){c.splice(c.indexOf(this.getAttribute("src")),1)}else if(this.hasAttribute("href")){c.splice(c.indexOf(this.getAttribute("href")),1)}if(!c.length){if($.isReady){i()}else{$(document).ready(i)}}});t.head.appendChild(o)})})(window,document,function(){var e=window.location.hash,t=$('[id="'+e.replace(/#/,"")+'"]'),i=$(".code"),s=$(".scope-private"),c=$(".toggle-code-blocks");$toggle_private=$(".toggle-private");c.on("click",function(){if(c.is(":checked")){i.show()}else{i.hide()}});$toggle_private.on("click",function(){if($toggle_private.is(":checked")){s.show()}else{s.hide()}});i.hide();s.hide();if(t.length&&!t.is(":visible")){$toggle_private.trigger("click")}$(".examples pre code, .code pre code").each(function(){hljs.highlightBlock(this)})});
5340
</script>
5441
</head>
5542

@@ -207,7 +194,7 @@
207194

208195
<h3>Code</h3>
209196

210-
<pre>{{code}}</pre>
197+
<pre><code>{{code}}</code></pre>
211198

212199
</section>
213200

@@ -249,50 +236,5 @@
249236

250237
</footer>
251238

252-
<script src="http://cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js"></script>
253-
<script>
254-
255-
(function () {
256-
257-
var hash = window.location.hash,
258-
$hash_elem = $('[id="' + hash.replace(/#/, '') + '"]'),
259-
$code_block = $('.code'),
260-
$scope_private = $('.scope-private'),
261-
$toggle_code_blocks = $('.toggle-code-blocks')
262-
$toggle_private = $('.toggle-private');
263-
264-
$toggle_code_blocks.on('click', function () {
265-
266-
if ($toggle_code_blocks.is(':checked')) {
267-
$code_block.show();
268-
} else {
269-
$code_block.hide();
270-
}
271-
272-
});
273-
274-
$toggle_private.on('click', function () {
275-
276-
if ($toggle_private.is(':checked')) {
277-
$scope_private.show();
278-
} else {
279-
$scope_private.hide();
280-
}
281-
282-
});
283-
284-
$code_block.hide();
285-
$scope_private.hide();
286-
287-
if ($hash_elem.length && !$hash_elem.is(':visible')) {
288-
289-
$toggle_private.trigger('click');
290-
291-
}
292-
293-
}());
294-
295-
</script>
296-
297239
</body>
298240
</html>

templates/bootstrap.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
(function (w, d, f) {
2+
3+
'use strict';
4+
5+
var protocol = w.location.protocol === 'file:' ? 'http:' : w.location.protocol,
6+
resource = [
7+
'//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css',
8+
'//cdn.jsdelivr.net/highlight.js/8.0/styles/github.css',
9+
'//cdn.jsdelivr.net/highlight.js/8.0/highlight.min.js',
10+
'//cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js'
11+
];
12+
13+
resource.forEach(function (url) {
14+
15+
var tag;
16+
17+
if (url.match(/\.js$/)) {
18+
19+
tag = d.createElement('script');
20+
tag.setAttribute('src', protocol + url);
21+
22+
} else if (url.match(/\.css$/)) {
23+
24+
tag = d.createElement('link');
25+
tag.setAttribute('rel', 'stylesheet');
26+
tag.setAttribute('href', protocol + url);
27+
28+
}
29+
30+
tag.addEventListener('load', function () {
31+
32+
if (this.hasAttribute('src')) {
33+
34+
resource.splice(resource.indexOf(this.getAttribute('src')), 1);
35+
36+
} else if (this.hasAttribute('href')) {
37+
38+
resource.splice(resource.indexOf(this.getAttribute('href')), 1);
39+
40+
}
41+
42+
if (!resource.length) {
43+
44+
if ($.isReady) {
45+
46+
f();
47+
48+
} else {
49+
50+
$(document).ready(f);
51+
52+
}
53+
54+
}
55+
56+
});
57+
58+
d.head.appendChild(tag);
59+
60+
});
61+
62+
}(window, document, function () {
63+
64+
var hash = window.location.hash,
65+
$hash_elem = $('[id="' + hash.replace(/#/, '') + '"]'),
66+
$code_block = $('.code'),
67+
$scope_private = $('.scope-private'),
68+
$toggle_code_blocks = $('.toggle-code-blocks')
69+
$toggle_private = $('.toggle-private');
70+
71+
$toggle_code_blocks.on('click', function () {
72+
73+
if ($toggle_code_blocks.is(':checked')) {
74+
$code_block.show();
75+
} else {
76+
$code_block.hide();
77+
}
78+
79+
});
80+
81+
$toggle_private.on('click', function () {
82+
83+
if ($toggle_private.is(':checked')) {
84+
$scope_private.show();
85+
} else {
86+
$scope_private.hide();
87+
}
88+
89+
});
90+
91+
$code_block.hide();
92+
$scope_private.hide();
93+
94+
if ($hash_elem.length && !$hash_elem.is(':visible')) {
95+
96+
$toggle_private.trigger('click');
97+
98+
}
99+
100+
$('.examples pre code, .code pre code').each(function() {
101+
hljs.highlightBlock(this);
102+
});
103+
104+
}));

templates/bootstrap.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)