Skip to content

Commit

Permalink
fix expected output to contain comments
Browse files Browse the repository at this point in the history
  • Loading branch information
englercj committed Dec 22, 2018
1 parent 09b5cdf commit bc735e2
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/create_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function handleComment<T extends ts.Node>(doclet: IDocletBase, node: T): T
// remove ' *' leading spaces
comment = comment.replace(/[ \t]+\*/g, ' *');

// remove trailing spaces
// remove trailing spacesgit dif
comment = comment.trim() + '\n ';

const kind = ts.SyntaxKind.MultiLineCommentTrivia;
Expand Down
117 changes: 117 additions & 0 deletions test/expected/class_all.d.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,109 @@
/**
* @this OtherThing
*/
declare function doStuff(): void;

/**
* @class
* @abstract
*/
declare class OtherThing {
/**
*
*/
copy(): void;
}

/**
*
*/
declare class Stuff {
/**
*
*/
doStuff(): void;
}

/**
*
*/
declare class Things {
/**
*
*/
doThings(): void;
}

/**
* Deep class #1
*
* @class
*/
declare class DeepClass1 {
constructor();
}

declare module DeepClass1 {
/**
* Deep class #2
*
* @class
*/
class DeepClass2 {
constructor();
}
module DeepClass2 {
/**
* Deep class #3
*
* @class
*/
class DeepClass3 {
constructor();
}
module DeepClass3 {
/**
* Deep class #4
*
* @class
*/
class DeepClass4 {
constructor();
}
}
}
}

/** @module util
*/
declare module util {
/**
* @class MyClass
* @param {string} message
* @returns {MyClass}
*/
class MyClass {
constructor(message: string);
/** @type {string}
*/
message: string;
}
/**
* GitGraph
* @constructor
* @param {object} options - GitGraph options
* @param {string} [options.elementId = "gitGraph"] - Id of the canvas container
* @param {Template|string|object} [options.template] - Template of the graph
* @param {string} [options.author = "Sergio Flores <saxo-guy@epic.com>"] - Default author for commits
* @param {string} [options.mode = (null|"compact")] - Display mode
* @param {HTMLElement} [options.canvas] - DOM canvas (ex: document.getElementById("id"))
* @param {string} [options.orientation = ("vertical-reverse"|"horizontal"|"horizontal-reverse")] - Graph orientation
* @param {boolean} [options.reverseArrow = false] - Make arrows point to ancestors if true
* @param {number} [options.initCommitOffsetX = 0] - Add custom offsetX to initial commit.
* @param {number} [options.initCommitOffsetY = 0] - Add custom offsetY to initial commit.
* @param {HTMLElement} [options.tooltipContainer = document.body] - HTML Element containing tooltips in compact mode.
* @this GitGraph
*/
class GitGraph {
constructor(options: {
elementId?: string;
Expand All @@ -51,22 +118,72 @@ declare module util {
tooltipContainer?: HTMLElement;
});
}
/**
* @typedef Something
* @type boolean
*/
type Something = boolean;
interface MyThing extends Stuff, Things {
}
/**
* @class
* @extends OtherThing
* @mixes Stuff
* @mixes Things
*/
class MyThing extends OtherThing implements Stuff, Things {
constructor(...a: number[]);
/**
* Derp or something.
*
* @member {string}
* @readonly
*/
readonly derp: string;
/**
* @member {Object<string, Array<(number|string)>>}
*/
map: {
[key: string]: (number | string)[];
};
/**
* @member {Array<Array.<Array<Array.<string[]>>>>}
*/
superArray: string[][][][][];
/**
* Creates a new thing.
*
* @param {!FoobarNS.CircleOptions} opts - Namespace test!
* @return {MyThing} the new thing.
*/
static create(opts: FoobarNS.CircleOptions): MyThing;
/**
* Gets a Promise that will resolve with an Object.
*
* @return {Promise<Object>} The Promise
*/
promiseMe(): Promise<any>;
/**
*
* @param {GitGraphOptions} options - GitGraph options
*/
objParam(options: GitGraphOptions): void;
/**
* Gets derp.
*
* @member {string}
*/
D: string;
/**
* @member {number}
* @static
*/
static me: number;
/**
*
*/
copy(): void;
}
}


6 changes: 6 additions & 0 deletions test/expected/enum_all.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/**
* Enum for tri-state values.
* @readonly
* @enum {number}
*/
declare enum triState {
TRUE,
FALSE,
MAYBE
}


25 changes: 25 additions & 0 deletions test/expected/function_all.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
/**
*
* @param {number} [a=10]
* @param {Object} input
* @param {number} input.x
* @param {number} input.y
*/
declare function test1(a?: number, input: {
x: number;
y: number;
}): void;

/**
* @class
*/
declare class Test12345 {
/**
* @function
* @memberof Test12345
* @name f
* @return {number[]}
*/
static f(): number[];
/**
* @function
* @memberof Test12345
* @variation 1
* @name f
* @param {string} key
* @return {number}
*/
static f(key: string): number;
}


13 changes: 13 additions & 0 deletions test/expected/interface_all.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
/**
* Interface for classes that represent a color.
*
* @interface
*/
declare interface Color {
/**
* Get the color as an array of red, green, and blue values, represented as
* decimal numbers between 0 and 1.
*
* @returns {Array<number>} An array containing the red, green, and blue values,
* in that order.
*/
rgb(): number[];
}


51 changes: 51 additions & 0 deletions test/expected/namespace_all.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
/**
* @namespace FoobarNS
*/
declare namespace FoobarNS {
/**
* @classdesc
* A Foo.
*
* @constructor
* @template T
*/
class Foo<T> {
/**
* A generic method.
* @param {FoobarNS.Foo.FCallback} f A function.
* @param [opt_this=10] An object.
* @param {number[]|object<number, string[]>} [opt_2=10] An object.
* @template S
*/
f<S>(f: FoobarNS.Foo.FCallback, opt_this?: any, opt_2?: number[] | {
[key: number]: string[];
}): void;
}
module Foo {
/**
* @callback FCallback
* @this S
* @memberof FoobarNS.Foo
* @param {T} first - The first param.
* @param {number} second - The second param.
* @param {T[]} third - The third param.
* @returns {*}
*/
type FCallback = (this: S, first: T, second: number, third: T[]) => any;
}
/**
* @classdesc
* A Bar.
*
* @constructor
* @extends FoobarNS.Foo
*/
class Bar extends FoobarNS.Foo {
/**
* A method.
*/
f(): void;
}
/**
* @interface
*/
interface CircleOptions {
/**
* Circle radius.
* @type {number}
*/
radius: number;
}
/**
* @classdesc
* Set circle style for vector features.
*
* @constructor
* @param {FoobarNS.CircleOptions=} opt_options Options.
*/
class Circle {
constructor(opt_options?: FoobarNS.CircleOptions);
}
}


Loading

0 comments on commit bc735e2

Please sign in to comment.