Skip to content

Commit 2b19627

Browse files
authored
Fix tabs initialization and update documentation rendering logic (#3629)
* Fix tabs initialization and update documentation rendering logic * cleanup * bump version to 3.12.0 * Remove buildOldDocs method
1 parent 068611f commit 2b19627

File tree

3 files changed

+5
-89
lines changed

3 files changed

+5
-89
lines changed

docuilib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-docs",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"main": "./src/index.ts",
55
"scripts": {
66
"docusaurus": "docusaurus",

docuilib/src/components/ComponentPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function ComponentPage({component}) {
5959
};
6060

6161
const buildTabs = () => {
62-
const tabs = component.docs?.tabs;
62+
const tabs = component.docs?.tabs ?? [];
6363
const api = component.props;
6464
const tabsArray = !_.isEmpty(api) ? [...tabs, devTab] : tabs;
6565

scripts/docs/buildDocsCommon.js

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,9 @@ function processComponents(components) {
8888
content += `sidebar_label: ${componentName}\n`;
8989
content += '---\n\n';
9090

91-
if (component.docs) {
92-
content += `import ComponentPage from '@site/src/components/ComponentPage';\n\n`;
93-
const componentObject = JSON.stringify(component);
94-
content += `<ComponentPage component={${componentObject}}/>\n`;
95-
} else {
96-
content += `${buildOldDocs(component)}\n`;
97-
}
91+
content += `import ComponentPage from '@site/src/components/ComponentPage';\n\n`;
92+
const componentObject = JSON.stringify(component);
93+
content += `<ComponentPage component={${componentObject}}/>\n`;
9894

9995
let dirPath;
10096
switch (component.category) {
@@ -153,84 +149,4 @@ function logStatistics(components) {
153149
}
154150
}
155151

156-
function buildOldDocs(component) {
157-
let content = '';
158-
content += `import UILivePreview from '@site/src/components/UILivePreview';\n\n`;
159-
160-
/* General Info */
161-
content += `${component.description} \n`;
162-
if (typeof component.example === 'string') {
163-
content += `[(code example)](${component.example})\n`;
164-
} else if (Array.isArray(component.example)) {
165-
content += '(code examples: ';
166-
component.example.forEach((example, index) => {
167-
const slashIndex = example.lastIndexOf('/');
168-
const dotIndex = example.lastIndexOf('.');
169-
content += `${index > 0 ? ', ' : ''}[${example.slice(slashIndex + 1, dotIndex)}](${example})`;
170-
});
171-
content += ')\n';
172-
}
173-
174-
if (component.extends) {
175-
let extendsText = component.extends?.join(', ');
176-
if (component.extendsLink) {
177-
extendsText = `[${extendsText}](${component.extendsLink})`;
178-
} else {
179-
extendsText = _.map(component.extends, generateExtendsLink).join(', ');
180-
}
181-
content += ':::info\n';
182-
content += `This component extends **${extendsText}** props.\n`;
183-
content += ':::\n';
184-
}
185-
186-
if (component.modifiers) {
187-
content += ':::tip\n';
188-
content += `This component support **${component.modifiers?.join(', ')}** modifiers.\n`;
189-
content += ':::\n';
190-
}
191-
192-
if (component.caution) {
193-
content += ':::caution\n';
194-
content += `${component.caution}\n`;
195-
content += ':::\n';
196-
}
197-
198-
if (component.note) {
199-
content += ':::note\n';
200-
content += `${component.note}\n`;
201-
content += ':::\n';
202-
}
203-
204-
/* Images */
205-
content += `<div style={{display: 'flex', flexDirection: 'row', overflowX: 'auto', maxHeight: '500px', alignItems: 'center'}}>`;
206-
component.images?.forEach(image => {
207-
content += `<img style={{maxHeight: '420px'}} src={'${image}'}/>`;
208-
content += '\n\n';
209-
});
210-
content += '</div>\n\n';
211-
212-
/* Snippet */
213-
if (component.snippet) {
214-
content += `### Usage\n`;
215-
content += `<UILivePreview componentName={"${component.name}"} code={\`${component.snippet
216-
?.map(item => _.replace(item, new RegExp(/\$[1-9]/, 'g'), ''))
217-
.join('\n')
218-
.toString()}\`}/>\n\n`;
219-
}
220-
221-
/* Props */
222-
content += '## API\n';
223-
_.sortBy(component.props, p => p.name)?.forEach(prop => {
224-
content += `### ${prop.name}\n`;
225-
if (prop.note) {
226-
content += `#### ${prop.note}\n`;
227-
}
228-
content += `${prop.description}\n`;
229-
// content += `<span style={{color: 'grey'}}>${_.escape(prop.type)}</span>\n\n`;
230-
content += `\`${prop.type} \` \n\n`;
231-
});
232-
233-
return content;
234-
}
235-
236152
module.exports = {buildDocs};

0 commit comments

Comments
 (0)