@progress/kendo-typescript-api-tasks 3.0.2-dev.3 → 3.0.2-dev.35
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/lib/comment.js +1 -1
- package/lib/generator.js +31 -5
- package/package.json +2 -2
- package/test/api.js +36 -0
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
|
-
|
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.35+a81fc3a",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a81fc3aad00eb94d6b027b54acfcfb3c73896b1d"
|
|
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
|
|