build(docs-infra): disambiguate doc paths for global APIs (#42648)

In #41788, the `disambiguateDocsPathsProcessor` was introduced to fix
an issue with case-insensitively equal paths. This processor may alter
the output paths of some docs. Due to its nature, the
`disambiguateDocPathsProcessor` must be the last processor in the
pipeline that updates a doc's output path. However, the
`updateGlobalApiPathProcess` (which also alters the output paths of some
docs) was not configured to run before `disambiguateDocPathsProcessor`.
As a result, the changes made by `disambiguateDocPathsProcessor` were
overridden by `updateGlobalApiPathProcess`, resulting in the app's
failing to load such global API docs pages. An example of such an API
page is: https://angular.io/api/core/global/ngApplyChanges

This commit fixes it by ensuring that the `updateGlobalApiPathProcess`
is explicitly run before the `disambiguateDocPathsProcessor`, so that
the former does not override the changes made by the latter.

PR Close #42648
This commit is contained in:
George Kalpakas 2021-06-24 20:57:23 +03:00 committed by Jessica Janiuk
parent 637ac00fd5
commit 2203217c40
3 changed files with 5 additions and 4 deletions

View File

@ -68,6 +68,7 @@ describe(browser.baseUrl, () => {
/* Directive */ 'api/common/NgIf': 'class ngif',
/* Enum */ 'api/core/ChangeDetectionStrategy': 'enum changedetectionstrategy',
/* Function */ 'api/animations/animate': 'animate(',
/* Global */ 'api/core/global/ngApplyChanges': 'ng.applychanges(',
/* Interface */ 'api/core/OnDestroy': 'interface ondestroy',
/* Pipe */ 'api/common/JsonPipe': '| json',
/* Type-Alias */ 'api/common/http/HttpEvent': 'type httpevent',

View File

@ -6,8 +6,8 @@
*/
module.exports = function updateGlobalApiPathProcessor() {
return {
$runAfter: ['computePathsProcessor'],
$runBefore: ['processNgModuleDocs'],
$runAfter: ['paths-computed'],
$runBefore: ['disambiguateDocPathsProcessor', 'processNgModuleDocs'],
$process: function(docs) {
docs.forEach(doc => {
if (doc.global && doc.globalNamespace) {

View File

@ -12,12 +12,12 @@ describe('updateGlobalApiPath processor', () => {
it('should run before the correct processor', () => {
const processor = processorFactory();
expect(processor.$runBefore).toEqual(['processNgModuleDocs']);
expect(processor.$runBefore).toEqual(['disambiguateDocPathsProcessor', 'processNgModuleDocs']);
});
it('should run after the correct processor', () => {
const processor = processorFactory();
expect(processor.$runAfter).toEqual(['computePathsProcessor']);
expect(processor.$runAfter).toEqual(['paths-computed']);
});
it('should update the paths of namespaced global APIs', () => {