Skip to content

Commit a834250

Browse files
committed
Fix d.ts whitespace on empty lines, added tsd-jsdoc LICENSE [ci skip]
1 parent 8f407a1 commit a834250

File tree

3 files changed

+345
-317
lines changed

3 files changed

+345
-317
lines changed

lib/tsd-jsdoc/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2016 Chad Engler
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
13+
all 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
21+
THE SOFTWARE.

lib/tsd-jsdoc/publish.js

+28-21
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ exports.publish = function publish(taffy, opts) {
8080
while (queuedInterfaces.length) {
8181
var element = queuedInterfaces.shift();
8282
begin(element);
83-
writeVirtualInterface(element);
83+
writeInterface(element);
8484
writeln(";");
8585
}
8686

@@ -120,7 +120,11 @@ function write() {
120120

121121
// writes one or multiple strings, followed by a new line
122122
function writeln() {
123-
write(Array.prototype.slice.call(arguments).join(""), "\n");
123+
var s = Array.prototype.slice.call(arguments).join("");
124+
if (s)
125+
write(s, "\n");
126+
else
127+
out.write("\n");
124128
indentWritten = false;
125129
}
126130

@@ -268,11 +272,22 @@ function writeFunctionSignature(element, isConstructor, isTypeDef) {
268272
}
269273
}
270274

275+
// writes (a typedef as) an interface
276+
function writeInterface(element) {
277+
writeln("interface ", element.name, " {");
278+
++indent;
279+
element.properties.forEach(function(property) {
280+
writeln(property.name, ": ", getTypeOf(property), ";");
281+
});
282+
--indent;
283+
writeln("}");
284+
}
285+
271286
//
272287
// Handlers
273288
//
274289

275-
// handles a single element / any
290+
// handles a single element of any understood type
276291
function handleElement(element, parent) {
277292
if (seen[element.longname])
278293
return;
@@ -305,6 +320,12 @@ function handleNamespace(element, parent) {
305320
writeln("}");
306321
}
307322

323+
// a filter function to remove any module references
324+
function notAModuleReference(ref) {
325+
return ref.indexOf("module:") === -1;
326+
}
327+
328+
308329
// handles a class or class-like
309330
function handleClass(element, parent) {
310331
begin(element);
@@ -319,9 +340,7 @@ function handleClass(element, parent) {
319340

320341
// extended classes
321342
if (element.augments) {
322-
var augments = element.augments.filter(function(aug) {
323-
return aug.indexOf("module:") === -1;
324-
});
343+
var augments = element.augments.filter(notAModuleReference);
325344
if (augments.length)
326345
write("extends ", augments[0], " ");
327346
}
@@ -332,9 +351,7 @@ function handleClass(element, parent) {
332351
Array.prototype.push.apply(impls, element.implements);
333352
if (element.mixes)
334353
Array.prototype.push.apply(impls, element.mixes);
335-
impls = impls.filter(function(imp) {
336-
return imp.indexOf("module:") === -1;
337-
});
354+
impls = impls.filter(notAModuleReference);
338355
if (impls.length)
339356
write("implements ", impls.join(", "), " ");
340357

@@ -359,7 +376,7 @@ function handleClass(element, parent) {
359376

360377
if (innerClasses.length) {
361378
writeln("");
362-
writeln("module ", element.name, "{");
379+
writeln("module ", element.name, " {");
363380
++indent;
364381
innerClasses.forEach(function(inner) {
365382
handleClass(inner, element);
@@ -424,24 +441,14 @@ function handleFunction(element, parent, isConstructor) {
424441
writeln(";");
425442
}
426443

427-
function writeVirtualInterface(element) {
428-
writeln("interface ", element.name, " {");
429-
++indent;
430-
element.properties.forEach(function(property) {
431-
writeln(property.name, ": ", getTypeOf(property), ";");
432-
});
433-
--indent;
434-
writeln("}");
435-
}
436-
437444
// handles a type definition (not a real type)
438445
function handleTypeDef(element, parent) {
439446
if (isInterface(element)) {
440447
if (isClass(parent))
441448
queuedInterfaces.push(element);
442449
else {
443450
begin(element);
444-
writeVirtualInterface(element);
451+
writeInterface(element);
445452
}
446453
} else {
447454
begin(element);

0 commit comments

Comments
 (0)