Skip to content

Commit 8f407a1

Browse files
committed
Post-merge; Repo now includes a restructured version of tsd-jsdoc with our changes incorporated for issues/prs, see #550
1 parent 82e8dd4 commit 8f407a1

File tree

8 files changed

+2869
-2406
lines changed

8 files changed

+2869
-2406
lines changed

cli/pbts.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ exports.main = function(args) {
5151

5252
// There is no proper API for jsdoc, so this executes the CLI and pipes the output
5353
var basedir = path.join(__dirname, "..");
54-
var child = child_process.exec("node \"" + basedir + "/node_modules/jsdoc/jsdoc.js\" -c \"" + basedir + "/jsdoc.types.json\" " + files.map(function(file) { return '"' + file + '"'; }).join(' '), {
54+
var moduleName = argv.name || "mymodule";
55+
var child = child_process.exec("node \"" + basedir + "/node_modules/jsdoc/jsdoc.js\" -c \"" + basedir + "/jsdoc.types.json\" -q \"module=" + encodeURIComponent(moduleName) + "\" " + files.map(function(file) { return '"' + file + '"'; }).join(' '), {
5556
cwd: process.cwd(),
5657
argv0: "node",
5758
stdio: "pipe"
@@ -69,23 +70,15 @@ exports.main = function(args) {
6970
return;
7071
}
7172

72-
var dts = out.join('').replace(/{$/mg, "{\n").trim();
73-
74-
var header = [
73+
var output = [
7574
"// $> pbts " + process.argv.slice(2).join(' '),
7675
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
77-
""
78-
];
79-
80-
// Remove declare statements and wrap everything in a module
81-
dts = dts.replace(/\bdeclare\s/g, "");
82-
dts = dts.replace(/^/mg, " ");
83-
dts = header.join('\n')+"\ndeclare module " + JSON.stringify(argv.name || "mymodule") + " {\n\n" + dts + "\n\n}\n";
76+
].join('\n') + "\n" + out.join('');
8477

8578
if (argv.out)
86-
fs.writeFileSync(argv.out, dts);
79+
fs.writeFileSync(argv.out, output);
8780
else
88-
process.stdout.write(dts, "utf8");
81+
process.stdout.write(output, "utf8");
8982
});
9083

9184
return undefined;

jsdoc.types.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
"includePattern": ".+\\.js(doc)?$",
88
"excludePattern": "(^|\\/|\\\\)_"
99
},
10-
"templates": {
11-
"jsdoc2tsd": {
12-
"interfacePrefix" : ""
13-
}
14-
},
1510
"opts": {
1611
"encoding" : "utf8",
1712
"recurse" : true,
18-
"private" : false,
1913
"lenient" : true,
20-
"destination" : "console",
21-
"template" : "./node_modules/tsd-jsdoc"
14+
"template" : "./lib/tsd-jsdoc",
15+
16+
"private" : false,
17+
"comments" : true,
18+
"destination" : false
2219
}
2320
}

lib/tsd-jsdoc/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
protobuf.js fork of tsd-jsdoc
2+
=============================
3+
4+
This is a slightly modified and restructured version of [tsd-jsdoc](https://github.com/englercj/tsd-jsdoc) for use with protobuf.js, parked here so we can process issues and pull requests.
5+
6+
Options
7+
-------
8+
9+
* **module: `string`**<br />
10+
Wraps everything in a module of the specified name.
11+
12+
* **private: `boolean`**<br />
13+
Skips private members when set to `false`.
14+
15+
* **comments: `boolean`**<br />
16+
Skips any comments when set to `false`.
17+
18+
* **destination: `string|boolean`**<br />
19+
Saves to the specified destination file or to console when set to `false`.
20+
21+
Setting options on the command line
22+
-----------------------------------
23+
Providing `-q, --query <queryString>` on the command line will set respectively override existing options.

0 commit comments

Comments
 (0)