diff --git a/docs_app/package.json b/docs_app/package.json
index 0fb2d66da0..ff12895f9d 100644
--- a/docs_app/package.json
+++ b/docs_app/package.json
@@ -85,7 +85,6 @@
"css-selector-parser": "^1.3.0",
"dgeni": "^0.4.14",
"dgeni-packages": "^0.30.0",
- "entities": "^1.1.1",
"eslint": "^5.16.0",
"eslint-plugin-jasmine": "^2.2.0",
"firebase-tools": "^9.3.0",
diff --git a/docs_app/tools/transforms/README.md b/docs_app/tools/transforms/README.md
index 4a8d1738a3..edebd2d943 100644
--- a/docs_app/tools/transforms/README.md
+++ b/docs_app/tools/transforms/README.md
@@ -38,7 +38,6 @@ you are working on.
* angular-api-package
* angular-content-package
* content-package
-* examples-package
* links-package
* post-process-package
* remark-package
diff --git a/docs_app/tools/transforms/angular-api-package/index.js b/docs_app/tools/transforms/angular-api-package/index.js
index d69ed07add..294980b47a 100644
--- a/docs_app/tools/transforms/angular-api-package/index.js
+++ b/docs_app/tools/transforms/angular-api-package/index.js
@@ -12,6 +12,7 @@ const typeScriptPackage = require('dgeni-packages/typescript');
const { API_SOURCE_PATH, API_TEMPLATES_PATH, MARBLE_IMAGES_PATH, MARBLE_IMAGES_WEB_PATH,
requireFolder } = require('../config');
+// prettier-ignore
module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
// Register the processors
@@ -55,7 +56,7 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
})
// Where do we get the source files?
- .config(function(readTypeScriptModules, readFilesProcessor, collectExamples, tsParser) {
+ .config(function(readTypeScriptModules, readFilesProcessor, tsParser) {
// Tell TypeScript how to load modules that start with `@angular`
tsParser.options.paths = { '@angular/*': [API_SOURCE_PATH + '/*'] };
@@ -84,7 +85,6 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
fileReader: 'exampleFileReader'
}
];
- collectExamples.exampleFolders.push('examples');
})
// Configure jsdoc-style tag parsing
@@ -96,7 +96,6 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
// Additional jsdoc config (for RxJS source)
.config(function(parseTagsProcessor) {
- parseTagsProcessor.tagDefinitions.push({ name: 'example', aliases: ['examples'], multi: true, docProperty: 'examples' });
parseTagsProcessor.tagDefinitions.push({ name: 'owner' });
parseTagsProcessor.tagDefinitions.push({ name: 'static' });
parseTagsProcessor.tagDefinitions.push({ name: 'nocollapse' });
diff --git a/docs_app/tools/transforms/angular-base-package/index.js b/docs_app/tools/transforms/angular-base-package/index.js
index 1996bc57e5..71b616dbe0 100644
--- a/docs_app/tools/transforms/angular-base-package/index.js
+++ b/docs_app/tools/transforms/angular-base-package/index.js
@@ -11,18 +11,17 @@ const Package = require('dgeni').Package;
const jsdocPackage = require('dgeni-packages/jsdoc');
const nunjucksPackage = require('dgeni-packages/nunjucks');
const linksPackage = require('../links-package');
-const examplesPackage = require('../examples-package');
const targetPackage = require('../target-package');
const remarkPackage = require('../remark-package');
const postProcessPackage = require('dgeni-packages/post-process-html');
const { PROJECT_ROOT, CONTENTS_PATH, OUTPUT_PATH, DOCS_OUTPUT_PATH, TEMPLATES_PATH, AIO_PATH, requireFolder } = require('../config');
+// prettier-ignore
module.exports = new Package('angular-base', [
jsdocPackage,
nunjucksPackage,
linksPackage,
- examplesPackage,
targetPackage,
remarkPackage,
postProcessPackage,
@@ -60,14 +59,12 @@ module.exports = new Package('angular-base', [
})
// Where do we get the source files?
- .config(function (readFilesProcessor, collectExamples, generateKeywordsProcessor, jsonFileReader) {
+ .config(function (readFilesProcessor, generateKeywordsProcessor, jsonFileReader) {
readFilesProcessor.fileReaders.push(jsonFileReader);
readFilesProcessor.basePath = PROJECT_ROOT;
readFilesProcessor.sourceFiles = [];
- collectExamples.exampleFolders = [];
generateKeywordsProcessor.ignoreWordsFile = path.resolve(__dirname, 'ignore.words');
- generateKeywordsProcessor.docTypesToIgnore = ['example-region'];
generateKeywordsProcessor.propertiesToIgnore = ['renderedContent'];
})
@@ -125,12 +122,8 @@ module.exports = new Package('angular-base', [
getLinkInfo.useFirstAmbiguousLink = false;
})
- .config(function (computePathsProcessor, generateKeywordsProcessor) {
+ .config(function (generateKeywordsProcessor) {
generateKeywordsProcessor.outputFolder = 'app';
-
- // Replace any path templates inherited from other packages
- // (we want full and transparent control)
- computePathsProcessor.pathTemplates = [{ docTypes: ['example-region'], getOutputPath: function () {} }];
})
.config(function (postProcessHtml, addImageDimensions, autoLinkCode, filterPipes, filterAmbiguousDirectiveAliases, filterFromInImports, filterNeverAsGeneric) {
diff --git a/docs_app/tools/transforms/angular-base-package/rendering/indentForMarkdown.js b/docs_app/tools/transforms/angular-base-package/rendering/indentForMarkdown.js
deleted file mode 100644
index 3330114f04..0000000000
--- a/docs_app/tools/transforms/angular-base-package/rendering/indentForMarkdown.js
+++ /dev/null
@@ -1,62 +0,0 @@
-module.exports = function() {
- // var MIXIN_PATTERN = /\S*\+\S*\(.*/;
- return {
- name: 'indentForMarkdown',
- process: function(str, width) {
- if (str == null || str.length === 0) {
- return '';
- }
- width = width || 4;
-
- var lines = str.split('\n');
- var newLines = [];
- var sp = spaces(width);
- var spMixin = spaces(width - 2);
- var isAfterMarkdownTag = true;
- lines.forEach(function(line) {
- // indent lines that match mixin pattern by 2 less than specified width
- if (line.indexOf('{@example') >= 0) {
- if (isAfterMarkdownTag) {
- // happens if example follows example
- if (newLines.length > 0) {
- newLines.pop();
- } else {
- // weird case - first expression in str is an @example
- // in this case the :marked appear above the str passed in,
- // so we need to put 'something' into the markdown tag.
- newLines.push(sp + '.'); // '.' is a dummy char
- }
- }
- newLines.push(spMixin + line);
- // after a mixin line we need to reenter markdown.
- newLines.push(spMixin + ':marked');
- isAfterMarkdownTag = true;
- } else {
- if ((!isAfterMarkdownTag) || (line.trim().length > 0)) {
- newLines.push(sp + line);
- isAfterMarkdownTag = false;
- }
- }
- });
- if (isAfterMarkdownTag) {
- if (newLines.length > 0) {
- // if last line is a markdown tag remove it.
- newLines.pop();
- }
- }
- // force character to be a newLine.
- if (newLines.length > 0) newLines.push('');
- var res = newLines.join('\n');
- return res;
- }
- };
-
- function spaces(n) {
- var str = '';
- for (var i = 0; i < n; i++) {
- str += ' ';
- }
- return str;
- }
-
-};
diff --git a/docs_app/tools/transforms/angular.io-package/index.js b/docs_app/tools/transforms/angular.io-package/index.js
index bda70fb7ed..0d3b383cdc 100644
--- a/docs_app/tools/transforms/angular.io-package/index.js
+++ b/docs_app/tools/transforms/angular.io-package/index.js
@@ -13,6 +13,7 @@ const { extname, resolve } = require('canonical-path');
const { existsSync } = require('fs');
const { SRC_PATH } = require('../config');
+// prettier-ignore
module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPackage])
// This processor relies upon the versionInfo. See below...
@@ -27,7 +28,7 @@ module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPacka
renderDocsProcessor.extraData.versionInfo = versionInfo;
})
- .config(function(checkAnchorLinksProcessor, linkInlineTagDef, renderExamples) {
+ .config(function(checkAnchorLinksProcessor, linkInlineTagDef) {
// Fail the processing if there is an invalid link
linkInlineTagDef.failOnBadLink = false;
@@ -50,10 +51,6 @@ module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPacka
});
checkAnchorLinksProcessor.pathVariants = ['', '/', '.html', '/index.html', '#top-of-page'];
checkAnchorLinksProcessor.errorOnUnmatchedLinks = false;
-
- // Make sure we fail if the examples are not right
- renderExamples.ignoreBrokenExamples = false;
-
})
.config(function(renderLinkInfo, postProcessHtml) {
diff --git a/docs_app/tools/transforms/examples-package/file-readers/example-reader.js b/docs_app/tools/transforms/examples-package/file-readers/example-reader.js
deleted file mode 100644
index f7ff368675..0000000000
--- a/docs_app/tools/transforms/examples-package/file-readers/example-reader.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * The point of this reader is to tag all the files that are going to be used as examples in the
- * documentation.
- * Later on we can extract the regions, via "shredding"; and we can also construct runnable examples
- * for passing to Stackblitz and the like.
- */
-module.exports = function exampleFileReader() {
- return {
- name: 'exampleFileReader',
- getDocs: function(fileInfo) {
- return [{docType: 'example-file', content: fileInfo.content, startingLine: 1}];
- }
- };
-};
diff --git a/docs_app/tools/transforms/examples-package/index.js b/docs_app/tools/transforms/examples-package/index.js
deleted file mode 100644
index 5704d7d333..0000000000
--- a/docs_app/tools/transforms/examples-package/index.js
+++ /dev/null
@@ -1,28 +0,0 @@
-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('./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);
- })
-
- .config(function(computePathsProcessor) {
- computePathsProcessor.pathTemplates.push(
- {docTypes: ['example-region'], getPath: function() {}, getOutputPath: function() {}});
- });
diff --git a/docs_app/tools/transforms/examples-package/inline-tag-defs/example.js b/docs_app/tools/transforms/examples-package/inline-tag-defs/example.js
deleted file mode 100644
index 5a2093207b..0000000000
--- a/docs_app/tools/transforms/examples-package/inline-tag-defs/example.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var entities = require('entities');
-
-/**
- * @dgService exampleInlineTagDef
- * @description
- * Process inline example tags (of the form {@example relativePath region -title='some title'
- * -stylePattern='{some style pattern}' }),
- * replacing them with code from a shredded file
- * Examples:
- * {@example core/application_spec.ts hello-app -title='Sample component' }
- * {@example core/application_spec.ts -region=hello-app -title='Sample component' }
- * @kind function
- */
-module.exports = function exampleInlineTagDef(parseArgString, createDocMessage, getExampleRegion) {
- return {
- name: 'example',
- description:
- 'Process inline example tags (of the form {@example some/uri Some Title}), replacing them with HTML anchors',
-
-
- handler: function(doc, tagName, tagDescription) {
- var tagArgs = parseArgString(entities.decodeHTML(tagDescription));
- var unnamedArgs = tagArgs._;
- var relativePath = unnamedArgs[0];
- var regionName = tagArgs.region || (unnamedArgs.length > 1 ? unnamedArgs[1] : '');
- if (regionName === '\'\'') regionName = '';
- var title = tagArgs.title || (unnamedArgs.length > 2 ? unnamedArgs.slice(2).join(' ') : null);
- var linenums = tagArgs.linenums;
- // var stylePattern = tagArgs.stylePattern; // TODO: not yet implemented here
-
- const sourceCode = getExampleRegion(doc, relativePath, regionName);
-
- const attributes = [];
- if (title) attributes.push(` title="${title}"`);
- if (linenums !== undefined) attributes.push(` linenums="${linenums}"`);
-
- return '\n' + sourceCode + '\n';
- }
- };
-};
-
diff --git a/docs_app/tools/transforms/examples-package/inline-tag-defs/example.spec.js b/docs_app/tools/transforms/examples-package/inline-tag-defs/example.spec.js
deleted file mode 100644
index ec506b2c6c..0000000000
--- a/docs_app/tools/transforms/examples-package/inline-tag-defs/example.spec.js
+++ /dev/null
@@ -1,69 +0,0 @@
-var testPackage = require('../../helpers/test-package');
-var Dgeni = require('dgeni');
-
-describe('example inline-tag-def', function() {
- let injector, tag, collectExamples, exampleMap;
-
- beforeEach(() => {
- const dgeni = new Dgeni([testPackage('examples-package', true)]);
- injector = dgeni.configureInjector();
- tag = injector.get('exampleInlineTagDef');
- collectExamples = injector.get('collectExamples');
- exampleMap = injector.get('exampleMap');
- });
-
- it('should be available as a service', () => {
- expect(tag).toBeDefined();
- expect(tag.name).toEqual('example');
- });
-
- describe('handler', () => {
- let handler;
-
- beforeEach(() => {
- handler = tag.handler;
- collectExamples.exampleFolders = ['examples'];
- exampleMap['examples'] = {
- 'test/url': { regions: {
- '': { renderedContent: 'whole file' },
- 'region-1': { renderedContent: 'region 1 contents' }
- } }
- };
- });
-
- it('should throw an error if there is no matching example', () => {
- expect(function() {
- handler({}, 'example', 'missing/uri');
- }).toThrowError();
-
- expect(function() {
- handler({}, 'example', 'test/url missing-region');
- }).toThrowError();
- });
-
- it('should contain the whole contents from the example file if no region is specified', () => {
- expect(handler({}, 'example', 'test/url')).toEqual('\nwhole file\n');
- });
-
- it('should contain the region contents from the example file if a region is specified', () => {
- expect(handler({}, 'example', 'test/url region-1')).toEqual('\nregion 1 contents\n');
- });
-
- it('should add a title if specified', () => {
- expect(handler({}, 'example', 'test/url region-1 \'Some Title\'')).toEqual('\nregion 1 contents\n');
- expect(handler({}, 'example', 'test/url region-1 Some Title')).toEqual('\nregion 1 contents\n');
- });
-
- it('should contain the whole contents from the example file if an empty ("") region is specified', () => {
- expect(handler({}, 'example', 'test/url \'\'')).toEqual('\nwhole file\n');
- expect(handler({}, 'example', 'test/url \'\' Some Title')).toEqual('\nwhole file\n');
- });
-
- it('should add in linenum attribute if specified', () => {
- expect(handler({}, 'example', 'test/url --linenums=\'false\'')).toEqual('\nwhole file\n');
- expect(handler({}, 'example', 'test/url --linenums=\'true\'')).toEqual('\nwhole file\n');
- expect(handler({}, 'example', 'test/url --linenums=\'15\'')).toEqual('\nwhole file\n');
- });
- });
-});
-
diff --git a/docs_app/tools/transforms/examples-package/processors/collect-examples.js b/docs_app/tools/transforms/examples-package/processors/collect-examples.js
deleted file mode 100644
index fd573381e4..0000000000
--- a/docs_app/tools/transforms/examples-package/processors/collect-examples.js
+++ /dev/null
@@ -1,96 +0,0 @@
-const {extname} = require('canonical-path');
-const {mapObject} = require('../../helpers/utils');
-
-module.exports = function collectExamples(exampleMap, regionParser, log, createDocMessage) {
- return {
- $runAfter: ['files-read'],
- $runBefore: ['parsing-tags'],
- $validate: {exampleFolders: {presence: true}},
- exampleFolders: [],
- ignoredExamples: {},
- /**
- * Call this method to indicate to the processor that some files, that actually exist,
- * have been filtered out from being processed.
- * @param paths an array of relative paths to the examples that have been ignored.
- * @param gitIgnorePath the path to the gitignore file that caused this example to be ignored.
- */
- registerIgnoredExamples(paths, gitIgnorePath) {
- paths.forEach(path => { this.ignoredExamples[path] = gitIgnorePath; });
- },
- /**
- * Call this method to find out if an example was ignored.
- * @param path a relative path to the example file to test for being ignored.
- * @returns the path to the .gitignore file.
- */
- isExampleIgnored(path) {
- return this.ignoredExamples[path];
- },
- $process(docs) {
- const exampleFolders = this.exampleFolders;
- exampleFolders.forEach(folder => exampleMap[folder] = exampleMap[folder] || {});
- const regionDocs = [];
- docs = docs.filter((doc) => {
- if (doc.docType === 'example-file') {
- try {
- // find the first matching folder
- exampleFolders.some((folder) => {
- if (doc.fileInfo.relativePath.indexOf(folder) === 0) {
- const relativePath =
- doc.fileInfo.relativePath.substr(folder.length).replace(/^\//, '');
- exampleMap[folder][relativePath] = doc;
-
- // We treat files that end in `.annotated` specially
- // They are used to annotate files that cannot contain comments, such as JSON
- // So you provide two files: `xyz.json` and `xyz.json.annotated`, which is a copy
- // of the original but contains inline doc region comments
- let fileType = doc.fileInfo.extension;
- if (fileType === 'annotated') {
- fileType = extname(doc.fileInfo.baseName).substr(1) + '.' + fileType;
- }
-
- const parsedRegions = regionParser(doc.content, fileType);
-
- log.debug(
- 'found example file', folder, relativePath, Object.keys(parsedRegions.regions));
-
- doc.renderedContent = parsedRegions.contents;
-
- // Map each region into a doc that can be put through the rendering pipeline
- doc.regions = mapObject(parsedRegions.regions, (regionName, regionContents) => {
- const regionDoc =
- createRegionDoc(folder, relativePath, regionName, regionContents);
- regionDocs.push(regionDoc);
- return regionDoc;
- });
-
- return true;
- }
- });
-
- return false;
-
- } catch (e) {
- throw new Error(createDocMessage(e.message, doc, e));
- }
- } else {
- return true;
- }
- });
-
- return docs.concat(regionDocs);
- }
- };
-};
-
-function createRegionDoc(folder, relativePath, regionName, regionContents) {
- const path = folder + '/' + relativePath;
- const id = path + '#' + regionName;
- return {
- docType: 'example-region',
- path: path,
- name: regionName,
- id: id,
- aliases: [id],
- contents: regionContents
- };
-}
diff --git a/docs_app/tools/transforms/examples-package/processors/collect-examples.spec.js b/docs_app/tools/transforms/examples-package/processors/collect-examples.spec.js
deleted file mode 100644
index cfb18509dd..0000000000
--- a/docs_app/tools/transforms/examples-package/processors/collect-examples.spec.js
+++ /dev/null
@@ -1,213 +0,0 @@
-var testPackage = require('../../helpers/test-package');
-var Dgeni = require('dgeni');
-var path = require('path');
-
-describe('collectExampleRegions processor', () => {
- var injector, processor, exampleMap, regionParser;
-
- beforeEach(function() {
-
- regionParser = jasmine.createSpy('regionParser').and.callFake(function(contents, extension) {
- return { contents: 'PARSED:' + contents, regions: {dummy: extension} };
- });
-
- const dgeni =
- new Dgeni([testPackage('examples-package', true).factory('regionParser', function() {
- return regionParser;
- })]);
-
- injector = dgeni.configureInjector();
- exampleMap = injector.get('exampleMap');
- processor = injector.get('collectExamples');
-
- processor.exampleFolders = ['examples-1', 'examples-2'];
- });
-
- describe('$process', () => {
-
- it('should initialise the `exampleMap` even if there are no examples to collect', () => {
- processor.$process([]);
- expect(exampleMap['examples-1']).toEqual(jasmine.any(Object));
- expect(exampleMap['examples-2']).toEqual(jasmine.any(Object));
- });
-
- it('should identify example files that are in the exampleFolders', () => {
- const docs = [
- createDoc('A', 'examples-1/x/app.js'), createDoc('B', 'examples-1/y/index.html'),
- createDoc('C', 'examples-2/s/app.js'), createDoc('D', 'examples-2/t/style.css'),
- createDoc('E', 'other/b/c.js')
- ];
-
- processor.$process(docs);
-
- expect(exampleMap['examples-1']['x/app.js']).toBeDefined();
- expect(exampleMap['examples-1']['y/index.html']).toBeDefined();
- expect(exampleMap['examples-2']['s/app.js']).toBeDefined();
- expect(exampleMap['examples-2']['t/style.css']).toBeDefined();
-
- expect(exampleMap['other']).toBeUndefined();
- });
-
- it('should remove example files from the docs collection', () => {
- const docs = [
- createDoc('Example A', 'examples-1/x/app.js'),
- createDoc('Example B', 'examples-1/y/index.html'),
- createDoc('Other doc 1', 'examples-2/t/style.css', 'content'),
- createDoc('Example C', 'examples-2/s/app.js'),
- createDoc('Other doc 2', 'other/b/c.js', 'content')
- ];
-
- const processedDocs = processor.$process(docs);
-
- expect(processedDocs.filter(doc => doc.docType === 'example-file')).toEqual([]);
- });
-
- it('should not remove docs from the docs collection that are not example files', () => {
- const docs = [
- createDoc('Example A', 'examples-1/x/app.js'),
- createDoc('Example B', 'examples-1/y/index.html'),
- createDoc('Other doc 1', 'examples-2/t/style.css', 'content'),
- createDoc('Example C', 'examples-2/s/app.js'),
- createDoc('Other doc 2', 'other/b/c.js', 'content')
- ];
-
- const processedDocs = processor.$process(docs);
-
- expect(processedDocs.filter(doc => doc.docType !== 'example-file'))
- .toEqual(jasmine.objectContaining([
- createDoc('Other doc 1', 'examples-2/t/style.css', 'content'),
- createDoc('Other doc 2', 'other/b/c.js', 'content')
- ]));
- });
-
- it('should call `regionParser` from with the content and file extension of each example doc',
- () => {
- const docs = [
- createDoc('Example A', 'examples-1/x/app.js'),
- createDoc('Example B', 'examples-1/y/index.html'),
- createDoc('Other doc 1', 'examples-2/t/style.css', 'content'),
- createDoc('Example C', 'examples-2/s/app.js'),
- createDoc('Other doc 2', 'other/b/c.js', 'content')
- ];
-
- processor.$process(docs);
-
- expect(regionParser).toHaveBeenCalledTimes(3);
- expect(regionParser).toHaveBeenCalledWith('Example A', 'js');
- expect(regionParser).toHaveBeenCalledWith('Example B', 'html');
- expect(regionParser).toHaveBeenCalledWith('Example C', 'js');
- });
-
-
- it('should attach parsed content as renderedContent to the example file docs', () => {
- const docs = [
- createDoc('A', 'examples-1/x/app.js'),
- createDoc('B', 'examples-1/y/index.html'),
- createDoc('C', 'examples-2/s/app.js'),
- createDoc('D', 'examples-2/t/style.css'),
- ];
-
- processor.$process(docs);
-
- expect(exampleMap['examples-1']['x/app.js'].renderedContent).toEqual('PARSED:A');
- expect(exampleMap['examples-1']['y/index.html'].renderedContent).toEqual('PARSED:B');
- expect(exampleMap['examples-2']['s/app.js'].renderedContent).toEqual('PARSED:C');
- expect(exampleMap['examples-2']['t/style.css'].renderedContent).toEqual('PARSED:D');
-
- });
-
- it('should create region docs for each region in the example file docs', () => {
- const docs = [
- createDoc('/* #docregion X */\nA', 'examples-1/x/app.js'),
- createDoc('\nB', 'examples-1/y/index.html'),
- createDoc('/* #docregion Z */\nC', 'examples-2/t/style.css'),
- ];
-
- const newDocs = processor.$process(docs);
-
- expect(newDocs.length).toEqual(3);
- expect(newDocs).toEqual([
- jasmine.objectContaining({
- docType: 'example-region',
- name: 'dummy',
- id: 'examples-1/x/app.js#dummy',
- contents: 'js'
- }),
- jasmine.objectContaining({
- docType: 'example-region',
- name: 'dummy',
- id: 'examples-1/y/index.html#dummy',
- contents: 'html'
- }),
- jasmine.objectContaining({
- docType: 'example-region',
- name: 'dummy',
- id: 'examples-2/t/style.css#dummy',
- contents: 'css'
- })
- ]);
- });
-
- it('should attach region docs to the example file docs', () => {
- const docs = [
- createDoc('/* #docregion X */\nA', 'examples-1/x/app.js'),
- createDoc('\nB', 'examples-1/y/index.html'),
- createDoc('/* #docregion Z */\nC', 'examples-2/t/style.css'),
- ];
-
- processor.$process(docs);
-
- expect(exampleMap['examples-1']['x/app.js'].regions).toEqual({
- dummy: {
- docType: 'example-region',
- path: 'examples-1/x/app.js',
- name: 'dummy',
- id: 'examples-1/x/app.js#dummy',
- aliases: ['examples-1/x/app.js#dummy'],
- contents: 'js'
- }
- });
- expect(exampleMap['examples-1']['y/index.html'].regions).toEqual({
- dummy: {
- docType: 'example-region',
- path: 'examples-1/y/index.html',
- name: 'dummy',
- id: 'examples-1/y/index.html#dummy',
- aliases: ['examples-1/y/index.html#dummy'],
- contents: 'html'
- }
- });
- expect(exampleMap['examples-2']['t/style.css'].regions).toEqual({
- dummy: {
- docType: 'example-region',
- path: 'examples-2/t/style.css',
- name: 'dummy',
- id: 'examples-2/t/style.css#dummy',
- aliases: ['examples-2/t/style.css#dummy'],
- contents: 'css'
- }
- });
- });
- });
-
- describe('filtered examples', () => {
- it('should indicate if an example was filtered', () => {
- processor.registerIgnoredExamples(['c/d/e', 'e/f/g'], 'path/to/gitignore');
- processor.registerIgnoredExamples(['x/y/z'], 'path/to/other/gitignore');
- expect(processor.isExampleIgnored('a/b/c')).toBeFalsy();
- expect(processor.isExampleIgnored('c/d/e')).toEqual('path/to/gitignore');
- expect(processor.isExampleIgnored('e/f/g')).toEqual('path/to/gitignore');
- expect(processor.isExampleIgnored('x/y/z')).toEqual('path/to/other/gitignore');
- });
- });
-});
-
-
-function createDoc(content, relativePath, docType) {
- return {
- fileInfo: {relativePath: relativePath, extension: path.extname(relativePath).substr(1)},
- content: content,
- docType: docType || 'example-file',
- startingLine: 1
- };
-}
diff --git a/docs_app/tools/transforms/examples-package/processors/render-examples.js b/docs_app/tools/transforms/examples-package/processors/render-examples.js
deleted file mode 100644
index b90d5763f1..0000000000
--- a/docs_app/tools/transforms/examples-package/processors/render-examples.js
+++ /dev/null
@@ -1,64 +0,0 @@
-const { parseAttributes, renderAttributes } = require('../../helpers/utils');
-
-/**
- * Search the renderedContent looking for code examples that have a path (and optionally a region) attribute.
- * When they are found replace their content with the appropriate doc-region parsed previously from an example file.
- */
-module.exports = function renderExamples(getExampleRegion, log, createDocMessage) {
- return {
- $runAfter: ['docs-rendered'],
- $runBefore: ['writing-files'],
- ignoreBrokenExamples: false,
- $process: function(docs) {
- docs.forEach(doc => {
- if (doc.renderedContent) {
- // We match either `code-example` or `code-pane` elements that have a path attribute
- doc.renderedContent = doc.renderedContent.replace(
- /<(code-example|code-pane)([^>]*)>[^<]*<\/([^>]+)>/g,
- (original, openingTag, attributes, closingTag) => {
- const attrMap = parseAttributes(attributes);
- if (attrMap.path) {
- try {
- if (closingTag !== openingTag) {
- // The markdown renderer will wrap what it thinks is a paragraph in `
` and `
` tags.
- // If you do not leave a blank line between a paragraph of text and a `` then
- // the markdown renderer may add a paragraph marker "in-between" the opening and closing
- // tags of the code-example. For example:
- //
- // ```
- // Some paragraph
- //
- //
- //
- // ```
- //
- // will be rendered as:
- //
- // ```
- // Some paragraph
- //
- //
- //
- // ```
- throw new Error(
- 'Badly formed example: ' + original + ' - closing tag does not match opening tag.\n' +
- ' - Perhaps you forgot to put a blank line before the example?');
- }
- // We found a path attribute so look up the example and rebuild the HTML
- const exampleContent = getExampleRegion(doc, attrMap.path, attrMap.region);
- return `<${openingTag}${renderAttributes(attrMap)}>\n${exampleContent}\n${openingTag}>`;
- } catch(e) {
- log.warn(createDocMessage(e.message, doc));
- if (!this.ignoreBrokenExamples) {
- throw e;
- }
- }
- }
- // No path attribute so just ignore this one
- return original;
- });
- }
- });
- }
- };
-};
diff --git a/docs_app/tools/transforms/examples-package/processors/render-examples.spec.js b/docs_app/tools/transforms/examples-package/processors/render-examples.spec.js
deleted file mode 100644
index 2fdf0bab9b..0000000000
--- a/docs_app/tools/transforms/examples-package/processors/render-examples.spec.js
+++ /dev/null
@@ -1,122 +0,0 @@
-var testPackage = require('../../helpers/test-package');
-var Dgeni = require('dgeni');
-
-describe('renderExamples processor', () => {
- var injector, processor, exampleMap, collectExamples, log;
-
- beforeEach(function() {
- const dgeni = new Dgeni([testPackage('examples-package', true)]);
- injector = dgeni.configureInjector();
-
- exampleMap = injector.get('exampleMap');
- processor = injector.get('renderExamples');
- collectExamples = injector.get('collectExamples');
- exampleMap = injector.get('exampleMap');
- log = injector.get('log');
-
- collectExamples.exampleFolders = ['examples'];
- exampleMap['examples'] = {
- 'test/url': { regions: {
- '': { renderedContent: 'whole file' },
- 'region-1': { renderedContent: 'region 1 contents' }
- } }
- };
- });
-
- it('should run before the correct processor', () => {
- expect(processor.$runBefore).toEqual(['writing-files']);
- });
-
- it('should run after the correct processor', () => {
- expect(processor.$runAfter).toEqual(['docs-rendered']);
- });
-
- ['code-example', 'code-pane'].forEach(CODE_TAG =>
- describe(CODE_TAG, () => {
- it(`should ignore a <${CODE_TAG}> tags with no path attribute`, () => {
- const docs = [
- { renderedContent: `Some text\n<${CODE_TAG}>Some code${CODE_TAG}>\n<${CODE_TAG} class="anti-pattern" title="Bad Code">do not do this${CODE_TAG}>` }
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`Some text\n<${CODE_TAG}>Some code${CODE_TAG}>\n<${CODE_TAG} class="anti-pattern" title="Bad Code">do not do this${CODE_TAG}>`);
- });
-
- it(`should replace the content of the <${CODE_TAG}> tag with the whole contents from an example file if a path is provided`, () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url">Some code${CODE_TAG}>`}
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`<${CODE_TAG} path="test/url">\nwhole file\n${CODE_TAG}>`);
- });
-
- it(`should replace all instances of <${CODE_TAG}> tags`, () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url">Some code${CODE_TAG}><${CODE_TAG} path="test/url" region="region-1">Other code${CODE_TAG}>`}
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`<${CODE_TAG} path="test/url">\nwhole file\n${CODE_TAG}><${CODE_TAG} path="test/url" region="region-1">\nregion 1 contents\n${CODE_TAG}>`);
- });
-
- it('should contain the region contents from the example file if a region is specified', () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url" region="region-1">Some code${CODE_TAG}>` }
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`<${CODE_TAG} path="test/url" region="region-1">\nregion 1 contents\n${CODE_TAG}>`);
- });
-
- it(`should replace the content of the <${CODE_TAG}> tag with the whole contents from an example file if the region is empty`, () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url" region="">Some code${CODE_TAG}>` }
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`<${CODE_TAG} path="test/url" region="">\nwhole file\n${CODE_TAG}>`);
- });
-
- it('should pass along all attributes including path and region', () => {
- const openTag = `<${CODE_TAG} class="special" path="test/url" linenums="15" region="region-1" id="some-id">`;
-
- const docs = [ { renderedContent: `${openTag}Some code${CODE_TAG}>` }
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`${openTag}\nregion 1 contents\n${CODE_TAG}>`);
- });
-
- it('should cope with spaces and double quotes inside attribute values', () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} title='a "quoted" value' path="test/url">${CODE_TAG}>`}
- ];
- processor.$process(docs);
- expect(docs[0].renderedContent).toEqual(`<${CODE_TAG} title="a "quoted" value" path="test/url">\nwhole file\n${CODE_TAG}>`);
- });
-
- it('should throw an exception if the code-example tag is not closed correctly', () => {
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url">${CODE_TAG}>`}
- ];
- expect(() => processor.$process(docs)).toThrowError(
- 'Badly formed example: <' + CODE_TAG + ' path="test/url"> - closing tag does not match opening tag.\n' +
- ' - Perhaps you forgot to put a blank line before the example?');
- });
-
- it('should not throw if `ignoreBrokenExamples` is set to true', () => {
- processor.ignoreBrokenExamples = true;
- const docs = [
- { renderedContent: `<${CODE_TAG} path="test/url">${CODE_TAG}>`},
- { renderedContent: `<${CODE_TAG} path="test/url" region="missing">${CODE_TAG}>`},
- { renderedContent: `<${CODE_TAG} path="missing/url">${CODE_TAG}>`}
- ];
- expect(() => processor.$process(docs)).not.toThrow();
- expect(log.warn).toHaveBeenCalledWith(
- 'Badly formed example: <' + CODE_TAG + ' path="test/url"> - closing tag does not match opening tag.\n' +
- ' - Perhaps you forgot to put a blank line before the example? - doc');
- expect(log.warn).toHaveBeenCalledWith(
- 'Missing example region... relativePath: "test/url", region: "missing". - doc\n' +
- 'Regions available are: "", "region-1" - doc');
- expect(log.warn).toHaveBeenCalledWith(
- 'Missing example file... relativePath: "missing/url". - doc\n' +
- 'Example files can be found in the following relative paths: "examples" - doc');
- });
- })
- );
-});
diff --git a/docs_app/tools/transforms/examples-package/services/example-map.js b/docs_app/tools/transforms/examples-package/services/example-map.js
deleted file mode 100644
index 86e8614d65..0000000000
--- a/docs_app/tools/transforms/examples-package/services/example-map.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = function exampleMap() {
- return {};
-};
diff --git a/docs_app/tools/transforms/examples-package/services/getExampleRegion.js b/docs_app/tools/transforms/examples-package/services/getExampleRegion.js
deleted file mode 100644
index ebf09c241f..0000000000
--- a/docs_app/tools/transforms/examples-package/services/getExampleRegion.js
+++ /dev/null
@@ -1,38 +0,0 @@
-module.exports = function getExampleRegion(exampleMap, createDocMessage, collectExamples) {
- return function getExampleRegionImpl(doc, relativePath, regionName) {
- const EXAMPLES_FOLDERS = collectExamples.exampleFolders;
-
- // Find the example in the folders
- var exampleFile;
- // Try an "annotated" version first
- EXAMPLES_FOLDERS.some(EXAMPLES_FOLDER => { return exampleFile = exampleMap[EXAMPLES_FOLDER][relativePath + '.annotated']; });
-
- // If no annotated version is available then try the actual file
- if (!exampleFile) {
- EXAMPLES_FOLDERS.some(EXAMPLES_FOLDER => { return exampleFile = exampleMap[EXAMPLES_FOLDER][relativePath]; });
- }
-
- // If still no file then we error
- if (!exampleFile) {
- const gitIgnoreFile = collectExamples.isExampleIgnored(relativePath);
- if( gitIgnoreFile) {
- const message = createDocMessage('Ignored example file... relativePath: "' + relativePath + '"', doc) + '\n' +
- 'This example file exists but has been ignored by a rule, in "' + gitIgnoreFile + '".';
- throw new Error(message);
- } else {
- const message = createDocMessage('Missing example file... relativePath: "' + relativePath + '".', doc) + '\n' +
- 'Example files can be found in the following relative paths: ' + EXAMPLES_FOLDERS.map(function(folder) { return '"' + folder + '"'; }).join(', ');
- throw new Error(message);
- }
- }
-
- var sourceCodeDoc = exampleFile.regions[regionName || ''];
- if (!sourceCodeDoc) {
- const message = createDocMessage('Missing example region... relativePath: "' + relativePath + '", region: "' + regionName + '".', doc) + '\n' +
- 'Regions available are: ' + Object.keys(exampleFile.regions).map(function(region) { return '"' + region + '"'; }).join(', ');
- throw new Error(message);
- }
-
- return sourceCodeDoc.renderedContent;
- };
-};
diff --git a/docs_app/tools/transforms/examples-package/services/getExampleRegion.spec.js b/docs_app/tools/transforms/examples-package/services/getExampleRegion.spec.js
deleted file mode 100644
index ba42d11805..0000000000
--- a/docs_app/tools/transforms/examples-package/services/getExampleRegion.spec.js
+++ /dev/null
@@ -1,46 +0,0 @@
-var testPackage = require('../../helpers/test-package');
-var Dgeni = require('dgeni');
-
-describe('getExampleRegion', () => {
- var dgeni, injector, getExampleRegion, collectExamples, exampleMap;
-
- beforeEach(function() {
- dgeni = new Dgeni([testPackage('examples-package', true)]);
- injector = dgeni.configureInjector();
- getExampleRegion = injector.get('getExampleRegion');
- collectExamples = injector.get('collectExamples');
- exampleMap = injector.get('exampleMap');
- collectExamples.exampleFolders = ['examples'];
- collectExamples.registerIgnoredExamples(['filtered/path'], 'some/gitignore');
- exampleMap['examples'] = {
- 'test/url': { regions: {
- '': { renderedContent: 'whole file' },
- 'region-1': { renderedContent: 'region 1 contents' }
- } }
- };
- });
-
- it('should contain the whole contents from the example file if no region is specified', () => {
- expect(getExampleRegion({}, 'test/url')).toEqual('whole file');
- });
-
- it('should contain the region contents from the example file if a region is specified', () => {
- expect(getExampleRegion({}, 'test/url', 'region-1')).toEqual('region 1 contents');
- });
-
- it('should throw an error if an example doesn\'t exist', () => {
- expect(() => {
- getExampleRegion({}, 'missing/file', 'region-1');
- }).toThrowError('Missing example file... relativePath: "missing/file". - doc\nExample files can be found in the following relative paths: "examples"');
- expect(() => {
- getExampleRegion({}, 'test/url', 'missing-region');
- }).toThrowError('Missing example region... relativePath: "test/url", region: "missing-region". - doc\nRegions available are: "", "region-1"');
- });
-
- it('should throw an error if an example has been filtered out', () => {
- expect(() => {
- getExampleRegion({}, 'filtered/path', 'any-region');
- }).toThrowError('Ignored example file... relativePath: "filtered/path" - doc\n' +
- 'This example file exists but has been ignored by a rule, in "some/gitignore".');
- });
-});
diff --git a/docs_app/tools/transforms/examples-package/services/parseArgString.js b/docs_app/tools/transforms/examples-package/services/parseArgString.js
deleted file mode 100644
index fc06ae3198..0000000000
--- a/docs_app/tools/transforms/examples-package/services/parseArgString.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @dgService parseArgString
- * @description
- * processes an arg string in 'almost' the same fashion that the command processor does
- * and returns an args object in yargs format.
- * @kind function
- * @param {String} str The arg string to process
- * @return {Object} The args parsed into a yargs format.
- */
-
-module.exports = function parseArgString() {
-
- return function parseArgStringImpl(str) {
- // regex from npm string-argv
- //[^\s'"] Match if not a space ' or "
-
- //+|['] or Match '
- //([^']*) Match anything that is not '
- //['] Close match if '
-
- //+|["] or Match "
- //([^"]*) Match anything that is not "
- //["] Close match if "
- var rx = /[^\s'"]+|[']([^']*?)[']|["]([^"]*?)["]/gi;
- var value = str;
- var unnamedArgs = [];
- var args = {_: unnamedArgs};
- var match, key;
- do {
- // Each call to exec returns the next regex match as an array
- match = rx.exec(value);
- if (match !== null) {
- // Index 1 in the array is the captured group if it exists
- // Index 0 is the matched text, which we use if no captured group exists
- var arg = match[2] ? match[2] : (match[1] ? match[1] : match[0]);
- if (key) {
- args[key] = arg;
- key = null;
- } else {
- if (arg.substr(arg.length - 1) === '=') {
- key = arg.substr(0, arg.length - 1);
- // remove leading '-' (or '--') if it exists.
- if (key.substr(0, 1) == '-') {
- key = key.substr(1);
- }
- if (key.substr(0, 1) == '-') {
- key = key.substr(1);
- }
- } else {
- unnamedArgs.push(arg);
- key = null;
- }
- }
- }
- } while (match !== null);
- return args;
- };
-};
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.js b/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.js
deleted file mode 100644
index d7464a6460..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// These kind of comments are used CSS and other languages that do not support inline comments
-module.exports = {
- regionStartMatcher: /^\s*\/\*\s*#docregion\s*(.*)\s*\*\/\s*$/,
- regionEndMatcher: /^\s*\/\*\s*#enddocregion\s*(.*)\s*\*\/\s*$/,
- plasterMatcher: /^\s*\/\*\s*#docplaster\s*(.*)\s*\*\/\s*$/,
- createPlasterComment: plaster => `/* ${plaster} */`
-};
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.spec.js b/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.spec.js
deleted file mode 100644
index 68d24e4542..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/block-c.spec.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const matcher = require('./block-c');
-
-describe('block-c region-matcher', () => {
- it('should match start annotations', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('/* #docregion A b c */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c ');
-
- matches = matcher.regionStartMatcher.exec('/*#docregion A b c*/');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('/* #docregion */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match end annotations', () => {
- let matches;
-
- matches = matcher.regionEndMatcher.exec('/* #enddocregion A b c */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c ');
-
- matches = matcher.regionEndMatcher.exec('/*#enddocregion A b c*/');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('/* #enddocregion */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match plaster annotations', () => {
- let matches;
-
- matches = matcher.plasterMatcher.exec('/* #docplaster A b c */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c ');
-
- matches = matcher.plasterMatcher.exec('/*#docplaster A b c*/');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('/* #docplaster */');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should create a plaster comment', () => {
- expect(matcher.createPlasterComment('... elided ...')).toEqual('/* ... elided ... */');
- });
-});
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/html.js b/docs_app/tools/transforms/examples-package/services/region-matchers/html.js
deleted file mode 100644
index 4528c10750..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/html.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// These kind of comments are used in HTML
-module.exports = {
- regionStartMatcher: /^\s*)?\s*$/,
- regionEndMatcher: /^\s*\s*$/,
- plasterMatcher: /^\s*\s*$/,
- createPlasterComment: plaster => ``
-};
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/html.spec.js b/docs_app/tools/transforms/examples-package/services/region-matchers/html.spec.js
deleted file mode 100644
index 9764b16a73..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/html.spec.js
+++ /dev/null
@@ -1,63 +0,0 @@
-const matcher = require('./html');
-
-describe('html region-matcher', () => {
- it('should match start annotations', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match end annotations', () => {
- let matches;
-
- matches = matcher.regionEndMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should handle annotations that do not close the comment on the same line', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should create a plaster comment', () => {
- expect(matcher.createPlasterComment('... elided ...')).toEqual('');
- });
-});
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.js
deleted file mode 100644
index 90b1d8d9ba..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// These kind of comments are used in languages that do not support block comments, such as Jade
-module.exports = {
- regionStartMatcher: /^\s*\/\/\s*#docregion\s*(.*)\s*$/,
- regionEndMatcher: /^\s*\/\/\s*#enddocregion\s*(.*)\s*$/,
- plasterMatcher: /^\s*\/\/\s*#docplaster\s*(.*)\s*$/,
- createPlasterComment: plaster => `// ${plaster}`
-};
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.spec.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.spec.js
deleted file mode 100644
index b3a8cb694a..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c-only.spec.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const matcher = require('./inline-c-only');
-
-describe('inline-c-only region-matcher', () => {
- it('should match start annotations', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('// #docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('//#docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('// #docregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match end annotations', () => {
- let matches;
-
- matches = matcher.regionEndMatcher.exec('// #enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('//#enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('// #enddocregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match plaster annotations', () => {
- let matches;
-
- matches = matcher.plasterMatcher.exec('// #docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('//#docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('// #docplaster');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should create a plaster comment', () => {
- expect(matcher.createPlasterComment('... elided ...')).toEqual('// ... elided ...');
- });
-});
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.js
deleted file mode 100644
index 2c4dc870b3..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// This comment type is used in C like languages such as JS, TS, Dart, etc
-module.exports = {
- regionStartMatcher: /^\s*\/\/\s*#docregion\s*(.*)\s*$/,
- regionEndMatcher: /^\s*\/\/\s*#enddocregion\s*(.*)\s*$/,
- plasterMatcher: /^\s*\/\/\s*#docplaster\s*(.*)\s*$/,
- createPlasterComment: plaster => `/* ${plaster} */`
-};
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.spec.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.spec.js
deleted file mode 100644
index e148537fe7..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-c.spec.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const matcher = require('./inline-c');
-
-describe('inline-c region-matcher', () => {
- it('should match start annotations', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('// #docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('//#docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('// #docregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match end annotations', () => {
- let matches;
-
- matches = matcher.regionEndMatcher.exec('// #enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('//#enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('// #enddocregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match plaster annotations', () => {
- let matches;
-
- matches = matcher.plasterMatcher.exec('// #docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('//#docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('// #docplaster');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should create a plaster comment', () => {
- expect(matcher.createPlasterComment('... elided ...')).toEqual('/* ... elided ... */');
- });
-});
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.js
deleted file mode 100644
index 1dc975fe3f..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// These type of comments are used in hash comment based languages such as bash and Yaml
-module.exports = {
- regionStartMatcher: /^\s*#\s*#docregion\s*(.*)\s*$/,
- regionEndMatcher: /^\s*#\s*#enddocregion\s*(.*)\s*$/,
- plasterMatcher: /^\s*#\s*#docplaster\s*(.*)\s*$/,
- createPlasterComment: plaster => `# ${plaster}`
-};
diff --git a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.spec.js b/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.spec.js
deleted file mode 100644
index 9653a66289..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-matchers/inline-hash.spec.js
+++ /dev/null
@@ -1,54 +0,0 @@
-const matcher = require('./inline-hash');
-
-describe('inline-hash region-matcher', () => {
- it('should match start annotations', () => {
- let matches;
-
- matches = matcher.regionStartMatcher.exec('# #docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('##docregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionStartMatcher.exec('# #docregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match end annotations', () => {
- let matches;
-
- matches = matcher.regionEndMatcher.exec('# #enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('##enddocregion A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.regionEndMatcher.exec('# #enddocregion');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should match plaster annotations', () => {
- let matches;
-
- matches = matcher.plasterMatcher.exec('# #docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('##docplaster A b c');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('A b c');
-
- matches = matcher.plasterMatcher.exec('# #docplaster');
- expect(matches).not.toBeNull();
- expect(matches[1]).toEqual('');
- });
-
- it('should create a plaster comment',
- () => { expect(matcher.createPlasterComment('... elided ...')).toEqual('# ... elided ...'); });
-});
\ No newline at end of file
diff --git a/docs_app/tools/transforms/examples-package/services/region-parser.js b/docs_app/tools/transforms/examples-package/services/region-parser.js
deleted file mode 100644
index cc5965af3e..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-parser.js
+++ /dev/null
@@ -1,142 +0,0 @@
-const blockC = require('./region-matchers/block-c');
-const html = require('./region-matchers/html');
-const inlineC = require('./region-matchers/inline-c');
-const inlineCOnly = require('./region-matchers/inline-c-only');
-const inlineHash = require('./region-matchers/inline-hash');
-const DEFAULT_PLASTER = '. . .';
-const {mapObject} = require('../../helpers/utils');
-
-module.exports = function regionParser() {
- return regionParserImpl;
-};
-
-regionParserImpl.regionMatchers = {
- ts: inlineC,
- js: inlineC,
- es6: inlineC,
- dart: inlineC,
- html: html,
- css: blockC,
- yaml: inlineHash,
- jade: inlineCOnly,
- json: inlineC,
- 'json.annotated': inlineC
-};
-
-/**
- * @param contents string
- * @param fileType string
- * @returns {contents: string, regions: {[regionName: string]: string}}
- */
-function regionParserImpl(contents, fileType) {
- const regionMatcher = regionParserImpl.regionMatchers[fileType];
- const openRegions = [];
- const regionMap = {};
-
- if (regionMatcher) {
- let plaster = regionMatcher.createPlasterComment(DEFAULT_PLASTER);
- const lines = contents.split(/\r?\n/).filter((line, index) => {
- const startRegion = line.match(regionMatcher.regionStartMatcher);
- const endRegion = line.match(regionMatcher.regionEndMatcher);
- const updatePlaster = line.match(regionMatcher.plasterMatcher);
-
- // start region processing
- if (startRegion) {
- // open up the specified region
- const regionNames = getRegionNames(startRegion[1]);
- if (regionNames.length === 0) {
- regionNames.push('');
- }
- regionNames.forEach(regionName => {
- const region = regionMap[regionName];
- if (region) {
- if (region.open) {
- throw new RegionParserError(
- `Tried to open a region, named "${regionName}", that is already open`, index);
- }
- region.open = true;
- if (plaster) {
- region.lines.push(plaster);
- }
- } else {
- regionMap[regionName] = {lines: [], open: true};
- }
- openRegions.push(regionName);
- });
-
- // end region processing
- } else if (endRegion) {
- if (openRegions.length === 0) {
- throw new RegionParserError('Tried to close a region when none are open', index);
- }
- // close down the specified region (or most recent if no name is given)
- const regionNames = getRegionNames(endRegion[1]);
- if (regionNames.length === 0) {
- regionNames.push(openRegions[openRegions.length - 1]);
- }
-
- regionNames.forEach(regionName => {
- const region = regionMap[regionName];
- if (!region || !region.open) {
- throw new RegionParserError(
- `Tried to close a region, named "${regionName}", that is not open`, index);
- }
- region.open = false;
- removeLast(openRegions, regionName);
- });
-
- // doc plaster processing
- } else if (updatePlaster) {
- const plasterString = updatePlaster[1].trim();
- plaster = plasterString ? regionMatcher.createPlasterComment(plasterString) : '';
-
- // simple line of content processing
- } else {
- openRegions.forEach(regionName => regionMap[regionName].lines.push(line));
- // do not filter out this line from the content
- return true;
- }
-
- // this line contained an annotation so let's filter it out
- return false;
- });
- if (!regionMap['']) {
- regionMap[''] = {lines};
- }
- return {
- contents: lines.join('\n'),
- regions: mapObject(regionMap, (regionName, region) => leftAlign(region.lines).join('\n'))
- };
- } else {
- return {contents, regions: {}};
- }
-}
-
-function getRegionNames(input) {
- return (input.trim() === '') ? [] : input.split(',').map(name => name.trim());
-}
-
-function removeLast(array, item) {
- const index = array.lastIndexOf(item);
- array.splice(index, 1);
-}
-
-function leftAlign(lines) {
- let indent = Number.MAX_VALUE;
- lines.forEach(line => {
- const lineIndent = line.search(/\S/);
- if (lineIndent !== -1) {
- indent = Math.min(lineIndent, indent);
- }
- });
- return lines.map(line => line.substr(indent));
-}
-
-function RegionParserError(message, index) {
- const lineNum = index + 1;
- this.message = `regionParser: ${message} (at line ${lineNum}).`;
- this.lineNum = lineNum;
- this.stack = (new Error()).stack;
-}
-RegionParserError.prototype = Object.create(Error.prototype);
-RegionParserError.prototype.constructor = RegionParserError;
diff --git a/docs_app/tools/transforms/examples-package/services/region-parser.spec.js b/docs_app/tools/transforms/examples-package/services/region-parser.spec.js
deleted file mode 100644
index 80739f8a4f..0000000000
--- a/docs_app/tools/transforms/examples-package/services/region-parser.spec.js
+++ /dev/null
@@ -1,180 +0,0 @@
-var testPackage = require('../../helpers/test-package');
-var Dgeni = require('dgeni');
-
-const testRegionMatcher = {
- regionStartMatcher: /^\s*\/\*\s*#docregion\s+(.*)\s*\*\/\s*$/,
- regionEndMatcher: /^\s*\/\*\s*#enddocregion\s+(.*)\s*\*\/\s*$/,
- plasterMatcher: /^\s*\/\*\s*#docplaster\s+(.*)\s*\*\/\s*$/,
- createPlasterComment: plaster => `/* ${plaster} */`
-};
-
-describe('regionParser service', () => {
- var dgeni, injector, regionParser;
-
- beforeEach(function() {
- dgeni = new Dgeni([testPackage('examples-package', true)]);
- injector = dgeni.configureInjector();
- regionParser = injector.get('regionParser');
- regionParser.regionMatchers = {'test-type': testRegionMatcher};
- });
-
- it('should return just the contents if there is no region-matcher for the file type', () => {
- const output = regionParser('some contents', 'unknown');
- expect(output).toEqual({contents: 'some contents', regions: {}});
- });
-
- it('should return just the contents if there is a region-matcher but no regions', () => {
- const output = regionParser('some contents', 'test-type');
- expect(output).toEqual({contents: 'some contents', regions: { '': 'some contents' }});
- });
-
- it('should remove start region annotations from the contents', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #docregion X */', 'def', '/* #docregion Y */', 'ghi'),
- 'test-type');
- expect(output.contents).toEqual(t('abc', 'def', 'ghi'));
- });
-
- it('should remove end region annotations from the contents', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #docregion X */', 'def', '/* #enddocregion X */',
- '/* #docregion Y */', 'ghi', '/* #enddocregion Y */', '/* #enddocregion */'),
- 'test-type');
- expect(output.contents).toEqual(t('abc', 'def', 'ghi'));
- });
-
- it('should left align the text of the region', () => {
- const output = regionParser(
- t(
- '/* #docregion X */', ' all', ' indented', ' by', ' two', ' spaces', '/* #enddocregion X */',
- '/* #docregion Y */', ' first', ' line', ' indented', ' more', ' than', ' later', ' lines', '/* #enddocregion Y */',
- '/* #docregion Z */', ' ignore', ' ', ' empty', '', ' lines', '/* #enddocregion Z */'
- ), 'test-type');
- expect(output.regions['X']).toEqual(t('all', ' indented', ' by', 'two', 'spaces'));
- expect(output.regions['Y']).toEqual(t(' first', 'line', 'indented', ' more', 'than', 'later', 'lines'));
- expect(output.regions['Z']).toEqual(t('ignore', '', 'empty', '', 'lines'));
- });
-
- it('should remove doc plaster annotations from the contents', () => {
- const output =
- regionParser(t('/* #docplaster ... elided ... */', 'abc', 'def', 'ghi'), 'test-type');
- expect(output.contents).toEqual(t('abc', 'def', 'ghi'));
- });
-
- it('should capture the rest of the contents for a region with no end region annotation', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #docregion X */', 'def', '/* #docregion Y */', 'ghi'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc', 'def', 'ghi'));
- expect(output.regions['X']).toEqual(t('def', 'ghi'));
- expect(output.regions['Y']).toEqual(t('ghi'));
- });
-
-
- it('should capture the contents for a region up to the end region annotation', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #enddocregion */', '/* #docregion X */', 'def',
- '/* #enddocregion X */', '/* #docregion Y */', 'ghi', '/* #enddocregion Y */'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc'));
- expect(output.regions['X']).toEqual(t('def'));
- expect(output.regions['Y']).toEqual(t('ghi'));
- });
-
- it('should open a region with a null name if there is no region name', () => {
- const output = regionParser(t('/* #docregion */', 'abc', '/* #enddocregion */'), 'test-type');
- expect(output.regions['']).toEqual('abc');
- });
-
- it('should close the most recently opened region if there is no region name', () => {
- const output = regionParser(
- t('/* #docregion X*/', 'abc', '/* #docregion Y */', 'def', '/* #enddocregion */', 'ghi',
- '/* #enddocregion */'),
- 'test-type');
- expect(output.regions['X']).toEqual(t('abc', 'def', 'ghi'));
- expect(output.regions['Y']).toEqual(t('def'));
- });
-
- it('should handle overlapping regions', () => {
- const output = regionParser(
- t('/* #docregion X*/', 'abc', '/* #docregion Y */', 'def', '/* #enddocregion X */', 'ghi',
- '/* #enddocregion Y */'),
- 'test-type');
- expect(output.regions['X']).toEqual(t('abc', 'def'));
- expect(output.regions['Y']).toEqual(t('def', 'ghi'));
- });
-
- it('should error if we attempt to open an already open region', () => {
- expect(() => regionParser(t('/* #docregion */', 'abc', '/* #docregion */', 'def'), 'test-type'))
- .toThrowError(
- 'regionParser: Tried to open a region, named "", that is already open (at line 3).');
-
- expect(
- () =>
- regionParser(t('/* #docregion X */', 'abc', '/* #docregion X */', 'def'), 'test-type'))
- .toThrowError(
- 'regionParser: Tried to open a region, named "X", that is already open (at line 3).');
- });
-
- it('should error if we attempt to close an already closed region', () => {
- expect(() => regionParser(t('abc', '/* #enddocregion */', 'def'), 'test-type'))
- .toThrowError('regionParser: Tried to close a region when none are open (at line 2).');
-
- expect(
- () =>
- regionParser(t('/* #docregion */', 'abc', '/* #enddocregion X */', 'def'), 'test-type'))
- .toThrowError(
- 'regionParser: Tried to close a region, named "X", that is not open (at line 3).');
- });
-
- it('should handle whitespace in region names on single annotation', () => {
- const output =
- regionParser(t('/* #docregion A B*/', 'abc', '/* #docregion A C */', 'def'), 'test-type');
- expect(output.regions['A B']).toEqual(t('abc', 'def'));
- expect(output.regions['A C']).toEqual(t('def'));
- });
-
- it('should join multiple regions with the default plaster string (". . .")', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #enddocregion */', 'def', '/* #docregion */', 'ghi',
- '/* #enddocregion */'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc', '/* . . . */', 'ghi'));
- });
-
-
- it('should join multiple regions with the current plaster string', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #enddocregion */', 'def', '/* #docregion */', 'ghi',
- '/* #enddocregion */', '/* #docplaster ... elided ... */', '/* #docregion A */', 'jkl',
- '/* #enddocregion A */', 'mno', '/* #docregion A */', 'pqr', '/* #enddocregion A */'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc', '/* . . . */', 'ghi'));
- expect(output.regions['A']).toEqual(t('jkl', '/* ... elided ... */', 'pqr'));
- });
-
- it('should remove the plaster altogether if the current plaster string is ""', () => {
- const output = regionParser(
- t('/* #docregion */', 'abc', '/* #enddocregion */', 'def', '/* #docregion */', 'ghi',
- '/* #enddocregion */', '/* #docplaster */', '/* #docregion A */', 'jkl',
- '/* #enddocregion A */', 'mno', '/* #docregion A */', 'pqr', '/* #enddocregion A */'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc', '/* . . . */', 'ghi'));
- expect(output.regions['A']).toEqual(t('jkl', 'pqr'));
- });
-
- it('should parse multiple region names separated by commas', () => {
- const output = regionParser(
- t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz',
- '/* #enddocregion A, C */', '123', '/* #enddocregion */'),
- 'test-type');
- expect(output.regions['']).toEqual(t('abc', 'xyz', '123'));
- expect(output.regions['A']).toEqual(t('abc', 'xyz'));
- expect(output.regions['B']).toEqual(t('abc'));
- expect(output.regions['C']).toEqual(t('xyz'));
- });
-});
-
-function t() {
- return Array.prototype.join.call(arguments, '\n');
-}
diff --git a/docs_app/tools/transforms/remark-package/services/renderMarkdown.spec.js b/docs_app/tools/transforms/remark-package/services/renderMarkdown.spec.js
index 53e12e4a8a..cc085514ee 100644
--- a/docs_app/tools/transforms/remark-package/services/renderMarkdown.spec.js
+++ b/docs_app/tools/transforms/remark-package/services/renderMarkdown.spec.js
@@ -1,5 +1,6 @@
const renderMarkdownFactory = require('./renderMarkdown');
+// prettier-ignore
describe('remark: renderMarkdown service', () => {
let renderMarkdown;
beforeEach(() => {
@@ -30,19 +31,6 @@ describe('remark: renderMarkdown service', () => {
expect(output).toEqual('\n- list item {@link some_url_path}
\n
\n');
});
- it('should not put block level inline tags inside paragraphs', () => {
- const content = 'A paragraph.\n' +
- '\n' +
- '{@example blah **blah** blah }\n' +
- '\n' +
- 'Another paragraph {@link _containing_ } an inline tag';
- const output = renderMarkdown(content);
- expect(output).toEqual(
- 'A paragraph.
\n' +
- '{@example blah **blah** blah }\n' +
- 'Another paragraph {@link _containing_ } an inline tag
\n');
- });
-
it('should not format the contents of tags marked as unformatted ', () => {
const content = '\n\n **abc**\n\n def\n\n\n\n\n **abc**\n\n def\n';
const output = renderMarkdown(content);