Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit db748b3

Browse files
committed
Initial commit.
0 parents  commit db748b3

File tree

15 files changed

+669
-0
lines changed

15 files changed

+669
-0
lines changed

.bithoundrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"ignore": [
3+
"**/test/**"
4+
],
5+
"test": [
6+
"**/test/**"
7+
]
8+
}

.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": [
3+
"@neogeek/eslint-config-standards"
4+
],
5+
"rules": {
6+
"no-shadow": 0,
7+
"sort-keys": 0
8+
}
9+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Scott Doxey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
BIN=node_modules/.bin
2+
3+
test:
4+
make lint
5+
$(BIN)/mocha test/specs/**.js
6+
7+
lint:
8+
$(BIN)/eslint index.js
9+
$(BIN)/eslint test/specs/
10+
11+
.PHONY: test

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# doxdox-parser-dox
2+
3+
> Dox parser plugin for doxdox.
4+
5+
[![NPM Version](http://img.shields.io/npm/v/doxdox-parser-dox.svg?style=flat)](https://www.npmjs.org/package/doxdox-parser-dox)
6+
![](https://img.shields.io/badge/requires%20doxdox-v1.0.0-orange.svg)
7+
8+
## Install
9+
10+
```bash
11+
$ npm install doxdox doxdox-parser-dox --save-dev
12+
```

index.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const dox = require('dox');
2+
3+
const formatStringForName = content =>
4+
content.toString()
5+
.replace(/\.prototype|\(\)/g, '');
6+
7+
const formatStringForUID = content =>
8+
content.toString()
9+
.toLowerCase()
10+
.replace(/[^\w\.]+/g, '-')
11+
.replace(/^-|-$/g, '');
12+
13+
const parser = (content, filename) => dox.parseComments(content, {'raw': true}).reduce((prev, curr) => {
14+
15+
if (!curr.ignore && curr.ctx) {
16+
17+
prev.push({
18+
'uid': formatStringForUID(`${filename}-${curr.ctx.string}`),
19+
'isPrivate': curr.isPrivate,
20+
'type': curr.ctx.type,
21+
'name': formatStringForName(curr.ctx.string),
22+
'description': curr.description.full,
23+
'params': curr.tags.filter(tag => tag.type === 'param' && !tag.name.match(/\./))
24+
.reduce((prev, curr) => {
25+
26+
if (prev) {
27+
28+
return `${prev}, ${curr.name.replace(/\[|\]/g, '')}`;
29+
30+
}
31+
32+
return `${curr.name.replace(/\[|\]/g, '')}`;
33+
34+
}, ''),
35+
'tags': {
36+
'example': curr.tags.filter(tag => tag.type === 'example')
37+
.reduce((prev, curr) => {
38+
39+
prev.push(curr.string);
40+
41+
return prev;
42+
43+
}, []),
44+
'param': curr.tags.filter(tag => tag.type === 'param')
45+
.reduce((prev, curr) => {
46+
47+
prev.push({
48+
'name': curr.name.replace(/\[|\]/g, ''),
49+
'isOptional': curr.optional,
50+
'types': curr.types,
51+
'description': curr.description
52+
});
53+
54+
return prev;
55+
56+
}, []),
57+
'property': curr.tags.filter(tag => tag.type === 'property')
58+
.reduce((prev, curr) => {
59+
60+
prev.push({
61+
'name': curr.name,
62+
'types': curr.types,
63+
'description': curr.description
64+
});
65+
66+
return prev;
67+
68+
}, []),
69+
'return': curr.tags.filter(tag => tag.type === 'return' || tag.type === 'returns')
70+
.reduce((prev, curr) => {
71+
72+
prev.push({
73+
'types': curr.types,
74+
'description': curr.description
75+
});
76+
77+
return prev;
78+
79+
}, [])
80+
}
81+
});
82+
83+
}
84+
85+
return prev;
86+
87+
}, []);
88+
89+
module.exports = parser;

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "doxdox-parser-dox",
3+
"description": "Dox parser plugin for doxdox.",
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"dependencies": {
8+
"dox": "0.9.0"
9+
},
10+
"devDependencies": {
11+
"@neogeek/eslint-config-standards": "1.6.3",
12+
"eslint": "3.8.0",
13+
"mocha": "3.1.2"
14+
},
15+
"scripts": {
16+
"test": "make test"
17+
},
18+
"keywords": [
19+
"doxdox",
20+
"parser",
21+
"dox"
22+
],
23+
"authors": [
24+
{
25+
"name": "Scott Doxey",
26+
"email": "[email protected]",
27+
"homepage": "http://scottdoxey.com/"
28+
}
29+
],
30+
"homepage": "https://github.com/neogeek/doxdox-parser-dox",
31+
"repository": {
32+
"type": "git",
33+
"url": "git://github.com/neogeek/doxdox-parser-dox.git"
34+
}
35+
}

test/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fixtures/

test/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@neogeek/eslint-config-standards/.eslintrc-tests"
4+
]
5+
}

0 commit comments

Comments
 (0)