Allows to create tests in the docs
Find a file
2025-02-08 21:51:17 +01:00
examples Fix line numbers in error messages 2022-04-08 17:56:56 +02:00
src Fix line numbers in error messages 2022-04-08 17:56:56 +02:00
tests Add --ignore as option 2022-04-08 04:39:17 +02:00
.gitignore Small tweaks 2022-03-25 16:36:18 +01:00
LICENSE Support doctests for typescript 2017-11-02 18:40:39 +01:00
package-lock.json Add --ignore as option 2022-04-08 04:39:17 +02:00
package.json Update links in package, add more explanation 2025-02-08 21:51:17 +01:00
README.md Update links in package, add more explanation 2025-02-08 21:51:17 +01:00
tsconfig.json Improve doctests 2022-03-25 15:47:14 +01:00
yarn.lock Add --ignore as option 2022-04-08 04:39:17 +02:00

doctest-ts-improved: doctests for TypeScript

Easy doctests for typescript modules, including private methods and extra imports:

export default class SomeClass {
    /**
     * Gets the field doubled
     * @example xyz
     *
     * import OtherClass from "./OtherClass";
     * 
     * // Should equal 42
     * SomeClass.get() // => 42
     *
     * SomeClass.get() + 1 // => 43
     * 
     * new OtherClass().doSomething(new SomeClass()) // => 5
     */
    private static get() : number{
        // a comment
        // @ts-ignore
        return 42
    }
}

Running doctest-ts-improved <directory> will create a copy of all .ts-files, containing the runner code. The new files will be named <original-filename>.doctest.ts. To ignore a (group of) files, add --ignore filename.ts or --ignore <directory>/*.ts. Multiple --ignore-flags can be given.

License

MIT