Gatsby setup for API docs

This commit is contained in:
Tim Schaub
2019-05-11 11:20:33 -06:00
parent 2322131b01
commit 5ee3063d01
18 changed files with 639 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
import {object} from 'prop-types';
import React from 'react';
import Markdown from 'react-markdown';
import Code from './Code';
function Class({cls, module}) {
const exportedName = module.getExportedName(cls.name);
let importCode;
if (exportedName === 'default') {
importCode = `import ${cls.name} from '${module.id}';`;
} else {
importCode = `import {${exportedName}} from '${module.id}';`;
}
return (
<div>
<h3>{cls.name}</h3>
<Code value={importCode} />
<Markdown source={cls.doc.classdesc} renderers={{code: Code}} />
</div>
);
}
Class.propTypes = {
cls: object.isRequired,
module: object.isRequired
};
export default Class;