jsdocts

0.1.4 • Public • Published

jsdocts

Outputs typescript declaration files from javascript files documented with jsDoc

Overview

jsdocts uses the jsdoc-toolkit to create a typescript decleration files from the jsdoc comments in the associated javascript files.

jsdocts uses NOC to wrap the jsdoc-toolkit

Installation

npm install -g jsdocts

Usage

jsdocts -d:<decleration_output_path> <source_dir> <source_file> ...

Known Issues

  • Optional parameters
  • Method overloading
  • Modules

Untested

  • Passthrough of standard jsDoc-Toolkit options

Example

javascript file documentd with jsdocs

/**
    Creates a new Vector.
 
    @constructor
    @param {Number} x The x component of the vector.
    @param {Number} y The y component of the vector.
    @param {Number} z The z component of the vector.
*/
function Vector(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
}
 
/**
    Multiples a vector by the given value and returns the new vector
 
    @method times
    @param {Number} k The multiplication value.
    @return {Vector} 
*/
Vector.prototype.times = function (k) {
    return new Vector(* this.x, k * this.y, k * this.z);
};
 
/**
    Adds a vector to the vector instance, returning a new vector.
 
    @method plus
    @param {Vector} v The vector to be added.
    @return {Vector} 
*/
Vector.prototype.plus = function (v) {
    return new Vector(this.x + v.x, this.y + v.y, this.z + v.z);
};
 
/**
    Performs the dot product
 
    @method dot
    @param {Vector} v The second vector in the dot product
    @return {Vector} 
*/
Vector.prototype.dot = function (v) {
    return this.x * v.x + this.y * v.y + this.z * v.z;
};
 
/**
    Gets the magnitude of the vector
 
    @method mag
    @return {Number} 
*/
Vector.prototype.mag = function () {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
};
 
 
/**
    Performs the cross product of 2 vectors
 
    @method cross
    @param {Vector} v1 The first vector used to perform the cross product.
    @param {Vector} v2 The second vector used to perform the cross product.
    @return {Number} 
*/
Vector.cross = function cross(v1, v2) {
    return new Vector(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
};

exported declaration file

export interface Vector  { 
   times(kNumber): Vector;
    plus(vVector): Vector;
    dot(vVector): Vector;
    mag(): Number;
    static cross(v1Vector, v2Vector): Number;
}

Readme

Keywords

none

Package Sidebar

Install

npm i jsdocts

Weekly Downloads

5

Version

0.1.4

License

none

Last publish

Collaborators

  • joshheyse