documentationjs / documentationjs/documentation

Add support for inlining external examples

Open
#348 3 comments 0 reactions 0 assignees View on GitHub
jsdoc-extension
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.