@progress/kendo-typescript-api-tasks 3.0.2-dev.4 → 3.0.2-dev.40
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.js +13 -0
- package/lib/comment.js +1 -1
- package/lib/generator.js +31 -5
- package/lib/list-api-members.js +34 -0
- package/package.json +3 -3
- package/test/api.js +36 -0
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const typedoc = require('typedoc');
|
|
|
8
8
|
const glob = require('glob');
|
|
9
9
|
const generator = require('./lib/generator.js');
|
|
10
10
|
const typeLinks = require('./type-links.json');
|
|
11
|
+
const listMembers = require('./lib/list-api-members.js');
|
|
11
12
|
|
|
12
13
|
const defaultConfig = {
|
|
13
14
|
outPath: 'docs/api',
|
|
@@ -66,6 +67,18 @@ module.exports.addAPITasks = (gulp, userConfig) => {
|
|
|
66
67
|
done();
|
|
67
68
|
});
|
|
68
69
|
|
|
70
|
+
gulp.task('api-members', series('api-json', (done) => {
|
|
71
|
+
const data = JSON.parse(fs.readFileSync(config.jsonPath, 'utf8'));
|
|
72
|
+
const members = listMembers(data);
|
|
73
|
+
const output = members.map(({ name }) => `${name}`).join("\n");
|
|
74
|
+
const absoluteOutput = path.resolve(path.join(path.dirname(config.jsonPath), 'api-members.txt'));
|
|
75
|
+
fs.writeFileSync(absoluteOutput, output, "utf8");
|
|
76
|
+
|
|
77
|
+
console.log(`API members list written to ${absoluteOutput}`);
|
|
78
|
+
|
|
79
|
+
done();
|
|
80
|
+
}));
|
|
81
|
+
|
|
69
82
|
gulp.task('api', series('api-json', 'api-clean', (done) => {
|
|
70
83
|
const packageJson = path.join(process.cwd(), 'package.json');
|
|
71
84
|
const packageInfo = require(packageJson);
|
package/lib/comment.js
CHANGED
|
@@ -13,7 +13,7 @@ const commentTags = (comment, member) =>
|
|
|
13
13
|
|
|
14
14
|
if (tag.tag === '@example') {
|
|
15
15
|
text = text.replace(/_@/g, '@');
|
|
16
|
-
} else if (tag.tag === '@see') {
|
|
16
|
+
} else if (tag.tag === '@see' && member.packageName) {
|
|
17
17
|
const linkSlug = slug(member.packageName, text);
|
|
18
18
|
text = `\n\nSee [${text}]({% slug ${linkSlug} %})`;
|
|
19
19
|
} else {
|
package/lib/generator.js
CHANGED
|
@@ -212,9 +212,35 @@ const writeFile = (name, content) => {
|
|
|
212
212
|
fs.writeFileSync(name, content);
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
const stripPlatformContent = (input, platform) => {
|
|
216
|
+
if (typeof platform !== 'string') {
|
|
217
|
+
return input;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const extractContent = (_, platformMatch, platformContent) => (
|
|
221
|
+
platform.toLowerCase() === platformMatch.trim().toLowerCase() ? `${platformContent}` : ""
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// Replace platform_content blocks on newlines
|
|
225
|
+
let content = input.replace(
|
|
226
|
+
/^[ \t]*{%\s*platform_content\s+([a-zA-Z0-9_-]+)\s*%}\r?\n?([\s\S]*?)^[ \t]*{%\s*endplatform_content\s*%}\r?\n?/gm,
|
|
227
|
+
extractContent
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
// Replace platform_content blocks without newlines (e.g. in comments)
|
|
231
|
+
content = content.replace(
|
|
232
|
+
/{%\s*platform_content\s+([a-zA-Z0-9_-]+)\s*%}([\s\S]*?){%\s*endplatform_content\s*%}/g,
|
|
233
|
+
extractContent
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
return content;
|
|
237
|
+
};
|
|
238
|
+
|
|
215
239
|
const writeMember = (path, member, info) => {
|
|
216
|
-
|
|
217
|
-
|
|
240
|
+
const sub = member.module ? member.module + '/' : '';
|
|
241
|
+
const content = stripPlatformContent(memberPage(member, info), info.platform);
|
|
242
|
+
|
|
243
|
+
writeFile(`${path}/${sub}${member.url}.md`, content);
|
|
218
244
|
};
|
|
219
245
|
|
|
220
246
|
const groupMembers = (members) => {
|
|
@@ -266,7 +292,7 @@ const generate = (done, config, packageInfo) => {
|
|
|
266
292
|
};
|
|
267
293
|
|
|
268
294
|
module.exports = {
|
|
269
|
-
generate
|
|
270
|
-
extractMembers
|
|
295
|
+
generate,
|
|
296
|
+
extractMembers,
|
|
297
|
+
stripPlatformContent
|
|
271
298
|
};
|
|
272
|
-
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function listMembers(root) {
|
|
2
|
+
const results = [];
|
|
3
|
+
|
|
4
|
+
function walk(node) {
|
|
5
|
+
if (!node || typeof node !== "object") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (Array.isArray(node.children)) {
|
|
10
|
+
const parentName = typeof node.name === "string" ? node.name + '.' : '';
|
|
11
|
+
|
|
12
|
+
for (const child of node.children) {
|
|
13
|
+
if (
|
|
14
|
+
child &&
|
|
15
|
+
typeof child === "object" &&
|
|
16
|
+
typeof child.name === "string" &&
|
|
17
|
+
typeof child.variant === "string" &&
|
|
18
|
+
typeof child.kind === "number" &&
|
|
19
|
+
child.variant === "declaration" &&
|
|
20
|
+
child.kind > 4 /* skip namespaces and modules */
|
|
21
|
+
) {
|
|
22
|
+
results.push({ name: parentName + child.name, kind: child.kind });
|
|
23
|
+
}
|
|
24
|
+
walk(child);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
walk(root);
|
|
30
|
+
return results;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = listMembers;
|
|
34
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-typescript-api-tasks",
|
|
3
3
|
"description": "Kendo UI API docs package gulp tasks",
|
|
4
|
-
"version": "3.0.2-dev.
|
|
4
|
+
"version": "3.0.2-dev.40+d5278df",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"glob": "^11.0.0",
|
|
21
21
|
"gulp": "^5.0.0",
|
|
22
22
|
"handlebars": "^4.7.7",
|
|
23
|
-
"lodash": "^4.
|
|
23
|
+
"lodash": "^4.18.1",
|
|
24
24
|
"mkdirp": "^3.0.1",
|
|
25
25
|
"typedoc": "0.25.2"
|
|
26
26
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d5278df38d8cca85576863592ddf9b1d8e46b462"
|
|
35
35
|
}
|
package/test/api.js
CHANGED
|
@@ -348,5 +348,41 @@ describe('API generation', () => {
|
|
|
348
348
|
expect(/#\s{1}Foo\s{1}API/.test(page)).toBe(true);
|
|
349
349
|
});
|
|
350
350
|
});
|
|
351
|
+
|
|
352
|
+
describe('stripPlatformContent', () => {
|
|
353
|
+
it('strips platform content', () => {
|
|
354
|
+
const content = `
|
|
355
|
+
HEADER
|
|
356
|
+
|
|
357
|
+
{% platform_content angular %}
|
|
358
|
+
ANGULAR CONTENT
|
|
359
|
+
{% endplatform_content %}
|
|
360
|
+
{% platform_content react %}
|
|
361
|
+
REACT CONTENT
|
|
362
|
+
{% endplatform_content %}
|
|
363
|
+
|
|
364
|
+
FOOTER
|
|
365
|
+
`;
|
|
366
|
+
|
|
367
|
+
const output = generator.stripPlatformContent(content, 'react');
|
|
368
|
+
|
|
369
|
+
expect(output).toBe(`
|
|
370
|
+
HEADER
|
|
371
|
+
|
|
372
|
+
REACT CONTENT
|
|
373
|
+
|
|
374
|
+
FOOTER
|
|
375
|
+
`);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('strips inline platform content', () => {
|
|
379
|
+
const content =
|
|
380
|
+
"HEADER {% platform_content angular %}ANGULAR CONTENT{% endplatform_content %}{% platform_content react %}REACT CONTENT{% endplatform_content %} FOOTER";
|
|
381
|
+
|
|
382
|
+
const output = generator.stripPlatformContent(content, 'react');
|
|
383
|
+
|
|
384
|
+
expect(output).toBe("HEADER REACT CONTENT FOOTER");
|
|
385
|
+
});
|
|
386
|
+
});
|
|
351
387
|
});
|
|
352
388
|
|