Skip to content

Commit 96afe4e

Browse files
authored
Docs support multiple example screens (#2227)
1 parent 65f8359 commit 96afe4e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

scripts/buildDocs.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ const components = apiFiles.map(filePath => {
1414
return api;
1515
});
1616

17-
if (!fs.existsSync(COMPONENTS_DOCS_DIR)) {
18-
fs.mkdirSync(COMPONENTS_DOCS_DIR);
17+
if (fs.existsSync(COMPONENTS_DOCS_DIR)) {
18+
childProcess.execSync(`rm -rf ${COMPONENTS_DOCS_DIR}`);
1919
}
2020

21+
fs.mkdirSync(COMPONENTS_DOCS_DIR);
22+
2123
const compoundComponents = components.filter(c => c.name.includes('.'));
2224
const parentComponents = _.flow(components => _.map(components, c => c.name.split('.')[0]), _.uniq)(compoundComponents);
2325

@@ -44,7 +46,17 @@ components.forEach(component => {
4446

4547
/* General */
4648
content += `${component.description} \n`;
47-
content += `[(code example)](${component.example})\n`;
49+
if (typeof component.example === 'string') {
50+
content += `[(code example)](${component.example})\n`;
51+
} else if (Array.isArray(component.example)) {
52+
content += '(code examples: ';
53+
component.example.forEach((example, index) => {
54+
const slashIndex = example.lastIndexOf('/');
55+
const dotIndex = example.lastIndexOf('.');
56+
content += `${index > 0 ? ', ' : ''}[${example.slice(slashIndex + 1, dotIndex)}](${example})`;
57+
});
58+
content += ')\n';
59+
}
4860

4961
if (component.extends) {
5062
let extendsText = component.extends?.join(', ');

0 commit comments

Comments
 (0)