/** * @providesModule AutodocsLayout * @jsx React.DOM */ var DocsSidebar = require('DocsSidebar'); var H = require('Header'); var Header = require('Header'); var Marked = require('Marked'); var React = require('React'); var Site = require('Site'); var slugify = require('slugify'); var ComponentDoc = React.createClass({ renderType: function(type) { if (type.name === 'enum') { if (typeof type.value === 'string') { return type.value; } return 'enum(' + type.value.map((v => v.value)).join(', ') + ')'; } if (type.name === 'shape') { return '{' + Object.keys(type.value).map((key => key + ': ' + this.renderType(type.value[key]))).join(', ') + '}'; } if (type.name === 'arrayOf') { return '[' + this.renderType(type.value) + ']'; } if (type.name === 'instanceOf') { return type.value; } if (type.name === 'custom') { if (type.raw === 'EdgeInsetsPropType') { return '{top: number, left: number, bottom: number, right: number}'; } return type.raw; } if (type.name === 'func') { return 'function'; } return type.name; }, renderProp: function(name, prop) { return (
{name} {' '} {prop.type && {this.renderType(prop.type)} }
{prop.description && {prop.description}}
); }, renderCompose: function(name) { return (
{name} props...
); }, renderProps: function(props, composes) { return (
{(composes || []).map((name) => this.renderCompose(name) )} {Object.keys(props).sort().map((name) => this.renderProp(name, props[name]) )}
); }, render: function() { var content = this.props.content; return (
{content.description} Props {this.renderProps(content.props, content.composes)}
); } }); var APIDoc = React.createClass({ removeCommentsFromDocblock: function(docblock) { return docblock .trim('\n ') .replace(/^\/\*+/, '') .replace(/\*\/$/, '') .split('\n') .map(function(line) { return line.trim().replace(/^\* ?/, ''); }) .join('\n'); }, renderTypehintRec: function(typehint) { if (typehint.type === 'simple') { return typehint.value; } if (typehint.type === 'generic') { return this.renderTypehintRec(typehint.value[0]) + '<' + this.renderTypehintRec(typehint.value[1]) + '>'; } return JSON.stringify(typehint); }, renderTypehint: function(typehint) { try { var typehint = JSON.parse(typehint); } catch(e) { return typehint; } return this.renderTypehintRec(typehint); }, renderMethod: function(method) { return (
{method.modifiers.length && {method.modifiers.join(' ') + ' '} } {method.name} ({method.params .map((param) => { var res = param.name; if (param.typehint) { res += ': ' + this.renderTypehint(param.typehint); } return res; }) .join(', ')})
{method.docblock && {this.removeCommentsFromDocblock(method.docblock)} }
); }, renderMethods: function(methods) { return (
{methods.map(this.renderMethod)}
); }, render: function() { var content = this.props.content; if (!content.methods) { return
Error
; } return (
{this.removeCommentsFromDocblock(content.docblock)} Methods {this.renderMethods(content.methods)}
); } }); var Autodocs = React.createClass({ render: function() { var metadata = this.props.metadata; var content = JSON.parse(this.props.children); return (

{metadata.title}

{content.type === 'component' ? : } {content.fullDescription}
{metadata.previous && ← Prev} {metadata.next && Next →}
); } }); module.exports = Autodocs;