@@ -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-
236152module . exports = { buildDocs} ;
0 commit comments