mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 10:31:53 +08:00
add ember support for docs-mode
This commit is contained in:
parent
ab16256732
commit
b54a15b934
10
addons/docs/src/frameworks/ember/config.js
Normal file
10
addons/docs/src/frameworks/ember/config.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
import { addParameters } from '@storybook/client-api';
|
||||||
|
import { extractProps, extractComponentDescription } from './jsondoc';
|
||||||
|
|
||||||
|
addParameters({
|
||||||
|
docs: {
|
||||||
|
extractProps,
|
||||||
|
extractComponentDescription,
|
||||||
|
},
|
||||||
|
});
|
27
addons/docs/src/frameworks/ember/jsondoc.js
Normal file
27
addons/docs/src/frameworks/ember/jsondoc.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
/* global window */
|
||||||
|
|
||||||
|
function getJSONDoc() {
|
||||||
|
return window.__EMBER_GENERATED_DOC_JSON__;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const extractProps = componentName => {
|
||||||
|
const json = getJSONDoc();
|
||||||
|
const componentDoc = json.included.find(doc => doc.attributes.name === componentName);
|
||||||
|
const rows = componentDoc.attributes.arguments.map(prop => {
|
||||||
|
return {
|
||||||
|
name: prop.name,
|
||||||
|
type: prop.type,
|
||||||
|
required: prop.tags.length ? prop.tags.some(tag => tag.name === 'required') : false,
|
||||||
|
defaultValue: prop.defaultValue,
|
||||||
|
description: prop.description,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return { rows };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const extractComponentDescription = componentName => {
|
||||||
|
const json = getJSONDoc();
|
||||||
|
const componentDoc = json.included.find(doc => doc.attributes.name === componentName);
|
||||||
|
return componentDoc.attributes.description;
|
||||||
|
};
|
@ -9,6 +9,8 @@ export {
|
|||||||
raw,
|
raw,
|
||||||
} from './preview';
|
} from './preview';
|
||||||
|
|
||||||
|
export { setJSONDoc } from './jsondoc';
|
||||||
|
|
||||||
if (module && module.hot && module.hot.decline) {
|
if (module && module.hot && module.hot.decline) {
|
||||||
module.hot.decline();
|
module.hot.decline();
|
||||||
}
|
}
|
||||||
|
6
app/ember/src/client/jsondoc.js
Normal file
6
app/ember/src/client/jsondoc.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
/* global window */
|
||||||
|
|
||||||
|
export function setJSONDoc(jsondoc) {
|
||||||
|
window.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user