Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1233 from woocommerce/fix/devDocs-filePath
Browse files Browse the repository at this point in the history
Fix/dev docs file path
  • Loading branch information
psealock authored Jan 14, 2019
2 parents 9b23786 + 761dcbc commit e4fd10e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion client/devdocs/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Docs extends Component {
}

getReadme() {
const readme = require( `../../docs/components/${ this.props.filePath }.md` );
const { filePath, docPath } = this.props;
const readme = require( `../../docs/components/${ docPath }/${ filePath }.md` );
if ( ! readme ) {
return;
}
Expand All @@ -37,4 +38,8 @@ class Docs extends Component {
}
}

Docs.defaultProps = {
docPath: 'packages',
};

export default Docs;
8 changes: 6 additions & 2 deletions client/devdocs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class extends Component {
<div className={ className }>
<Header sections={ breadcrumbs } />
{ exampleList.map( example => {
const { componentName, filePath, render } = getExampleData( example );
const { componentName, filePath, render, docPath } = getExampleData( example );
const cardClasses = classnames(
'woocommerce-devdocs__card',
`woocommerce-devdocs__card--${ filePath }`
Expand All @@ -78,7 +78,11 @@ export default class extends Component {
/>

{ component && (
<ComponentDocs componentName={ componentName } filePath={ filePath } />
<ComponentDocs
componentName={ componentName }
filePath={ filePath }
docPath={ docPath }
/>
) }
</Card>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ You can use [`card/example.md`](https://raw.githubusercontent.com/woocommerce/wc

## 4. Add your example to `client/devdocs/examples.json`

Keep these alphabetized. Optional properties here are `render` and `filePath`. `render` defaults to `My{ComponentName}`, and `filePath` defaults to `/docs/component/{component-name-as-slug}`.
Keep these alphabetized. Optional properties here are `render`, `filePath`, and `docPath`. `render` defaults to `My{ComponentName}`, and `filePath` defaults to `/docs/component/packages/{component-name-as-slug}`. `docPath` designates the origin of the component and efaults to `packages` for components from `/packages/components`.

Now you can visit `/wp-admin/admin.php?page=wc-admin#/devdocs` to see your component in action.

0 comments on commit e4fd10e

Please sign in to comment.