Skip to content

Commit 2675b85

Browse files
Recompiled TypeDoc
1 parent 0e7324f commit 2675b85

File tree

3 files changed

+143
-11
lines changed

3 files changed

+143
-11
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,44 @@ function doSomething(target:any, value:number):number;
151151
function doSomething(target:any, arg:any):number {
152152
return 0;
153153
}
154+
```
155+
156+
157+
### Modules
158+
159+
Modules can be commented like any other elements in TypeScript. As modules can be defined in multiple
160+
files, TypeDoc selects the longest comment by default. One may override this behaviour with the special
161+
`@preferred` comment tag.
162+
163+
```typescript
164+
/**
165+
* Actual module comment.
166+
* @preferred
167+
*/
168+
module MyModule { }
169+
```
170+
171+
```typescript
172+
/**
173+
* Dismissed module comment.
174+
* This is the longer comment but will be dismissed in favor of the preferred comment.
175+
*/
176+
module MyModule { }
177+
```
178+
179+
180+
### Dynamic modules
181+
182+
The first doc comment within a file is used as the doc comment of a dynamic module. However, you must
183+
ensure that the first declaration also has as doc comment.
184+
185+
```typescript
186+
/**
187+
* This is a doc comment for a dynamic module.
188+
*/
189+
190+
/**
191+
* This is a doc comment for "someVar".
192+
*/
193+
var someVar:string = "value";
154194
```

bin/typedoc.d.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,25 @@ declare module TypeDoc.Factories {
834834
static parseDocComment(text: string, comment?: Models.Comment): Models.Comment;
835835
}
836836
}
837+
declare module TypeDoc.Factories {
838+
/**
839+
* A handler that moves comments with dot syntax to their target.
840+
*/
841+
class DeepCommentHandler extends BaseHandler {
842+
/**
843+
* Create a new CommentHandler instance.
844+
*
845+
* @param dispatcher The dispatcher this handler should be attached to.
846+
*/
847+
constructor(dispatcher: Dispatcher);
848+
/**
849+
* Triggered when the dispatcher starts processing a declaration.
850+
*
851+
* @param state The state that describes the current declaration and reflection.
852+
*/
853+
private onDeclaration(state);
854+
}
855+
}
837856
declare module TypeDoc.Factories {
838857
/**
839858
* A handler that truncates the names of dynamic modules to not include the
@@ -984,11 +1003,11 @@ declare module TypeDoc.Factories {
9841003
*/
9851004
constructor(dispatcher: Dispatcher);
9861005
/**
987-
* Triggered when the dispatcher processes a declaration.
1006+
* Triggered when the dispatcher has finished processing a declaration.
9881007
*
9891008
* @param state The state that describes the current declaration and reflection.
9901009
*/
991-
private onDeclaration(state);
1010+
private onEndDeclaration(state);
9921011
}
9931012
}
9941013
declare module TypeDoc.Factories {
@@ -1221,11 +1240,11 @@ declare module TypeDoc.Factories {
12211240
*/
12221241
constructor(dispatcher: Dispatcher);
12231242
/**
1224-
* Triggered when the dispatcher starts processing a declaration.
1243+
* Triggered when the dispatcher has finished processing a declaration.
12251244
*
12261245
* @param state The state that describes the current declaration and reflection.
12271246
*/
1228-
private onDeclaration(state);
1247+
private onEndDeclaration(state);
12291248
static getLiteralDeclaration(declaration: TypeScript.PullDecl): TypeScript.PullDecl;
12301249
}
12311250
}
@@ -1695,6 +1714,10 @@ declare module TypeDoc.Models {
16951714
*/
16961715
public name: string;
16971716
/**
1717+
* The original name of the TypeScript declaration.
1718+
*/
1719+
public originalName: string;
1720+
/**
16981721
* The parsed documentation comment attached to this reflection.
16991722
*/
17001723
public comment: Comment;

bin/typedoc.js

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ var TypeDoc;
14781478
var len = basePath.length;
14791479

14801480
while (basePath != dirname.substr(0, len)) {
1481-
if (len <= dirname.length) {
1481+
if (len >= dirname.length) {
14821482
return;
14831483
}
14841484

@@ -1926,6 +1926,7 @@ var TypeDoc;
19261926
var parent = state.parentState.reflection;
19271927
var reflection = new TypeDoc.Models.DeclarationReflection();
19281928
reflection.name = (state.flattenedName ? state.flattenedName + '.' : '') + state.getName();
1929+
reflection.originalName = state.declaration.name;
19291930
reflection.parent = parent;
19301931

19311932
state.reflection = reflection;
@@ -2572,6 +2573,74 @@ var TypeDoc;
25722573
var Factories = TypeDoc.Factories;
25732574
})(TypeDoc || (TypeDoc = {}));
25742575
var TypeDoc;
2576+
(function (TypeDoc) {
2577+
(function (Factories) {
2578+
/**
2579+
* A handler that moves comments with dot syntax to their target.
2580+
*/
2581+
var DeepCommentHandler = (function (_super) {
2582+
__extends(DeepCommentHandler, _super);
2583+
/**
2584+
* Create a new CommentHandler instance.
2585+
*
2586+
* @param dispatcher The dispatcher this handler should be attached to.
2587+
*/
2588+
function DeepCommentHandler(dispatcher) {
2589+
_super.call(this, dispatcher);
2590+
2591+
dispatcher.on(Factories.Dispatcher.EVENT_DECLARATION, this.onDeclaration, this, -512);
2592+
}
2593+
/**
2594+
* Triggered when the dispatcher starts processing a declaration.
2595+
*
2596+
* @param state The state that describes the current declaration and reflection.
2597+
*/
2598+
DeepCommentHandler.prototype.onDeclaration = function (state) {
2599+
var reflection = state.reflection;
2600+
if (reflection.comment) {
2601+
return;
2602+
}
2603+
2604+
function push(reflection) {
2605+
var part = reflection.originalName;
2606+
if (reflection.isSignature) {
2607+
part = '';
2608+
}
2609+
2610+
if (part && part != '') {
2611+
name = (name == '' ? part : part + '.' + name);
2612+
}
2613+
}
2614+
2615+
var name = '';
2616+
var target = reflection.parent;
2617+
push(reflection);
2618+
2619+
while (target instanceof TypeDoc.Models.DeclarationReflection) {
2620+
if (target.comment) {
2621+
var tag = target.comment.getTag('param', name);
2622+
if (tag) {
2623+
target.comment.tags.splice(target.comment.tags.indexOf(tag), 1);
2624+
reflection.comment = new TypeDoc.Models.Comment('', tag.text);
2625+
break;
2626+
}
2627+
}
2628+
2629+
target = target.parent;
2630+
}
2631+
};
2632+
return DeepCommentHandler;
2633+
})(Factories.BaseHandler);
2634+
Factories.DeepCommentHandler = DeepCommentHandler;
2635+
2636+
/**
2637+
* Register this handler.
2638+
*/
2639+
Factories.Dispatcher.HANDLERS.push(DeepCommentHandler);
2640+
})(TypeDoc.Factories || (TypeDoc.Factories = {}));
2641+
var Factories = TypeDoc.Factories;
2642+
})(TypeDoc || (TypeDoc = {}));
2643+
var TypeDoc;
25752644
(function (TypeDoc) {
25762645
(function (Factories) {
25772646
/**
@@ -2931,14 +3000,14 @@ var TypeDoc;
29313000
function FunctionTypeHandler(dispatcher) {
29323001
_super.call(this, dispatcher);
29333002

2934-
dispatcher.on(Factories.Dispatcher.EVENT_DECLARATION, this.onDeclaration, this, -256);
3003+
dispatcher.on(Factories.Dispatcher.EVENT_END_DECLARATION, this.onEndDeclaration, this);
29353004
}
29363005
/**
2937-
* Triggered when the dispatcher processes a declaration.
3006+
* Triggered when the dispatcher has finished processing a declaration.
29383007
*
29393008
* @param state The state that describes the current declaration and reflection.
29403009
*/
2941-
FunctionTypeHandler.prototype.onDeclaration = function (state) {
3010+
FunctionTypeHandler.prototype.onEndDeclaration = function (state) {
29423011
if (state.isSignature) {
29433012
return;
29443013
}
@@ -3578,14 +3647,14 @@ var TypeDoc;
35783647
function ObjectLiteralHandler(dispatcher) {
35793648
_super.call(this, dispatcher);
35803649

3581-
dispatcher.on(Factories.Dispatcher.EVENT_DECLARATION, this.onDeclaration, this, 1024);
3650+
dispatcher.on(Factories.Dispatcher.EVENT_END_DECLARATION, this.onEndDeclaration, this);
35823651
}
35833652
/**
3584-
* Triggered when the dispatcher starts processing a declaration.
3653+
* Triggered when the dispatcher has finished processing a declaration.
35853654
*
35863655
* @param state The state that describes the current declaration and reflection.
35873656
*/
3588-
ObjectLiteralHandler.prototype.onDeclaration = function (state) {
3657+
ObjectLiteralHandler.prototype.onEndDeclaration = function (state) {
35893658
var _this = this;
35903659
var literal = ObjectLiteralHandler.getLiteralDeclaration(state.declaration);
35913660
if (literal && literal.getChildDecls().length > 0) {

0 commit comments

Comments
 (0)