You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see two possible approaches. Both could probably be implemented via plugins(?) But I was wondering what the TypeDoc team thought and if any of them might get built-in support in the future. There could also be more approaches and/or tools that I’m not aware of.
Testing approach 1: include external code
async.ts:
/** * This function returns an iterable where each item was produced by applying * `mapperFn` to an item of `iterable`. * * @example * {@includeCode * ../../test/async-usage_test.ts#imports, * ../../test/async-usage_test.ts#example-map, * } */
/** * This function returns an iterable where each item was produced by applying * `mapperFn` to an item of `iterable`. * * @example * ```ts * import * as assert from 'assert/strict'; * import { AsyncIterable } from '@rauschma/iterable/async'; * const {toArray, fromIterable: fi} = AsyncIterable; * assert.deepEqual( * await toArray(AsyncIterable.map(x => x + x, fi(['a', 'b', 'c']))), * ['aa', 'bb', 'cc'] * ); * ``` */asyncfunction*map<In,Out>(mapperFn: (x: In)=>Out,iterable: AsyncOrSyncIterable<In>): AsyncIterable<Out>{forawait(constxofiterable){yieldmapperFn(x);}}
Processing:
Use TypeDoc to create a JSON file with the documentation data.
Personally, I prefer option 1. #2816 will make it possible, (though you'll need two @includeCode tags, and it uses VSCode's folding syntax)
The biggest disadvantage with option 2 for me is that that code isn't tied into the language server at all. findAllReferences won't find it, renaming won't find it. It won't be checked for typos (without a tool such as yours which parses it out and runs it)
Search terms
testing example code in doc comments
Question
I see two possible approaches. Both could probably be implemented via plugins(?) But I was wondering what the TypeDoc team thought and if any of them might get built-in support in the future. There could also be more approaches and/or tools that I’m not aware of.
Testing approach 1: include external code
async.ts
:async-usage_test.ts
:Testing approach 2: export to JSON, test Markdown
async.ts
:Processing:
The text was updated successfully, but these errors were encountered: