Permalink
Browse files

Fix d.ts whitespace on empty lines, added tsd-jsdoc LICENSE [ci skip]

  • Loading branch information...
dcodeIO committed Dec 15, 2016
1 parent 8f407a1 commit a83425049c9a78c5607bc35e8089e08ce78a741e
Showing with 345 additions and 317 deletions.
  1. +21 −0 lib/tsd-jsdoc/LICENSE
  2. +28 −21 lib/tsd-jsdoc/publish.js
  3. +296 −296 types/protobuf.js.d.ts
@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2016 Chad Engler
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -80,7 +80,7 @@ exports.publish = function publish(taffy, opts) {
while (queuedInterfaces.length) {
var element = queuedInterfaces.shift();
begin(element);
writeVirtualInterface(element);
writeInterface(element);
writeln(";");
}
@@ -120,7 +120,11 @@ function write() {
// writes one or multiple strings, followed by a new line
function writeln() {
write(Array.prototype.slice.call(arguments).join(""), "\n");
var s = Array.prototype.slice.call(arguments).join("");
if (s)
write(s, "\n");
else
out.write("\n");
indentWritten = false;
}
@@ -268,11 +272,22 @@ function writeFunctionSignature(element, isConstructor, isTypeDef) {
}
}
// writes (a typedef as) an interface
function writeInterface(element) {
writeln("interface ", element.name, " {");
++indent;
element.properties.forEach(function(property) {
writeln(property.name, ": ", getTypeOf(property), ";");
});
--indent;
writeln("}");
}
//
// Handlers
//
// handles a single element / any
// handles a single element of any understood type
function handleElement(element, parent) {
if (seen[element.longname])
return;
@@ -305,6 +320,12 @@ function handleNamespace(element, parent) {
writeln("}");
}
// a filter function to remove any module references
function notAModuleReference(ref) {
return ref.indexOf("module:") === -1;
}
// handles a class or class-like
function handleClass(element, parent) {
begin(element);
@@ -319,9 +340,7 @@ function handleClass(element, parent) {
// extended classes
if (element.augments) {
var augments = element.augments.filter(function(aug) {
return aug.indexOf("module:") === -1;
});
var augments = element.augments.filter(notAModuleReference);
if (augments.length)
write("extends ", augments[0], " ");
}
@@ -332,9 +351,7 @@ function handleClass(element, parent) {
Array.prototype.push.apply(impls, element.implements);
if (element.mixes)
Array.prototype.push.apply(impls, element.mixes);
impls = impls.filter(function(imp) {
return imp.indexOf("module:") === -1;
});
impls = impls.filter(notAModuleReference);
if (impls.length)
write("implements ", impls.join(", "), " ");
@@ -359,7 +376,7 @@ function handleClass(element, parent) {
if (innerClasses.length) {
writeln("");
writeln("module ", element.name, "{");
writeln("module ", element.name, " {");
++indent;
innerClasses.forEach(function(inner) {
handleClass(inner, element);
@@ -424,24 +441,14 @@ function handleFunction(element, parent, isConstructor) {
writeln(";");
}
function writeVirtualInterface(element) {
writeln("interface ", element.name, " {");
++indent;
element.properties.forEach(function(property) {
writeln(property.name, ": ", getTypeOf(property), ";");
});
--indent;
writeln("}");
}
// handles a type definition (not a real type)
function handleTypeDef(element, parent) {
if (isInterface(element)) {
if (isClass(parent))
queuedInterfaces.push(element);
else {
begin(element);
writeVirtualInterface(element);
writeInterface(element);
}
} else {
begin(element);
Oops, something went wrong.

0 comments on commit a834250

Please sign in to comment.