Reputation: 1
I want to generate automatically some documentation for Intern 4 functional tests. I tried typedoc and it worked pretty well when parsing my object page functions, but failed with functional Test suites, for example on a file like
/**
* This is a test comment for general purpose
*/
/**
*
*/
const { registerSuite } = intern.getInterface('object');
const { url } = intern.getPlugin('conf');
import {
tryLogin,
pollForDElement,
clickByDId,
clickSeq,
verifyGantt,
verifyIcon,
verifyCell
} from '../objectPage';
declare let ui: any;
let grid:string;
let id:string;
registerSuite('cells-pre-test',
{
/**
* this is a test comment for a test
*
*/
'login'()
{
return this.remote
.setFindTimeout(20000)
.setPageLoadTimeout(20000)
.setExecuteAsyncTimeout(20000)
.get(url)
.then(tryLogin('xxx', 'xxx'));
}
});
with command
typedoc --module commonjs --target ES6 --out docs/ tests/
just the comment for general purpose appears to the generated documentation, not the comment to the test suite.
Anybody could help me to figure out this or suggest alternative tools with automatic Typescript parsing?
Thanks
Upvotes: 0
Views: 256
Reputation: 3363
Typedoc only extracts comments for certain types of elements, like modules, exported functions, classes, and class members. There's nothing particularly special about a test function (it's just a method in a generic object), so Typedoc doesn't pay attention to any related comments. (See https://github.com/TypeStrong/typedoc/issues/821.)
I'm not aware of any JS or TS documentation tools that would extract test comments. One possibility would be to use Typedoc's JSON output functionality (typedoc --json <json file>
) to output a JSON description of the project. You could then write a tool that walked the JSON data looking for doc comments and created a doc file based on what it found. This would probably work best with a custom doc tag of some sort, like @test
, so that the tool could identify which comments related to tests.
Upvotes: 0