documentationjs / documentationjs/documentation
Add support for inlining external examples
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 481
- PR merge metrics
- No merged PRs in 30d
Description
This probably shouldn't be scoped to just @example, but that's my specific use case.
Basically, I've written examples in my source code comments, but as a result, I can't unit test them, lint them, etc, so they tend to have typos and whatnot.
src/constructable.js
``` JavaScript
/**
* @example
* <%= examples/constructable.js %>
*/
class Constructable {
}
```
examples/constructable.js
``` JavaScript
var constructed = new Constructable()
assert.instanceOf(constructed, Constructable);
```
which would produce the same output as
``` JavaScript
/**
* @example
* var constructed = new Constructable()
* assert.instanceOf(constructed, Constructable);
*/
class Constructable {
}
```
Right now, my plan is to solve this with a mix of documentationjs and grunt templating, but it would be great to see something like this natively in documentationjs (or via a plugin, if #70 gets traction).
Contributor guide
Assessment
This issue has not been assessed yet.