spacedocs 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +29 -0
- data/dox/History.md +57 -0
- data/dox/Makefile +24 -0
- data/dox/Readme.md +332 -0
- data/dox/bin/dox +47 -0
- data/dox/index.js +2 -0
- data/dox/lib/dox.js +286 -0
- data/dox/lib/utils.js +15 -0
- data/dox/package.json +16 -0
- data/dox/test/dox.test.js +287 -0
- data/dox/test/fixtures/a.js +12 -0
- data/dox/test/fixtures/b.js +26 -0
- data/dox/test/fixtures/c.js +266 -0
- data/dox/test/fixtures/d.js +15 -0
- data/dox/test/fixtures/titles.js +14 -0
- data/lib/assets/stylesheets/spacedocs/docs.css.sass +155 -0
- data/lib/spacedocs/engine.rb +6 -0
- data/lib/spacedocs/version.rb +3 -0
- data/lib/spacedocs.rb +215 -0
- data/source/class.html.haml +98 -0
- data/source/index.html.haml +16 -0
- metadata +73 -0
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Spacedocs
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'spacedocs'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install spacedocs
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/dox/History.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
0.3.1 / 2012-04-25
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Fixed annoying title bug
|
6
|
+
|
7
|
+
0.3.0 / 2012-03-27
|
8
|
+
==================
|
9
|
+
|
10
|
+
* Added __@memberOf__ [olivernn]
|
11
|
+
* Added __@arguments__ [olivernn]
|
12
|
+
* Added __@borrows__ [olivernn]
|
13
|
+
|
14
|
+
0.2.0 / 2012-02-23
|
15
|
+
==================
|
16
|
+
|
17
|
+
* Added `-r, --raw` support. Closes #48
|
18
|
+
|
19
|
+
0.1.3 / 2011-12-08
|
20
|
+
==================
|
21
|
+
|
22
|
+
* Added: allow arbitrary tags [logicalparadox]
|
23
|
+
* Fixed function whitespace [TooTallNate]
|
24
|
+
|
25
|
+
0.1.2 / 2011-10-22
|
26
|
+
==================
|
27
|
+
|
28
|
+
* remove html escaping for now
|
29
|
+
|
30
|
+
0.1.1 / 2011-10-10
|
31
|
+
==================
|
32
|
+
|
33
|
+
* Fixed: colons in comment lines not intended as headers [Evan Owen]
|
34
|
+
|
35
|
+
0.0.5 / 2011-03-02
|
36
|
+
==================
|
37
|
+
|
38
|
+
* Adding "main" to package descriptor since "directories" are no longer supported.
|
39
|
+
|
40
|
+
0.0.4 / 2011-01-20
|
41
|
+
==================
|
42
|
+
|
43
|
+
* Added `--intro` support for including an intro file written in markdown [Alex Young]
|
44
|
+
|
45
|
+
0.0.3 / 2010-07-15
|
46
|
+
==================
|
47
|
+
|
48
|
+
* Linked h2s
|
49
|
+
|
50
|
+
0.0.2 / 2010-07-15
|
51
|
+
==================
|
52
|
+
|
53
|
+
* Collapsing files, click to open. Closes #19
|
54
|
+
* Fixed ribbon position instead of absolute
|
55
|
+
* Removed menu
|
56
|
+
* Removed node-discount dependency, using markdown-js
|
57
|
+
|
data/dox/Makefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
TESTS = test/*.test.js
|
3
|
+
REPORTER = dot
|
4
|
+
|
5
|
+
test:
|
6
|
+
@NODE_ENV=test ./node_modules/.bin/mocha \
|
7
|
+
--ui exports \
|
8
|
+
--reporter $(REPORTER) \
|
9
|
+
$(TESTS)
|
10
|
+
|
11
|
+
docs:
|
12
|
+
@./bin/dox \
|
13
|
+
--verbose \
|
14
|
+
lib/* \
|
15
|
+
--out docs \
|
16
|
+
--title Dox \
|
17
|
+
--github visionmedia/dox \
|
18
|
+
--index index.md
|
19
|
+
|
20
|
+
doc-server:
|
21
|
+
@./bin/dox \
|
22
|
+
--server docs
|
23
|
+
|
24
|
+
.PHONY: test docs
|
data/dox/Readme.md
ADDED
@@ -0,0 +1,332 @@
|
|
1
|
+
# Dox
|
2
|
+
|
3
|
+
Dox is a JavaScript documentation generator written with [node](http://nodejs.org). Dox no longer generates an opinionated structure or style for your docs, it simply gives you a JSON representation, allowing you to use _markdown_ and _JSDoc_-style tags.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install from npm:
|
8
|
+
|
9
|
+
$ npm install -g dox
|
10
|
+
|
11
|
+
## Usage Examples
|
12
|
+
|
13
|
+
`dox(1)` operates over stdio:
|
14
|
+
|
15
|
+
$ dox < utils.js
|
16
|
+
...JSON...
|
17
|
+
|
18
|
+
to inspect the generated data you can use the `--debug` flag, which is easier to read than the JSON output:
|
19
|
+
|
20
|
+
$ dox --debug < utils.js
|
21
|
+
|
22
|
+
utils.js:
|
23
|
+
|
24
|
+
```js
|
25
|
+
/**
|
26
|
+
* Escape the given `html`.
|
27
|
+
*
|
28
|
+
* Examples:
|
29
|
+
*
|
30
|
+
* utils.escape('<script></script>')
|
31
|
+
* // => '<script></script>'
|
32
|
+
*
|
33
|
+
* @param {String} html string to be escaped
|
34
|
+
* @return {String} escaped html
|
35
|
+
* @api public
|
36
|
+
*/
|
37
|
+
|
38
|
+
exports.escape = function(html){
|
39
|
+
return String(html)
|
40
|
+
.replace(/&(?!\w+;)/g, '&')
|
41
|
+
.replace(/</g, '<')
|
42
|
+
.replace(/>/g, '>');
|
43
|
+
};
|
44
|
+
```
|
45
|
+
|
46
|
+
output:
|
47
|
+
|
48
|
+
```json
|
49
|
+
[
|
50
|
+
{
|
51
|
+
"tags": [
|
52
|
+
{
|
53
|
+
"type": "param",
|
54
|
+
"types": [
|
55
|
+
"String"
|
56
|
+
],
|
57
|
+
"name": "html",
|
58
|
+
"description": "string to be escaped"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"type": "return",
|
62
|
+
"types": [
|
63
|
+
"String"
|
64
|
+
],
|
65
|
+
"description": "escaped html"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"type": "api",
|
69
|
+
"visibility": "public"
|
70
|
+
}
|
71
|
+
],
|
72
|
+
"description": {
|
73
|
+
"full": "<p>Escape the given <code>html</code>.</p>\n\n<h2>Examples</h2>\n\n<pre><code>utils.escape('&lt;script&gt;&lt;/script&gt;')\n// =&gt; '&lt;script&gt;&lt;/script&gt;'\n</code></pre>",
|
74
|
+
"summary": "<p>Escape the given <code>html</code>.</p>",
|
75
|
+
"body": "<h2>Examples</h2>\n\n<pre><code>utils.escape('&lt;script&gt;&lt;/script&gt;')\n// =&gt; '&lt;script&gt;&lt;/script&gt;'\n</code></pre>"
|
76
|
+
},
|
77
|
+
"isPrivate": false,
|
78
|
+
"ignore": false,
|
79
|
+
"code": "exports.escape = function(html){\n return String(html)\n .replace(/&(?!\\w+;)/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n};",
|
80
|
+
"ctx": {
|
81
|
+
"type": "method",
|
82
|
+
"receiver": "exports",
|
83
|
+
"name": "escape",
|
84
|
+
"string": "exports.escape()"
|
85
|
+
}
|
86
|
+
}
|
87
|
+
]
|
88
|
+
```
|
89
|
+
|
90
|
+
This output can then be passed to a template for rendering. Look below at the "Properties" section for details.
|
91
|
+
|
92
|
+
## Usage
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
Usage: dox [options]
|
97
|
+
|
98
|
+
Options:
|
99
|
+
|
100
|
+
-h, --help output usage information
|
101
|
+
-v, --version output the version number
|
102
|
+
-d, --debug output parsed comments for debugging
|
103
|
+
|
104
|
+
Examples:
|
105
|
+
|
106
|
+
# stdin
|
107
|
+
$ dox > myfile.json
|
108
|
+
|
109
|
+
# operates over stdio
|
110
|
+
$ dox < myfile.js > myfile.json
|
111
|
+
|
112
|
+
```
|
113
|
+
|
114
|
+
## Properties
|
115
|
+
|
116
|
+
A "comment" is comprised of the following detailed properties:
|
117
|
+
|
118
|
+
- tags
|
119
|
+
- description
|
120
|
+
- isPrivate
|
121
|
+
- ignore
|
122
|
+
- code
|
123
|
+
- ctx
|
124
|
+
|
125
|
+
### Description
|
126
|
+
|
127
|
+
A dox description is comprised of three parts, the "full" description,
|
128
|
+
the "summary", and the "body". The following example has only a "summary",
|
129
|
+
as it consists of a single paragraph only, therefore the "full" property has
|
130
|
+
only this value as well.
|
131
|
+
|
132
|
+
```js
|
133
|
+
/**
|
134
|
+
* Output the given `str` to _stdout_.
|
135
|
+
*/
|
136
|
+
|
137
|
+
exports.write = function(str) {
|
138
|
+
process.stdout.write(str);
|
139
|
+
};
|
140
|
+
````
|
141
|
+
yields:
|
142
|
+
|
143
|
+
```js
|
144
|
+
description:
|
145
|
+
{ full: '<p>Output the given <code>str</code> to <em>stdout</em>.</p>',
|
146
|
+
summary: '<p>Output the given <code>str</code> to <em>stdout</em>.</p>',
|
147
|
+
body: '' },
|
148
|
+
```
|
149
|
+
|
150
|
+
Large descriptions might look something like the following, where the "summary" is still the first paragraph, the remaining description becomes the "body". Keep in mind this _is_ markdown, so you can indent code, use lists, links, etc. Dox also augments markdown, allowing "Some Title:\n" to form a header.
|
151
|
+
|
152
|
+
```js
|
153
|
+
/**
|
154
|
+
* Output the given `str` to _stdout_
|
155
|
+
* or the stream specified by `options`.
|
156
|
+
*
|
157
|
+
* Options:
|
158
|
+
*
|
159
|
+
* - `stream` defaulting to _stdout_
|
160
|
+
*
|
161
|
+
* Examples:
|
162
|
+
*
|
163
|
+
* mymodule.write('foo')
|
164
|
+
* mymodule.write('foo', { stream: process.stderr })
|
165
|
+
*
|
166
|
+
*/
|
167
|
+
|
168
|
+
exports.write = function(str, options) {
|
169
|
+
options = options || {};
|
170
|
+
(options.stream || process.stdout).write(str);
|
171
|
+
};
|
172
|
+
```
|
173
|
+
|
174
|
+
yields:
|
175
|
+
|
176
|
+
```js
|
177
|
+
description:
|
178
|
+
{ full: '<p>Output the given <code>str</code> to <em>stdout</em><br />or the stream specified by <code>options</code>.</p>\n\n<h2>Options</h2>\n\n<ul>\n<li><code>stream</code> defaulting to <em>stdout</em></li>\n</ul>\n\n<h2>Examples</h2>\n\n<pre><code>mymodule.write(\'foo\')\nmymodule.write(\'foo\', { stream: process.stderr })\n</code></pre>',
|
179
|
+
summary: '<p>Output the given <code>str</code> to <em>stdout</em><br />or the stream specified by <code>options</code>.</p>',
|
180
|
+
body: '<h2>Options</h2>\n\n<ul>\n<li><code>stream</code> defaulting to <em>stdout</em></li>\n</ul>\n\n<h2>Examples</h2>\n\n<pre><code>mymodule.write(\'foo\')\nmymodule.write(\'foo\', { stream: process.stderr })\n</code></pre>' }
|
181
|
+
```
|
182
|
+
|
183
|
+
### Tags
|
184
|
+
|
185
|
+
Dox also supports JSdoc-style tags. Currently only __@api__ is special-cased, providing the `comment.isPrivate` boolean so you may omit "private" utilities etc.
|
186
|
+
|
187
|
+
```js
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Output the given `str` to _stdout_
|
191
|
+
* or the stream specified by `options`.
|
192
|
+
*
|
193
|
+
* @param {String} str
|
194
|
+
* @param {Object} options
|
195
|
+
* @return {Object} exports for chaining
|
196
|
+
*/
|
197
|
+
|
198
|
+
exports.write = function(str, options) {
|
199
|
+
options = options || {};
|
200
|
+
(options.stream || process.stdout).write(str);
|
201
|
+
return this;
|
202
|
+
};
|
203
|
+
```
|
204
|
+
|
205
|
+
yields:
|
206
|
+
|
207
|
+
```js
|
208
|
+
tags:
|
209
|
+
[ { type: 'param',
|
210
|
+
types: [ 'String' ],
|
211
|
+
name: 'str',
|
212
|
+
description: '' },
|
213
|
+
{ type: 'param',
|
214
|
+
types: [ 'Object' ],
|
215
|
+
name: 'options',
|
216
|
+
description: '' },
|
217
|
+
{ type: 'return',
|
218
|
+
types: [ 'Object' ],
|
219
|
+
description: 'exports for chaining' },
|
220
|
+
{ type: 'api',
|
221
|
+
visibility: 'public' } ]
|
222
|
+
```
|
223
|
+
|
224
|
+
### Code
|
225
|
+
|
226
|
+
The `.code` property is the code following the comment block, in our previous examples:
|
227
|
+
|
228
|
+
```js
|
229
|
+
exports.write = function(str, options) {
|
230
|
+
options = options || {};
|
231
|
+
(options.stream || process.stdout).write(str);
|
232
|
+
return this;
|
233
|
+
};
|
234
|
+
```
|
235
|
+
|
236
|
+
### Ctx
|
237
|
+
|
238
|
+
The `.ctx` object indicates the context of the code block, is it a method, a function, a variable etc. Below are some examples:
|
239
|
+
|
240
|
+
```js
|
241
|
+
exports.write = function(str, options) {
|
242
|
+
};
|
243
|
+
```
|
244
|
+
|
245
|
+
yields:
|
246
|
+
|
247
|
+
```js
|
248
|
+
ctx:
|
249
|
+
{ type: 'method',
|
250
|
+
receiver: 'exports',
|
251
|
+
name: 'write',
|
252
|
+
string: 'exports.write()' } }
|
253
|
+
```
|
254
|
+
|
255
|
+
```js
|
256
|
+
var foo = 'bar';
|
257
|
+
```
|
258
|
+
|
259
|
+
yields:
|
260
|
+
|
261
|
+
```js
|
262
|
+
ctx:
|
263
|
+
{ type: 'declaration',
|
264
|
+
name: 'foo',
|
265
|
+
value: '\'bar\'',
|
266
|
+
string: 'foo' }
|
267
|
+
```
|
268
|
+
|
269
|
+
```js
|
270
|
+
function User() {
|
271
|
+
|
272
|
+
}
|
273
|
+
```
|
274
|
+
|
275
|
+
yields:
|
276
|
+
|
277
|
+
```js
|
278
|
+
ctx:
|
279
|
+
{ type: 'function',
|
280
|
+
name: 'User',
|
281
|
+
string: 'User()' } }
|
282
|
+
```
|
283
|
+
|
284
|
+
### Ignore
|
285
|
+
|
286
|
+
Comments and their associated bodies of code may be flagged with "!" to be considered worth ignoring, these are typically things like file comments containing copyright etc, however you of course can output them in your templates if you want.
|
287
|
+
|
288
|
+
```
|
289
|
+
/**
|
290
|
+
* Not ignored.
|
291
|
+
*/
|
292
|
+
```
|
293
|
+
|
294
|
+
vs
|
295
|
+
|
296
|
+
```
|
297
|
+
/*!
|
298
|
+
* Ignored.
|
299
|
+
*/
|
300
|
+
```
|
301
|
+
|
302
|
+
### Running tests
|
303
|
+
|
304
|
+
Install dev dependencies and execute `make test`:
|
305
|
+
|
306
|
+
$ npm install -d
|
307
|
+
$ make test
|
308
|
+
|
309
|
+
## License
|
310
|
+
|
311
|
+
(The MIT License)
|
312
|
+
|
313
|
+
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
314
|
+
|
315
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
316
|
+
a copy of this software and associated documentation files (the
|
317
|
+
'Software'), to deal in the Software without restriction, including
|
318
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
319
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
320
|
+
permit persons to whom the Software is furnished to do so, subject to
|
321
|
+
the following conditions:
|
322
|
+
|
323
|
+
The above copyright notice and this permission notice shall be
|
324
|
+
included in all copies or substantial portions of the Software.
|
325
|
+
|
326
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
327
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
328
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
329
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
330
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
331
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
332
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/dox/bin/dox
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Module dependencies.
|
5
|
+
*/
|
6
|
+
|
7
|
+
var program = require('commander')
|
8
|
+
, util = require('util')
|
9
|
+
, dox = require('../');
|
10
|
+
|
11
|
+
// options
|
12
|
+
|
13
|
+
program
|
14
|
+
.version(dox.version)
|
15
|
+
.option('-r, --raw', 'output "raw" comments, leaving the markdown intact')
|
16
|
+
.option('-d, --debug', 'output parsed comments for debugging');
|
17
|
+
|
18
|
+
// examples
|
19
|
+
|
20
|
+
program.on('--help', function(){
|
21
|
+
console.log(' Examples:');
|
22
|
+
console.log('');
|
23
|
+
console.log(' # stdin');
|
24
|
+
console.log(' $ dox > myfile.json');
|
25
|
+
console.log('');
|
26
|
+
console.log(' # operates over stdio');
|
27
|
+
console.log(' $ dox < myfile.js > myfile.json');
|
28
|
+
console.log('');
|
29
|
+
});
|
30
|
+
|
31
|
+
// parse argv
|
32
|
+
|
33
|
+
program.parse(process.argv);
|
34
|
+
|
35
|
+
// process stdin
|
36
|
+
|
37
|
+
var buf = '';
|
38
|
+
process.stdin.setEncoding('utf8');
|
39
|
+
process.stdin.on('data', function(chunk){ buf += chunk; });
|
40
|
+
process.stdin.on('end', function(){
|
41
|
+
var obj = dox.parseComments(buf, { raw: program.raw });
|
42
|
+
if (program.debug) {
|
43
|
+
process.stdout.write(util.inspect(obj, false, Infinity, true) + '\n');
|
44
|
+
} else {
|
45
|
+
process.stdout.write(JSON.stringify(obj, null, 2));
|
46
|
+
}
|
47
|
+
}).resume();
|
data/dox/index.js
ADDED