Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions generator-eui/documentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module.exports = class extends Generator {
const {
componentExampleName,
componentExamplePrefix,
componentName,
fileName,
} = this.config.documentationVars;

Expand All @@ -140,30 +141,23 @@ module.exports = class extends Generator {
'const'
)} ${componentExamplePrefix}Source = require(${chalk.cyan(
`'!!raw-loader!./${fileName}'`
)});\n` +
`${chalk.magenta(
'const'
)} ${componentExamplePrefix}Html = renderToHtml(${componentExampleName});`
)});`
);

this.log(chalk.white('\n// Render demo.'));
this.log(chalk.white('\n// Append to existing example sections.'));
this.log(
'<GuideSection\n' +
` title="${componentExampleName}"\n` +
' source={[{\n' +
'{\n' +
` title: '${componentExampleName}',\n` +
' text: (\n' +
` <><p>Description needed: how to use the <strong>${componentExampleName}</strong> component.</p></>\n` +
' ),\n' +
' source: [{\n' +
' type: GuideSectionTypes.JS,\n' +
` code: ${componentExamplePrefix}Source,\n` +
' }, {\n' +
' type: GuideSectionTypes.HTML,\n' +
` code: ${componentExamplePrefix}Html,\n` +
' }]}\n' +
' text={\n' +
` <p>Description needed: how to use the ${componentExampleName} component.</p>\n` +
' }\n' +
' demo={\n' +
` <${componentExampleName} />\n` +
' }\n' +
'/>\n'
' }],\n' +
` demo: <${componentExampleName} />,\n` +
` props: { ${componentName} },\n` +
' }\n'
);
};

Expand Down
26 changes: 13 additions & 13 deletions generator-eui/documentation/templates/documentation_page.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import React from 'react';

import { renderToHtml } from '../../services';

import {
GuideSectionTypes,
} from '../../components';

import {
EuiText,
<%= componentName %>,
} from '../../../../src/components';
} from '../../../../src';

import <%= componentExampleName %> from './<%= fileName %>';
const <%= componentExamplePrefix %>Source = require('!!raw-loader!./<%= fileName %>');
const <%= componentExamplePrefix %>Html = renderToHtml(<%= componentExampleName %>);

export const <%= componentExampleName %>Example = {
title: '<%= componentExampleName %>',
intro: (
<><EuiText></EuiText></>
),
sections: [{
title: '<%= componentExampleName %>',
text: (
<>
<p>
Description needed: how to use the <strong>Eui<%= componentExampleName %></strong> component.
</p>
</>
),
source: [{
type: GuideSectionTypes.JS,
code: <%= componentExamplePrefix %>Source,
}, {
type: GuideSectionTypes.HTML,
code: <%= componentExamplePrefix %>Html,
}],
text: (
<p>
Description needed: how to use the <strong>Eui<%= componentExampleName %></strong> component.
</p>
),
props: { <%= componentName %> },
demo: <<%= componentExampleName %> />,
props: { <%= componentName %> },
}],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {
<%= componentName %>,
} from '../../../../src/components/<%= folderName %>';
} from '../../../../src';

export default () => (
<<%= componentName %>>
Expand Down