@ng-doc/keywords-loaders 17.5.5 → 17.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +45 -107
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -19,21 +19,13 @@ function getNgHost(version) {
|
|
|
19
19
|
return `https://${versionEndpoint}angular.io`;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return Promise.resolve(f.apply(this, args));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
return Promise.reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param version
|
|
25
|
+
*/
|
|
26
|
+
async function fetchDocs(version) {
|
|
27
|
+
return await fetch__default["default"](`${getNgHost(version)}/generated/docs/app/search-data.json`).then(response => response.json());
|
|
33
28
|
}
|
|
34
|
-
const fetchDocs = _async$3(function (version) {
|
|
35
|
-
return fetch__default["default"](`${getNgHost(version)}/generated/docs/app/search-data.json`).then(response => response.json());
|
|
36
|
-
});
|
|
37
29
|
|
|
38
30
|
/**
|
|
39
31
|
*
|
|
@@ -75,113 +67,59 @@ function ngPageToKeyword(page, version) {
|
|
|
75
67
|
* of the Angular API into links to the Angular documentation.
|
|
76
68
|
* @param options
|
|
77
69
|
*/
|
|
78
|
-
|
|
79
|
-
function _await$1(value, then, direct) {
|
|
80
|
-
if (direct) {
|
|
81
|
-
return then ? then(value) : value;
|
|
82
|
-
}
|
|
83
|
-
if (!value || !value.then) {
|
|
84
|
-
value = Promise.resolve(value);
|
|
85
|
-
}
|
|
86
|
-
return then ? value.then(then) : value;
|
|
87
|
-
}
|
|
88
|
-
function _async$2(f) {
|
|
89
|
-
return function () {
|
|
90
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
91
|
-
args[i] = arguments[i];
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
return Promise.resolve(f.apply(this, args));
|
|
95
|
-
} catch (e) {
|
|
96
|
-
return Promise.reject(e);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
70
|
function ngKeywordsLoader(options) {
|
|
101
|
-
return
|
|
102
|
-
|
|
71
|
+
return async () => {
|
|
72
|
+
const {
|
|
103
73
|
pages
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
74
|
+
} = await fetchDocs(options?.version);
|
|
75
|
+
return pages.filter(page => page.path.startsWith('api')).filter(page => ngApiPageTypes.includes(page.type)).map(page => ngPageToKeyword(page, options?.version)).flat().reduce((keywords, [key, keyword]) => {
|
|
76
|
+
keywords[key] = keyword;
|
|
77
|
+
return keywords;
|
|
78
|
+
}, {});
|
|
79
|
+
};
|
|
111
80
|
}
|
|
112
81
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return Promise.resolve(f.apply(this, args));
|
|
120
|
-
} catch (e) {
|
|
121
|
-
return Promise.reject(e);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param endpoint
|
|
85
|
+
*/
|
|
86
|
+
async function fetchKeywords(endpoint) {
|
|
87
|
+
return await fetch__default["default"](`${endpoint}/keywords.json`).then(response => response.json());
|
|
124
88
|
}
|
|
125
|
-
const fetchKeywords = _async$1(function (endpoint) {
|
|
126
|
-
return fetch__default["default"](`${endpoint}/keywords.json`).then(response => response.json());
|
|
127
|
-
});
|
|
128
89
|
|
|
129
90
|
/**
|
|
130
91
|
* Loads keywords from an external NgDoc documentation.
|
|
131
92
|
* You can use it to integrate your documentation with another NgDoc documentation and use its API or Pages keywords.
|
|
132
93
|
* @param options - The options for the NgDoc keywords loader.
|
|
133
94
|
*/
|
|
134
|
-
|
|
135
|
-
function _await(value, then, direct) {
|
|
136
|
-
if (direct) {
|
|
137
|
-
return then ? then(value) : value;
|
|
138
|
-
}
|
|
139
|
-
if (!value || !value.then) {
|
|
140
|
-
value = Promise.resolve(value);
|
|
141
|
-
}
|
|
142
|
-
return then ? value.then(then) : value;
|
|
143
|
-
}
|
|
144
|
-
function _async(f) {
|
|
145
|
-
return function () {
|
|
146
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
147
|
-
args[i] = arguments[i];
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
return Promise.resolve(f.apply(this, args));
|
|
151
|
-
} catch (e) {
|
|
152
|
-
return Promise.reject(e);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
95
|
function ngDocKeywordsLoader(options) {
|
|
157
|
-
return
|
|
96
|
+
return async () => {
|
|
158
97
|
const endpoint = options.endpoint.replace(/\/$/, '');
|
|
159
98
|
const assets = options.assetsPath ?? '/assets/ng-doc';
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
});
|
|
99
|
+
const keywords = await fetchKeywords(`${endpoint}${assets}`);
|
|
100
|
+
return Object.keys(keywords).reduce((acc, key) => {
|
|
101
|
+
const keyword = keywords[key];
|
|
102
|
+
const url = `${endpoint}${keyword.path}`;
|
|
103
|
+
if (keyword.type === 'guide' && options.loadGuides) {
|
|
104
|
+
const prefix = options.guidesPrefix ?? '';
|
|
105
|
+
const newKey = `*${prefix}${key.replace(/^\*/, '')}`;
|
|
106
|
+
acc[newKey] = {
|
|
107
|
+
title: keyword.title ?? key,
|
|
108
|
+
url,
|
|
109
|
+
description: keyword.description,
|
|
110
|
+
isCodeLink: keyword.isCodeLink
|
|
111
|
+
};
|
|
112
|
+
} else if (keyword.type !== 'guide') {
|
|
113
|
+
acc[key] = {
|
|
114
|
+
title: keyword.title ?? key,
|
|
115
|
+
url,
|
|
116
|
+
description: keyword.description,
|
|
117
|
+
isCodeLink: keyword.isCodeLink
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return acc;
|
|
121
|
+
}, {});
|
|
122
|
+
};
|
|
185
123
|
}
|
|
186
124
|
|
|
187
125
|
exports.ngDocKeywordsLoader = ngDocKeywordsLoader;
|
package/package.json
CHANGED