This processor will eventually replace the `{@example}` inline tags because it provides a cleaner approach that also supports tabbed examples straight out of the box. The idea is that authors will simply add a `path` and (optionally) a `region` attribute to `<code-example>` or `<code-pane>` elements in their docs. This indicates to dgeni that the relevant example needs to be injected into the content of this element. For example, assume that there is an example file `toh-pt1/index.hml` with a region called `title`, which looks like: ``` <h1>Tour of Heroes</h1> ``` Then the document author could get this to appear in the docs as a standalone example: ``` <code-example path="toh-pt1" region="title"></code-example> ``` Or as part of a tabbed group: ``` <code-tabs> <code-pane path="toh-pt1" region="title"></code-pane> </code-tabs> ``` If no `path` attribute is provided then the element is ignored, which enables authors to provide inline code instead: ``` <code-example> Some <html> escaped code </code-example> ``` Also all attributes other than `path` and `region` are ignored and passed through to the final rendered output allowing the author to provide styling hints: ``` <code-example path="toh-pt1" region="title" linenums"15" class="important"> </code-example> ```
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
var Package = require('dgeni').Package;
|
|
var jsdocPackage = require('dgeni-packages/jsdoc');
|
|
|
|
module.exports =
|
|
new Package('examples', [jsdocPackage])
|
|
|
|
.factory(require('./inline-tag-defs/example'))
|
|
// .factory(require('./inline-tag-defs/exampleTabs'))
|
|
.factory(require('./services/parseArgString'))
|
|
.factory(require('./services/example-map'))
|
|
.factory(require('./file-readers/example-reader'))
|
|
.factory(require('./services/region-parser'))
|
|
.factory(require('./services/getExampleRegion'))
|
|
|
|
.processor(require('./processors/collect-examples'))
|
|
.processor(require('./processors/render-examples'))
|
|
|
|
.config(function(readFilesProcessor, exampleFileReader) {
|
|
readFilesProcessor.fileReaders.push(exampleFileReader);
|
|
})
|
|
|
|
.config(function(inlineTagProcessor, exampleInlineTagDef) {
|
|
inlineTagProcessor.inlineTagDefinitions.push(exampleInlineTagDef);
|
|
// inlineTagProcessor.inlineTagDefinitions.push(exampleTabsInlineTagDef);
|
|
})
|
|
|
|
.config(function(computePathsProcessor) {
|
|
computePathsProcessor.pathTemplates.push(
|
|
{docTypes: ['example-region'], getPath: function() {}, getOutputPath: function() {}});
|
|
});
|