Skip to content

Commit 3baedf7

Browse files
committed
Add multiple input locations.
1 parent 07ebfda commit 3baedf7

14 files changed

+533
-3
lines changed

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/multi_input_folder/fixtures

bin/apidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var argv = nomnom
2323
.option('exclude-filters', { abbr: 'e', 'default': '', list: true,
2424
help: 'RegEx-Filter to select files / dirs that should not be parsed (many -e can be used).', })
2525

26-
.option('input', { abbr: 'i', 'default': './', help: 'Input / source dirname.' })
26+
.option('input', { abbr: 'i', 'default': './', list: true, help: 'Input / source dirname.' })
2727

2828
.option('output', { abbr: 'o', 'default': './doc/', help: 'Output dirname.' })
2929

lib/package_info.js

+27-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ PackageInfo.prototype.get = function() {
6060
*/
6161
PackageInfo.prototype._readPackageData = function(filename) {
6262
var result = {};
63-
var jsonFilename = path.join(app.options.src, filename);
63+
//var jsonFilename = path.join(app.options.src, filename);
64+
var dir = this._resolveSrcPath();
65+
var jsonFilename = path.join(dir, filename);
6466

6567
// read from source dir
6668
if ( ! fs.existsSync(jsonFilename)) {
@@ -88,10 +90,14 @@ PackageInfo.prototype._readPackageData = function(filename) {
8890
*/
8991
PackageInfo.prototype._getHeaderFooter = function(json) {
9092
var result = {};
93+
var self = this;
9194

9295
['header', 'footer'].forEach(function(key) {
9396
if (json[key] && json[key].filename) {
94-
var filename = path.join(app.options.src, json[key].filename);
97+
// var filename = path.join(app.options.src, json[key].filename);
98+
var dir = self._resolveSrcPath();
99+
var filename = path.join(dir, json[key].filename);
100+
95101
if ( ! fs.existsSync(filename))
96102
filename = path.join('./', json[key].filename);
97103

@@ -110,3 +116,22 @@ PackageInfo.prototype._getHeaderFooter = function(json) {
110116

111117
return result;
112118
};
119+
120+
/**
121+
* Resolve source path.
122+
*
123+
* If multiple input dirs are given, the current workdir './' will be returned.
124+
* On one input dir, the current workdir will be the input dir.
125+
*
126+
* @returns {string}
127+
* @private
128+
*/
129+
PackageInfo.prototype._resolveSrcPath = function() {
130+
var dir = './';
131+
132+
if (app.options.src instanceof Array && app.options.src.length === 1)
133+
dir = app.options.src[0];
134+
135+
return dir;
136+
};
137+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
define({ "api": [
2+
{
3+
"type": "post",
4+
"url": "/api/authenticate",
5+
"title": "",
6+
"version": "0.3.0",
7+
"group": "Authentication",
8+
"name": "Authenticate",
9+
"parameter": {
10+
"fields": {
11+
"Credentials": [
12+
{
13+
"group": "Credentials",
14+
"type": "<p>String</p> ",
15+
"optional": false,
16+
"field": "username",
17+
"description": "<p>Username</p> "
18+
},
19+
{
20+
"group": "Credentials",
21+
"type": "<p>String</p> ",
22+
"optional": false,
23+
"field": "password",
24+
"description": "<p>password</p> "
25+
}
26+
]
27+
}
28+
},
29+
"filename": "src/test_api.js",
30+
"groupTitle": "Authentication",
31+
"error": {
32+
"fields": {
33+
"500 Internal Server Error": [
34+
{
35+
"group": "500 Internal Server Error",
36+
"optional": false,
37+
"field": "InternalServerError",
38+
"description": "<p>The server encountered an internal error</p> "
39+
}
40+
]
41+
},
42+
"examples": [
43+
{
44+
"title": "500 Internal Server Error",
45+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
46+
"type": "json"
47+
}
48+
]
49+
}
50+
},
51+
{
52+
"type": "get",
53+
"url": "/api/subscriptioninfo",
54+
"title": "",
55+
"version": "0.3.0",
56+
"description": "<p>Get the subscription information from an authenticated user.</p> ",
57+
"group": "Authentication",
58+
"name": "GetSubscriptionInfo",
59+
"filename": "src/test_api.js",
60+
"groupTitle": "Authentication",
61+
"header": {
62+
"fields": {
63+
"Header": [
64+
{
65+
"group": "Header",
66+
"type": "String",
67+
"optional": false,
68+
"field": "Authorization",
69+
"description": "<p>Auth header with JWT Token</p> "
70+
}
71+
]
72+
},
73+
"examples": [
74+
{
75+
"title": "Authorization-Example:",
76+
"content": "Authorization: Bearer <jwt-token>",
77+
"type": "String"
78+
}
79+
]
80+
},
81+
"error": {
82+
"fields": {
83+
"500 Internal Server Error": [
84+
{
85+
"group": "500 Internal Server Error",
86+
"optional": false,
87+
"field": "InternalServerError",
88+
"description": "<p>The server encountered an internal error</p> "
89+
}
90+
]
91+
},
92+
"examples": [
93+
{
94+
"title": "500 Internal Server Error",
95+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
96+
"type": "json"
97+
}
98+
]
99+
}
100+
},
101+
{
102+
"type": "get",
103+
"url": "/api/subscriptioninfo/:userid",
104+
"title": "",
105+
"version": "0.2.0",
106+
"description": "<p>Get the subscription information for a user.</p> ",
107+
"parameter": {
108+
"fields": {
109+
"Parameter": [
110+
{
111+
"group": "Parameter",
112+
"type": "<p>Number</p> ",
113+
"optional": false,
114+
"field": "userid",
115+
"description": "<p>user id</p> "
116+
}
117+
]
118+
}
119+
},
120+
"group": "Authentication",
121+
"name": "GetSubscriptionInfo",
122+
"filename": "folder2/History.js",
123+
"groupTitle": "Authentication",
124+
"error": {
125+
"fields": {
126+
"500 Internal Server Error": [
127+
{
128+
"group": "500 Internal Server Error",
129+
"optional": false,
130+
"field": "InternalServerError",
131+
"description": "<p>The server encountered an internal error</p> "
132+
}
133+
]
134+
},
135+
"examples": [
136+
{
137+
"title": "500 Internal Server Error",
138+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
139+
"type": "json"
140+
}
141+
]
142+
}
143+
}
144+
] });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
[
2+
{
3+
"type": "post",
4+
"url": "/api/authenticate",
5+
"title": "",
6+
"version": "0.3.0",
7+
"group": "Authentication",
8+
"name": "Authenticate",
9+
"parameter": {
10+
"fields": {
11+
"Credentials": [
12+
{
13+
"group": "Credentials",
14+
"type": "<p>String</p> ",
15+
"optional": false,
16+
"field": "username",
17+
"description": "<p>Username</p> "
18+
},
19+
{
20+
"group": "Credentials",
21+
"type": "<p>String</p> ",
22+
"optional": false,
23+
"field": "password",
24+
"description": "<p>password</p> "
25+
}
26+
]
27+
}
28+
},
29+
"filename": "src/test_api.js",
30+
"groupTitle": "Authentication",
31+
"error": {
32+
"fields": {
33+
"500 Internal Server Error": [
34+
{
35+
"group": "500 Internal Server Error",
36+
"optional": false,
37+
"field": "InternalServerError",
38+
"description": "<p>The server encountered an internal error</p> "
39+
}
40+
]
41+
},
42+
"examples": [
43+
{
44+
"title": "500 Internal Server Error",
45+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
46+
"type": "json"
47+
}
48+
]
49+
}
50+
},
51+
{
52+
"type": "get",
53+
"url": "/api/subscriptioninfo",
54+
"title": "",
55+
"version": "0.3.0",
56+
"description": "<p>Get the subscription information from an authenticated user.</p> ",
57+
"group": "Authentication",
58+
"name": "GetSubscriptionInfo",
59+
"filename": "src/test_api.js",
60+
"groupTitle": "Authentication",
61+
"header": {
62+
"fields": {
63+
"Header": [
64+
{
65+
"group": "Header",
66+
"type": "String",
67+
"optional": false,
68+
"field": "Authorization",
69+
"description": "<p>Auth header with JWT Token</p> "
70+
}
71+
]
72+
},
73+
"examples": [
74+
{
75+
"title": "Authorization-Example:",
76+
"content": "Authorization: Bearer <jwt-token>",
77+
"type": "String"
78+
}
79+
]
80+
},
81+
"error": {
82+
"fields": {
83+
"500 Internal Server Error": [
84+
{
85+
"group": "500 Internal Server Error",
86+
"optional": false,
87+
"field": "InternalServerError",
88+
"description": "<p>The server encountered an internal error</p> "
89+
}
90+
]
91+
},
92+
"examples": [
93+
{
94+
"title": "500 Internal Server Error",
95+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
96+
"type": "json"
97+
}
98+
]
99+
}
100+
},
101+
{
102+
"type": "get",
103+
"url": "/api/subscriptioninfo/:userid",
104+
"title": "",
105+
"version": "0.2.0",
106+
"description": "<p>Get the subscription information for a user.</p> ",
107+
"parameter": {
108+
"fields": {
109+
"Parameter": [
110+
{
111+
"group": "Parameter",
112+
"type": "<p>Number</p> ",
113+
"optional": false,
114+
"field": "userid",
115+
"description": "<p>user id</p> "
116+
}
117+
]
118+
}
119+
},
120+
"group": "Authentication",
121+
"name": "GetSubscriptionInfo",
122+
"filename": "folder2/History.js",
123+
"groupTitle": "Authentication",
124+
"error": {
125+
"fields": {
126+
"500 Internal Server Error": [
127+
{
128+
"group": "500 Internal Server Error",
129+
"optional": false,
130+
"field": "InternalServerError",
131+
"description": "<p>The server encountered an internal error</p> "
132+
}
133+
]
134+
},
135+
"examples": [
136+
{
137+
"title": "500 Internal Server Error",
138+
"content": "HTTP/1.1 500 Internal Server Error\n{\n \"uri\": \"<api-endpoint>\",\n \"method\": \"<method used>\",\n \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n \"title\": \"Internal Server Error\",\n \"status\": 500,\n \"detail\": \"<Detail Message>\"\n}",
139+
"type": "json"
140+
}
141+
]
142+
}
143+
}
144+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
define({
2+
"name": "Multiple Input Folder Test",
3+
"version": "1.0.0",
4+
"description": "Example of feeding apidoc from multiple input folder locations",
5+
"sampleUrl": false,
6+
"apidoc": "0.2.0",
7+
"generator": {
8+
"name": "apidoc",
9+
"time": "2015-05-08T10:26:38.294Z",
10+
"url": "http://apidocjs.com",
11+
"version": "0.12.3"
12+
}
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Multiple Input Folder Test",
3+
"version": "1.0.0",
4+
"description": "Example of feeding apidoc from multiple input folder locations",
5+
"sampleUrl": false,
6+
"apidoc": "0.2.0",
7+
"generator": {
8+
"name": "apidoc",
9+
"time": "2015-05-08T10:26:38.294Z",
10+
"url": "http://apidocjs.com",
11+
"version": "0.12.3"
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>apiDoc</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7+
</head>
8+
<body>
9+
10+
Empty Test Template.
11+
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)