dtsdoc is a experimental documantation generator for TypeScript's ambient source file (*.d.ts). dtsdoc has original parser developed with Parsect, my parser combinator library and it does't depends on tsc's parser.
I believe ofiicial document generator will be developed with a parser of tsc in the future. So this project is just a quick hack, mainly for three.d.ts.
#Online geratation demo http://phyzkit.net/dtsdoc/
See my Web Site.
If you only want to use dtsdoc, you can precompiled javascript source files in bin
directory.
Some messy steps are needed to build.
npm install -g jakefile
- Download Parsect and place same directory with dtsdoc.
jake
To run dtsdoc in node.js, you needs some files in bin dir. dtsdoc.js
is command line script, so:
node bin/dtsdoc --out DEST SOURCE_FILE_PATH
will generate a document in DEST.
See src/dtsdoc.ts
as example.
Open web/index.html
in your browser. In Chrome, --allow-file-access-from-files
option is needed to run locally.
Can't find a type name in other split module, especially the following case:
module M {
var c: N.C; <- N.C is not found
var d: M.N.C; <- M.N.C is OK
}
module M.N {
class C {
}
}
dtsdoc is distributed under the MIT License.
Copyright (c) 2013 Kon <http://phyzkit.net/>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Multiple interfaces with the same name exist together. Merge or split them in documents? Which definition should be linked from a interface name?
Finding of subtype of interface is difficult because all combination of Classed and Interfaces have to be checked.
One-to-one mapping of a module and a source file does not hold true. I want to keep this docs generator simple but never seems to get there...
javadoc/jsdoc style start/end tag (from /**
to */
) is not good...(though @tag
is good!), because:
Generally a single line code needes three lines of the document.
/** <- Boo!
* Variable hoge is bad.
*/ <- Boo!
var hoge:Hoge;
C#-style tags ///
is cool!
/// Variable piyo is good!
var piyo:Piyo;
Can you understand the following regexp matches javadoc-style block comments?
\/(\*(?!\*)|\*\*\*+)([^*]|\r|\n|\*(?!\/))*\*\/ <- block comment
\/\*(\*(?!\*))((\*(?!\/)|[^*])*)\*\/ <- document comment
C#-style document comment is simple:
(\s*\/{3}.*\n)*
/* I temporary don't need Puyo...
class Puyo{
/**
* class variable hoge is bad.
*/
hoge:Hoge;
}
*/ <- Oops! "Check format of expression term"!
/** <- no leading spaces, 3 chars
* Variable hoge is bad. <- 1 leading spaces, 1 chars
*/ <- 1 leading spaces, 2 chars
var hoge:Hoge; <- no leading spaces
/// <- no leading spaces, 3 chars
/// Variable hoge is bad. <- Same as above
/// <- Same as above
var hoge:Hoge; <- no leading spaces
asterisks on line top is needed or not?
/**
* hoge is hoge.
* Because hoge is so hoge.
*/
var hoge: Hoge;
/**
piyo is piyo.
Because piyo is so piyo.
*/
var piyo: Piyo;
/**
*hoge* is bad variable! <- Leading asterisk will be removed or not?
*/
var hoge: Hoge;
/// *piyo* is good variable! <- Obvious, there are always leading `///`.
var piyo: Piyo;