6

I have a .d.ts file with the interfaces describing my library. It has JSDoc comments, which will be shown via intellisense in Visual Studio when people refer to the .d.ts in their code:

/** Description of JSNLogAppender */
interface JSNLogAppender {
    /* Description of setOptions */
    setOptions(options: JSNLogAppenderOptions): void;

    /* Description of log */
    log(logItem: JSNLogItem): void;
}

... etc ...

I need to generate documentation based on the JSDoc and TypeScript interfaces. Problem is that the generators I found all work with JavaScript, and interfaces are not compiled to JavaScript. I could put the JSDoc on the actual classes and functions that implement the interfaces, but than I would lose the intellisense when people refer to the .d.ts file.

Is there a tool that generates html documentation from the JSDoc comments and the TypeScript interface definitions in a .d.ts file?

thomaux
  • 19,133
  • 10
  • 76
  • 103
user1147862
  • 4,096
  • 8
  • 36
  • 53

4 Answers4

3

You can use http://typedoc.org/

It supports jsdoc for things it cannot infer http://typedoc.org/guides/doccomments/

And any jsdoc descriptor it doesn't recognise will still be outputted, which is fortunate.

balupton
  • 47,113
  • 32
  • 131
  • 182
1

None at the moment. Could not find any related feature request here either: http://typescript.codeplex.com/workitem/list/basic

All that we do have at the moment is TypeScript language service understanding JSDoc: http://typescript.codeplex.com/workitem/178

basarat
  • 261,912
  • 58
  • 460
  • 511
  • In the absence of any tools to do this, I'm thinking of creating my own. It would parse a .d.ts file (including the JSDoc) and generate HTML using T4 templates. Am wondering if such a tool would be useful to people besides myself, or am I going off track here? – user1147862 May 20 '13 at 23:26
  • 2
    I would love to have a tool to do this. One recommendation is to use NodeJS instead of C# (I know it can be a pain) but it would be more cross platform and would integrate into the modern web workflows (e.g http://yeoman.io/ gruntjs etc) – basarat May 20 '13 at 23:47
1

I've written this small tool which may be helpful: typescript-docs

You'll need to install the Haskell Platform to build it.

It has basic support for jsdoc-style comments, and will generate HTML with hyperlinks between types, possibly across modules.

Phil Freeman
  • 4,199
  • 1
  • 20
  • 15
1

I found a npm module that claims to do this, though I haven't tried it yet: https://www.npmjs.org/package/tsdoc

JasonS
  • 7,443
  • 5
  • 41
  • 61
  • 1
    I can't see anywhere where tsdoc claims to generate docs from a definition file. It just says it uses the TypeScript compiler to generate docs from the source code. – Adam Harte May 23 '16 at 23:09