Skip to content

Commit 0bf30ef

Browse files
author
Asghar
committed
initialize
0 parents  commit 0bf30ef

File tree

8 files changed

+458
-0
lines changed

8 files changed

+458
-0
lines changed

.eslintrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "standard",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"mocha": true
7+
},
8+
"rules": {
9+
"camelcase": "off"
10+
}
11+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const commentParser = require('comment-parser');
2+
3+
const parseFile = file => new Promise((resolve,reject)=>{
4+
commentParser.file(file, (err,result)=>err ? reject(err) : resolve(result));
5+
})
6+
7+
parseFile('./sample.js').then(c=> {
8+
let all = Object.values(c).reduce((result,item)=>{
9+
if (!item.tags.some(i=>i.tag==='socket.io-doc')) return result;
10+
let category = item.tags.find(i=>i.tag==='tag');
11+
category=category ? category.name : 'uncategorized';
12+
13+
let transformed = item.tags.reduce((r,t)=>{
14+
(t.tag === 'listen' || t.tag ==='emit') && (r={...r,action:t.tag, event: t.name});
15+
t.tag==='example' && (r={...r, example: t.name.replace(/\n|\r/g, "")+t.description.replace(/\n|\r/g, "")});
16+
return r;
17+
},{
18+
category,
19+
description:item.description || null
20+
});
21+
result.push(transformed);
22+
return result;
23+
},[]);
24+
25+
console.log(all);
26+
}).catch(e=>console.error(e));
27+

package-lock.json

+205
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "socketio-doc",
3+
"version": "1.0.0",
4+
"description": "Socket.io inline document generator.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/cybercoder/socketio-doc.git"
12+
},
13+
"keywords": [
14+
"socket.io",
15+
"doc",
16+
"comment"
17+
],
18+
"author": "cybercoder",
19+
"license": "MIT",
20+
"bugs": {
21+
"url": "https://github.com/cybercoder/socketio-doc/issues"
22+
},
23+
"homepage": "https://github.com/cybercoder/socketio-doc#readme",
24+
"dependencies": {
25+
"comment-parser": "^0.7.6",
26+
"showdown": "^1.9.1"
27+
}
28+
}

sample.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @api asghar.com
3+
*/
4+
5+
/**
6+
* Singleline or multiline description text. Line breaks are preserved111.
7+
* @socket.io-doc
8+
* @emit send send a message
9+
* @tag Messaging
10+
* @data {object}
11+
* @example
12+
* {
13+
* "id": 1,
14+
* "title": 5
15+
* }
16+
*/
17+
18+
19+
/**
20+
* Singleline or multiline description text. Line breaks are preserved.
21+
* @socket.io-doc
22+
* @listen onReceive receive
23+
* @tag Messaging
24+
* @data {object}
25+
* @example 5
26+
*/
27+
28+
console.log()

templates/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)