# Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/architecture-components.md # aio/content/guide/architecture-modules.md # aio/content/guide/architecture-next-steps.md # aio/content/guide/architecture-services.md # aio/content/guide/architecture.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/cheatsheet.md # aio/content/guide/comparing-observables.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection-pattern.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/dynamic-component-loader.md # aio/content/guide/elements.md # aio/content/guide/feature-modules.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/hierarchical-dependency-injection.md # aio/content/guide/i18n.md # aio/content/guide/lazy-loading-ngmodules.md # aio/content/guide/lifecycle-hooks.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule-vs-jsmodule.md # aio/content/guide/ngmodules.md # aio/content/guide/npm-packages.md # aio/content/guide/observables-in-angular.md # aio/content/guide/observables.md # aio/content/guide/pipes.md # aio/content/guide/practical-observable-usage.md # aio/content/guide/providers.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/router.md # aio/content/guide/rx-library.md # aio/content/guide/security.md # aio/content/guide/service-worker-communications.md # aio/content/guide/service-worker-getting-started.md # aio/content/guide/service-worker-intro.md # aio/content/guide/setup-systemjs-anatomy.md # aio/content/guide/setup.md # aio/content/guide/singleton-services.md # aio/content/guide/structural-directives.md # aio/content/guide/styleguide.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/guide/typescript-configuration.md # aio/content/guide/universal.md # aio/content/guide/updating.md # aio/content/guide/upgrade.md # aio/content/guide/user-input.md # aio/content/guide/visual-studio-2015.md # aio/content/marketing/docs.md # aio/content/navigation.json # aio/content/tutorial/toh-pt0.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/ngsw-manifest.json # aio/package.json # aio/src/app/custom-elements/api/api-list.component.html # aio/src/app/custom-elements/api/api-list.component.ts # aio/src/index.html # aio/tools/transforms/templates/api/base.template.html # aio/tools/transforms/templates/api/class.template.html # aio/tools/transforms/templates/api/directive.template.html # aio/tools/transforms/templates/api/enum.template.html # aio/tools/transforms/templates/api/includes/class-overview.html # aio/tools/transforms/templates/api/includes/deprecation.html # aio/tools/transforms/templates/api/includes/export-as.html # aio/tools/transforms/templates/api/includes/info-bar.html # aio/tools/transforms/templates/api/includes/interface-overview.html # aio/tools/transforms/templates/api/includes/selectors.html # aio/tools/transforms/templates/api/lib/directiveHelpers.html # aio/tools/transforms/templates/api/lib/githubLinks.html # aio/tools/transforms/templates/api/lib/memberHelpers.html # aio/tools/transforms/templates/api/package.template.html # aio/yarn.lock # packages/common/http/src/module.ts # packages/common/src/common_module.ts # packages/common/src/directives/ng_for_of.ts # packages/common/src/directives/ng_if.ts # packages/common/src/directives/ng_template_outlet.ts # packages/common/src/location/location.ts # packages/common/src/pipes/async_pipe.ts # packages/common/src/pipes/json_pipe.ts # packages/common/src/pipes/number_pipe.ts # packages/common/src/pipes/slice_pipe.ts # packages/core/src/change_detection/change_detector_ref.ts # packages/core/src/di/injectable.ts # packages/core/src/linker/template_ref.ts # packages/core/src/linker/view_container_ref.ts # packages/core/src/metadata/di.ts # packages/core/src/metadata/ng_module.ts # packages/core/src/render/api.ts # packages/forms/src/directives/form_interface.ts # packages/forms/src/directives/ng_form.ts # packages/forms/src/directives/ng_model.ts # packages/forms/src/directives/reactive_directives/form_control_name.ts # packages/forms/src/directives/select_control_value_accessor.ts # packages/forms/src/directives/validators.ts # packages/forms/src/form_providers.ts # packages/forms/src/model.ts # packages/forms/src/validators.ts # packages/router/src/config.ts # packages/router/src/router.ts # packages/router/src/router_module.ts # packages/router/src/router_state.ts
127 lines
4.5 KiB
JavaScript
127 lines
4.5 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
const Package = require('dgeni').Package;
|
|
const glob = require('glob');
|
|
const ignore = require('ignore');
|
|
const fs = require('fs');
|
|
const path = require('canonical-path');
|
|
const basePackage = require('../angular-base-package');
|
|
const contentPackage = require('../content-package');
|
|
|
|
const { CONTENTS_PATH, GUIDE_EXAMPLES_PATH } = require('../config');
|
|
|
|
module.exports = new Package('angular-content', [basePackage, contentPackage])
|
|
|
|
// Where do we get the source files?
|
|
.config(function(readFilesProcessor, collectExamples, renderExamples) {
|
|
|
|
const gitignoreFilePath = path.resolve(GUIDE_EXAMPLES_PATH, '.gitignore');
|
|
const gitignoreFile = fs.readFileSync(gitignoreFilePath, 'utf8');
|
|
const gitignore = ignore().add(gitignoreFile);
|
|
|
|
const examplePaths = glob.sync('**/*', { cwd: GUIDE_EXAMPLES_PATH, dot: true, ignore: '**/node_modules/**', mark: true })
|
|
.filter(filePath => filePath !== '.gitignore') // we are not interested in the .gitignore file itself
|
|
.filter(filePath => !/\/$/.test(filePath)); // this filter removes the folders, leaving only files
|
|
const ignoredExamplePaths = [];
|
|
const resolvedExamplePaths = [];
|
|
|
|
examplePaths.forEach(filePath => {
|
|
// filter out files that match the .gitignore rules
|
|
if (gitignore.ignores(filePath)) {
|
|
ignoredExamplePaths.push(filePath);
|
|
} else {
|
|
// we need the full paths for the filereader
|
|
resolvedExamplePaths.push(path.resolve(GUIDE_EXAMPLES_PATH, filePath));
|
|
}
|
|
});
|
|
|
|
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/{guide,tutorial}/**/*.md',
|
|
fileReader: 'contentFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH + '/marketing',
|
|
include: CONTENTS_PATH + '/marketing/**/*.{html,md}',
|
|
fileReader: 'contentFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/*.md',
|
|
exclude: [CONTENTS_PATH + '/index.md'],
|
|
fileReader: 'contentFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: resolvedExamplePaths,
|
|
fileReader: 'exampleFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/navigation.json',
|
|
fileReader: 'jsonFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/marketing/announcements.json',
|
|
fileReader: 'jsonFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/marketing/contributors.json',
|
|
fileReader: 'jsonFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/marketing/resources.json',
|
|
fileReader: 'jsonFileReader'
|
|
},
|
|
{
|
|
basePath: CONTENTS_PATH,
|
|
include: CONTENTS_PATH + '/translations/**/*.md',
|
|
fileReader: 'contentFileReader'
|
|
},
|
|
]);
|
|
|
|
collectExamples.exampleFolders.push('examples');
|
|
collectExamples.registerIgnoredExamples(ignoredExamplePaths, gitignoreFilePath);
|
|
|
|
renderExamples.ignoreBrokenExamples = true;
|
|
})
|
|
|
|
|
|
// Configure jsdoc-style tag parsing
|
|
.config(function(inlineTagProcessor) {
|
|
inlineTagProcessor.inlineTagDefinitions.push(require('./inline-tag-defs/anchor'));
|
|
})
|
|
|
|
|
|
.config(function(computePathsProcessor) {
|
|
|
|
// Replace any path templates inherited from other packages
|
|
// (we want full and transparent control)
|
|
computePathsProcessor.pathTemplates = computePathsProcessor.pathTemplates.concat([
|
|
{
|
|
docTypes: ['content'],
|
|
getPath: (doc) => `${doc.id.replace(/\/index$/, '')}`,
|
|
outputPathTemplate: '${path}.json'
|
|
},
|
|
{docTypes: ['navigation-json'], pathTemplate: '${id}', outputPathTemplate: '../${id}.json'},
|
|
{docTypes: ['contributors-json'], pathTemplate: '${id}', outputPathTemplate: '../${id}.json'},
|
|
{docTypes: ['announcements-json'], pathTemplate: '${id}', outputPathTemplate: '../${id}.json'},
|
|
{docTypes: ['resources-json'], pathTemplate: '${id}', outputPathTemplate: '../${id}.json'}
|
|
]);
|
|
})
|
|
|
|
// We want the content files to be converted
|
|
.config(function(convertToJsonProcessor, postProcessHtml) {
|
|
convertToJsonProcessor.docTypes.push('content');
|
|
postProcessHtml.docTypes.push('content');
|
|
});
|