Home

Awesome

ts2jsdoc

A JSDoc plugin with an optional template which automatically adds JSDoc comments based on Typescript definitions.

Overview

Features

Demos

You can see some demos here:

Plugin

Usage

First install the plugin as a dependency.

$ npm install ts2jsdoc

Then configure the plugin and the template using JSDoc's conf.json:

{
    "source": {
        "includePattern": "(\\.d)?\\.ts$"
    },
    "plugins": [
        "node_modules/ts2jsdoc/plugin.js"
    ],
    "opts": {
        "template": "node_modules/ts2jsdoc/template"
    }
}

Options

All Typescript's compiler options are available. Plugin options are provided using JSDoc's config.json:

"typescript": {
    "target":                           "{es3|es5|es6|latest}",
    "module":                           "{commonjs|amd|none}",
    "codepage":                         "{number}",
    "charset":                          "{string}",
    "mapRoot":                          "{string}",
    "sourceRoot":                       "{string}",
    "allowNonTsExtensions":             "{boolean}",
    "declaration":                      "{boolean}",
    "diagnostics":                      "{boolean}",
    "emitBOM":                          "{boolean}",
    "noEmitOnError":                    "{boolean}",
    "noErrorTruncation":                "{boolean}",
    "noImplicitAny":                    "{boolean}",
    "noLib":                            "{boolean}",
    "noLibCheck":                       "{boolean}",
    "noResolve":                        "{boolean}",
    "preserveConstEnums":               "{boolean}",
    "removeComments":                   "{boolean}",
    "suppressImplicitAnyIndexErrors":   "{boolean}"
}

Template

The template allows you to easily take advantage of the full plugin features. It supports generic annotations, call signatures, construct singatures and anonymous types and callbacks.

It's entirely based on Bootstrap so it's easily customizable using a simple Bootstrap theme.

Configuration

Template options are provided using JSDoc's config.json:

"templates": {
    "systemName":           "{string}",
    "theme":                "{path | default}",
    "navType":              "{vertical | inline}",
    "inverseNav":           "{boolean}", 
    "tableOfContents":      "{boolean}",
    "linenums":             "{boolean}",
    "collapseSymbols":      "{boolean}",
    "footer":               "{string}",
    "copyright":            "{string}",
    "analytics":            "{string}",
    "outputSourceFiles":    "{boolean}",
    "outputSourcePath":     "{boolean}"
}

Options

CLI

ts2jsdoc can also be used as a standalone CLI tool to generate .js.doc files from Typescript files.

Usage

First install ts2jsdoc as a global pacakge.

$ npm install -g ts2jsdoc

Then you can use the plugin with the same options as tsc.

$ ts2jsdoc --module commonjs --target es5 lib.d.ts

Contribute

Any contribution is welcome !

Get started

First, clone the repository:

$ git clone https://gitub.com/spatools/ts2jsdoc.git

Then install dev dependencies:

$ npm install

Build targets

Then project is using Grunt.js for test and build. To start a task type:

$ grunt <task>

Release History