2015-03-05 02:10:12 +00:00
|
|
|
/**
|
2015-03-23 17:55:49 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
2015-03-05 02:10:12 +00:00
|
|
|
* @providesModule AutodocsLayout
|
|
|
|
*/
|
|
|
|
|
2016-06-21 21:22:44 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-05 02:10:12 +00:00
|
|
|
var DocsSidebar = require('DocsSidebar');
|
2017-03-02 02:39:40 +00:00
|
|
|
var Footer = require('Footer');
|
2015-03-05 02:10:12 +00:00
|
|
|
var Header = require('Header');
|
|
|
|
var Marked = require('Marked');
|
2017-03-02 02:39:40 +00:00
|
|
|
var Metadata = require('Metadata');
|
2015-03-31 19:28:26 +00:00
|
|
|
var Prism = require('Prism');
|
2015-03-05 02:10:12 +00:00
|
|
|
var React = require('React');
|
2017-04-12 23:09:48 +00:00
|
|
|
const PropTypes = require('prop-types');
|
2015-03-05 02:10:12 +00:00
|
|
|
var Site = require('Site');
|
2017-03-02 02:39:40 +00:00
|
|
|
|
2015-03-09 18:49:58 +00:00
|
|
|
var slugify = require('slugify');
|
2015-03-05 02:10:12 +00:00
|
|
|
|
2015-03-19 21:05:07 +00:00
|
|
|
var styleReferencePattern = /^[^.]+\.propTypes\.style$/;
|
2015-03-05 02:10:12 +00:00
|
|
|
|
2016-01-28 01:08:11 +00:00
|
|
|
function renderEnumValue(value) {
|
|
|
|
// Use single quote strings even when we are given double quotes
|
|
|
|
if (value.match(/^"(.+)"$/)) {
|
|
|
|
return "'" + value.slice(1, -1) + "'";
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
function renderType(type) {
|
2017-03-08 01:58:15 +00:00
|
|
|
const baseType = renderBaseType(type);
|
|
|
|
return type.nullable ? <span>?{baseType}</span> : baseType;
|
|
|
|
}
|
|
|
|
|
|
|
|
function spanJoinMapper(elements, callback, separator) {
|
|
|
|
return <span>{elements.map((rawElement, ii) => {
|
|
|
|
const el = callback(rawElement);
|
|
|
|
return (ii + 1 < elements.length) ? <span>{el}{separator}</span> : el;
|
|
|
|
})}</span>;
|
2017-03-02 02:39:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderBaseType(type) {
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'enum') {
|
|
|
|
if (typeof type.value === 'string') {
|
|
|
|
return type.value;
|
2015-03-09 20:25:01 +00:00
|
|
|
}
|
2016-01-28 01:08:11 +00:00
|
|
|
return 'enum(' + type.value.map((v) => renderEnumValue(v.value)).join(', ') + ')';
|
2015-09-01 19:41:51 +00:00
|
|
|
}
|
2015-03-09 20:25:01 +00:00
|
|
|
|
2016-04-09 18:12:46 +00:00
|
|
|
if (type.name === '$Enum') {
|
|
|
|
if (type.elements[0].signature.properties) {
|
|
|
|
return type.elements[0].signature.properties.map(p => `'${p.key}'`).join(' | ');
|
|
|
|
}
|
|
|
|
return type.name;
|
|
|
|
}
|
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'shape') {
|
2017-03-08 01:58:15 +00:00
|
|
|
return <span>{'{'}{spanJoinMapper(
|
|
|
|
Object.keys(type.value),
|
|
|
|
(key) => <span>{key + ': '}{renderType(type.value[key])}</span>,
|
|
|
|
', '
|
|
|
|
)}{'}'}</span>;
|
2015-09-01 19:41:51 +00:00
|
|
|
}
|
2015-03-09 20:25:01 +00:00
|
|
|
|
2016-03-13 10:03:22 +00:00
|
|
|
if (type.name === 'union') {
|
2016-04-09 18:12:46 +00:00
|
|
|
if (type.value) {
|
2017-03-08 01:58:15 +00:00
|
|
|
return spanJoinMapper(type.value, renderType, ', ');
|
2016-04-09 18:12:46 +00:00
|
|
|
}
|
2017-03-08 01:58:15 +00:00
|
|
|
return spanJoinMapper(type.elements, renderType, ' | ');
|
2015-09-01 19:41:51 +00:00
|
|
|
}
|
2015-05-06 18:05:47 +00:00
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'arrayOf') {
|
2016-03-13 10:03:22 +00:00
|
|
|
return <span>[{renderType(type.value)}]</span>;
|
2015-09-01 19:41:51 +00:00
|
|
|
}
|
2015-03-09 20:25:01 +00:00
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'instanceOf') {
|
|
|
|
return type.value;
|
|
|
|
}
|
2015-03-09 20:25:01 +00:00
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'custom') {
|
|
|
|
if (styleReferencePattern.test(type.raw)) {
|
|
|
|
var name = type.raw.substring(0, type.raw.indexOf('.'));
|
2016-03-13 10:03:22 +00:00
|
|
|
return <a href={'docs/' + slugify(name) + '.html#style'}>{name}#style</a>;
|
2015-03-09 20:25:01 +00:00
|
|
|
}
|
2016-01-29 03:36:54 +00:00
|
|
|
if (type.raw === 'ColorPropType') {
|
2016-03-13 10:03:22 +00:00
|
|
|
return <a href={'docs/colors.html'}>color</a>;
|
2016-01-29 03:36:54 +00:00
|
|
|
}
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.raw === 'EdgeInsetsPropType') {
|
|
|
|
return '{top: number, left: number, bottom: number, right: number}';
|
2015-03-19 21:05:07 +00:00
|
|
|
}
|
2015-09-01 19:41:51 +00:00
|
|
|
return type.raw;
|
|
|
|
}
|
2015-03-19 21:05:07 +00:00
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'stylesheet') {
|
|
|
|
return 'style';
|
|
|
|
}
|
2015-03-19 20:55:42 +00:00
|
|
|
|
2015-09-01 19:41:51 +00:00
|
|
|
if (type.name === 'func') {
|
|
|
|
return 'function';
|
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
|
|
|
if (type.name === 'signature') {
|
|
|
|
return type.raw;
|
|
|
|
}
|
|
|
|
|
2017-03-02 02:39:40 +00:00
|
|
|
return type.raw || type.name;
|
2015-09-01 19:41:51 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2016-06-21 21:22:44 +00:00
|
|
|
function renderTypeNameLink(typeName, docPath, namedTypes) {
|
|
|
|
const ignoreTypes = [
|
|
|
|
'string',
|
|
|
|
'number',
|
|
|
|
'boolean',
|
|
|
|
'object',
|
|
|
|
'function',
|
|
|
|
'array',
|
|
|
|
];
|
|
|
|
const typeNameLower = typeName.toLowerCase();
|
|
|
|
if (ignoreTypes.indexOf(typeNameLower) !== -1 || !namedTypes[typeNameLower]) {
|
|
|
|
return typeName;
|
|
|
|
}
|
|
|
|
return <a href={docPath + '#' + typeNameLower}>{typeName}</a>;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderTypeWithLinks(type, docTitle, namedTypes) {
|
|
|
|
if (!type || !type.names) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const docPath = docTitle ? 'docs/' + docTitle.toLowerCase() + '.html' : 'docs/';
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{
|
|
|
|
type.names.map((typeName, index, array) => {
|
2017-03-02 02:39:40 +00:00
|
|
|
const separator = index < array.length - 1 && ' | ';
|
2016-06-21 21:22:44 +00:00
|
|
|
return (
|
|
|
|
<span key={index}>
|
|
|
|
{renderTypeNameLink(typeName, docPath, namedTypes)}
|
|
|
|
{separator}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-01-25 17:52:51 +00:00
|
|
|
function sortByPlatform(props, nameA, nameB) {
|
|
|
|
var a = props[nameA];
|
|
|
|
var b = props[nameB];
|
|
|
|
|
|
|
|
if (a.platforms && !b.platforms) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (b.platforms && !a.platforms) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cheap hack: use < on arrays of strings to compare the two platforms
|
|
|
|
if (a.platforms < b.platforms) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (a.platforms > b.platforms) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nameA < nameB) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (nameA > nameB) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-09 18:12:46 +00:00
|
|
|
function removeCommentsFromDocblock(docblock) {
|
|
|
|
return docblock
|
|
|
|
.trim('\n ')
|
|
|
|
.replace(/^\/\*+/, '')
|
|
|
|
.replace(/\*\/$/, '')
|
|
|
|
.split('\n')
|
|
|
|
.map(function(line) {
|
|
|
|
return line.trim().replace(/^\* ?/, '');
|
|
|
|
})
|
|
|
|
.join('\n');
|
|
|
|
}
|
|
|
|
|
2016-06-21 21:22:44 +00:00
|
|
|
function getNamedTypes(typedefs) {
|
2017-03-02 02:39:40 +00:00
|
|
|
const namedTypes = {};
|
2016-06-21 21:22:44 +00:00
|
|
|
typedefs && typedefs.forEach(typedef => {
|
|
|
|
if (typedef.name) {
|
|
|
|
const type = typedef.name.toLowerCase();
|
|
|
|
namedTypes[type] = 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return namedTypes;
|
|
|
|
}
|
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
class ComponentDoc extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.extractPlatformFromProps = this.extractPlatformFromProps.bind(this);
|
|
|
|
this.renderCompose = this.renderCompose.bind(this);
|
|
|
|
this.renderStylesheetProp = this.renderStylesheetProp.bind(this);
|
|
|
|
this.renderStylesheetProps = this.renderStylesheetProps.bind(this);
|
|
|
|
this.renderMethod = this.renderMethod.bind(this);
|
|
|
|
this.renderMethods = this.renderMethods.bind(this);
|
|
|
|
this.renderProp = this.renderProp.bind(this);
|
|
|
|
this.renderProps = this.renderProps.bind(this);
|
|
|
|
this.renderTypeDef = this.renderTypeDef.bind(this);
|
|
|
|
this.renderTypeDefs = this.renderTypeDefs.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderProp(name, prop) {
|
2015-03-05 02:10:12 +00:00
|
|
|
return (
|
2015-03-09 18:49:58 +00:00
|
|
|
<div className="prop" key={name}>
|
2016-02-29 17:20:24 +00:00
|
|
|
<Header level={4} className="propTitle" toSlug={name}>
|
2015-08-07 17:31:07 +00:00
|
|
|
{prop.platforms && prop.platforms.map(platform =>
|
|
|
|
<span className="platform">{platform}</span>
|
|
|
|
)}
|
2015-03-05 02:10:12 +00:00
|
|
|
{name}
|
2017-03-02 02:39:40 +00:00
|
|
|
{prop.required ? ': ' : '?: '}
|
|
|
|
{(prop.type || prop.flowType) && <span className="propType">
|
|
|
|
{renderType(prop.flowType || prop.type)}
|
2015-03-09 20:25:01 +00:00
|
|
|
</span>}
|
2015-03-05 05:03:24 +00:00
|
|
|
</Header>
|
2016-01-29 10:04:44 +00:00
|
|
|
{prop.deprecationMessage && <div className="deprecated">
|
|
|
|
<div className="deprecatedTitle">
|
2016-02-11 14:16:34 +00:00
|
|
|
<img className="deprecatedIcon" src="img/Warning.png" />
|
2016-01-29 10:04:44 +00:00
|
|
|
<span>Deprecated</span>
|
|
|
|
</div>
|
|
|
|
<div className="deprecatedMessage">
|
|
|
|
<Marked>{prop.deprecationMessage}</Marked>
|
|
|
|
</div>
|
|
|
|
</div>}
|
2015-03-19 21:05:07 +00:00
|
|
|
{prop.type && prop.type.name === 'stylesheet' &&
|
|
|
|
this.renderStylesheetProps(prop.type.value)}
|
2015-03-05 05:03:24 +00:00
|
|
|
{prop.description && <Marked>{prop.description}</Marked>}
|
2015-03-05 02:10:12 +00:00
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderCompose(name) {
|
2015-03-09 18:49:58 +00:00
|
|
|
return (
|
|
|
|
<div className="prop" key={name}>
|
|
|
|
<Header level={4} className="propTitle" toSlug={name}>
|
2016-02-17 15:30:04 +00:00
|
|
|
<a href={'docs/' + slugify(name) + '.html#props'}>{name} props...</a>
|
2015-03-09 18:49:58 +00:00
|
|
|
</Header>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderStylesheetProp(name, prop) {
|
2016-01-25 17:52:51 +00:00
|
|
|
return (
|
|
|
|
<div className="prop" key={name}>
|
|
|
|
<h6 className="propTitle">
|
|
|
|
{prop.platforms && prop.platforms.map(platform =>
|
|
|
|
<span className="platform">{platform}</span>
|
|
|
|
)}
|
|
|
|
{name}
|
|
|
|
{' '}
|
|
|
|
{prop.type && <span className="propType">
|
|
|
|
{renderType(prop.type)}
|
|
|
|
</span>}
|
|
|
|
{' '}
|
|
|
|
{prop.description && <Marked>{prop.description}</Marked>}
|
|
|
|
</h6>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-01-25 17:52:51 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderStylesheetProps(stylesheetName) {
|
2015-03-19 21:05:07 +00:00
|
|
|
var style = this.props.content.styles[stylesheetName];
|
2016-01-25 17:52:51 +00:00
|
|
|
this.extractPlatformFromProps(style.props);
|
2015-03-19 21:05:07 +00:00
|
|
|
return (
|
|
|
|
<div className="compactProps">
|
|
|
|
{(style.composes || []).map((name) => {
|
|
|
|
var link;
|
2015-05-07 19:16:48 +00:00
|
|
|
if (name === 'LayoutPropTypes') {
|
2016-07-27 18:27:31 +00:00
|
|
|
name = 'Layout Props';
|
2015-03-19 21:05:07 +00:00
|
|
|
link =
|
2016-07-27 18:27:31 +00:00
|
|
|
<a href={'docs/' + slugify(name) + '.html#props'}>{name}...</a>;
|
|
|
|
} else if (name === 'ShadowPropTypesIOS') {
|
|
|
|
name = 'Shadow Props';
|
|
|
|
link =
|
|
|
|
<a href={'docs/' + slugify(name) + '.html#props'}>{name}...</a>;
|
2015-05-07 19:16:48 +00:00
|
|
|
} else if (name === 'TransformPropTypes') {
|
|
|
|
name = 'Transforms';
|
|
|
|
link =
|
2016-07-27 18:27:31 +00:00
|
|
|
<a href={'docs/' + slugify(name) + '.html#props'}>{name}...</a>;
|
2015-05-07 19:16:48 +00:00
|
|
|
} else {
|
|
|
|
name = name.replace('StylePropTypes', '');
|
|
|
|
link =
|
2016-02-16 00:59:49 +00:00
|
|
|
<a href={'docs/' + slugify(name) + '.html#style'}>{name}#style...</a>;
|
2015-03-19 21:05:07 +00:00
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="prop" key={name}>
|
|
|
|
<h6 className="propTitle">{link}</h6>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
2016-01-25 17:52:51 +00:00
|
|
|
{Object.keys(style.props)
|
|
|
|
.sort(sortByPlatform.bind(null, style.props))
|
|
|
|
.map((name) => this.renderStylesheetProp(name, style.props[name]))
|
|
|
|
}
|
2015-03-19 21:05:07 +00:00
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-19 21:05:07 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderProps(props, composes) {
|
2015-03-09 18:49:58 +00:00
|
|
|
return (
|
|
|
|
<div className="props">
|
|
|
|
{(composes || []).map((name) =>
|
|
|
|
this.renderCompose(name)
|
|
|
|
)}
|
2015-08-07 17:31:07 +00:00
|
|
|
{Object.keys(props)
|
2016-01-25 17:52:51 +00:00
|
|
|
.sort(sortByPlatform.bind(null, props))
|
|
|
|
.map((name) => this.renderProp(name, props[name]))
|
|
|
|
}
|
2015-03-09 18:49:58 +00:00
|
|
|
</div>
|
2015-03-05 02:10:12 +00:00
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
extractPlatformFromProps(props) {
|
2015-08-07 17:31:07 +00:00
|
|
|
for (var key in props) {
|
|
|
|
var prop = props[key];
|
|
|
|
var description = prop.description || '';
|
|
|
|
var platforms = description.match(/\@platform (.+)/);
|
|
|
|
platforms = platforms && platforms[1].replace(/ /g, '').split(',');
|
|
|
|
description = description.replace(/\@platform (.+)/, '');
|
|
|
|
|
|
|
|
prop.description = description;
|
|
|
|
prop.platforms = platforms;
|
|
|
|
}
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-08-07 17:31:07 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethod(method, namedTypes) {
|
2016-04-09 18:12:46 +00:00
|
|
|
return (
|
|
|
|
<Method
|
|
|
|
key={method.name}
|
|
|
|
name={method.name}
|
|
|
|
description={method.description}
|
|
|
|
params={method.params}
|
2016-06-21 21:22:44 +00:00
|
|
|
modifiers={method.scope ? [method.scope] : method.modifiers}
|
|
|
|
examples={method.examples}
|
2016-04-09 18:12:46 +00:00
|
|
|
returns={method.returns}
|
2016-06-21 21:22:44 +00:00
|
|
|
namedTypes={namedTypes}
|
2017-07-23 16:43:19 +00:00
|
|
|
entityName={this.props.componentName}
|
2016-04-09 18:12:46 +00:00
|
|
|
/>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethods(methods, namedTypes) {
|
2016-04-09 18:12:46 +00:00
|
|
|
if (!methods || !methods.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Methods</Header>
|
2016-04-09 18:12:46 +00:00
|
|
|
<div className="props">
|
|
|
|
{methods.filter((method) => {
|
|
|
|
return method.name[0] !== '_';
|
2016-06-21 21:22:44 +00:00
|
|
|
}).map(method => this.renderMethod(method, namedTypes))}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderTypeDef(typedef, namedTypes) {
|
2016-06-21 21:22:44 +00:00
|
|
|
return (
|
|
|
|
<TypeDef
|
|
|
|
key={typedef.name}
|
|
|
|
name={typedef.name}
|
|
|
|
description={typedef.description}
|
|
|
|
type={typedef.type}
|
|
|
|
properties={typedef.properties}
|
|
|
|
values={typedef.values}
|
|
|
|
apiName={this.props.apiName}
|
|
|
|
namedTypes={namedTypes}
|
|
|
|
/>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderTypeDefs(typedefs, namedTypes) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!typedefs || !typedefs.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Type Definitions</Header>
|
2016-06-21 21:22:44 +00:00
|
|
|
<div className="props">
|
|
|
|
{typedefs.map((typedef) => {
|
|
|
|
return this.renderTypeDef(typedef, namedTypes);
|
|
|
|
})}
|
2016-04-09 18:12:46 +00:00
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
render() {
|
2015-03-12 18:03:32 +00:00
|
|
|
var content = this.props.content;
|
2015-08-07 17:31:07 +00:00
|
|
|
this.extractPlatformFromProps(content.props);
|
2016-06-21 21:22:44 +00:00
|
|
|
const namedTypes = getNamedTypes(content.typedef);
|
2015-03-12 18:03:32 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Marked>
|
|
|
|
{content.description}
|
|
|
|
</Marked>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Props</Header>
|
2015-03-12 18:03:32 +00:00
|
|
|
{this.renderProps(content.props, content.composes)}
|
2016-06-21 21:22:44 +00:00
|
|
|
{this.renderMethods(content.methods, namedTypes)}
|
|
|
|
{this.renderTypeDefs(content.typedef, namedTypes)}
|
2015-03-12 18:03:32 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class APIDoc extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.renderMethod = this.renderMethod.bind(this);
|
|
|
|
this.renderMethods = this.renderMethods.bind(this);
|
|
|
|
this.renderProperty = this.renderProperty.bind(this);
|
|
|
|
this.renderProperties = this.renderProperties.bind(this);
|
|
|
|
this.renderClasses = this.renderClasses.bind(this);
|
|
|
|
this.renderTypeDef = this.renderTypeDef.bind(this);
|
|
|
|
this.renderTypeDefs = this.renderTypeDefs.bind(this);
|
|
|
|
this.renderMainDescription = this.renderMainDescription.bind(this);
|
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethod(method, namedTypes) {
|
2015-03-12 18:03:32 +00:00
|
|
|
return (
|
2016-04-09 18:12:46 +00:00
|
|
|
<Method
|
|
|
|
key={method.name}
|
|
|
|
name={method.name}
|
2016-06-21 21:22:44 +00:00
|
|
|
description={method.description || method.docblock && removeCommentsFromDocblock(method.docblock)}
|
2016-04-09 18:12:46 +00:00
|
|
|
params={method.params}
|
2016-06-21 21:22:44 +00:00
|
|
|
modifiers={method.scope ? [method.scope] : method.modifiers}
|
|
|
|
examples={method.examples}
|
2017-07-23 16:43:19 +00:00
|
|
|
entityName={this.props.apiName}
|
2016-06-21 21:22:44 +00:00
|
|
|
namedTypes={namedTypes}
|
2016-04-09 18:12:46 +00:00
|
|
|
/>
|
2015-03-12 18:03:32 +00:00
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethods(methods, namedTypes) {
|
2015-03-25 21:26:46 +00:00
|
|
|
if (!methods.length) {
|
|
|
|
return null;
|
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
return (
|
2015-03-25 21:26:46 +00:00
|
|
|
<span>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Methods</Header>
|
2015-03-25 21:26:46 +00:00
|
|
|
<div className="props">
|
|
|
|
{methods.filter((method) => {
|
|
|
|
return method.name[0] !== '_';
|
2016-06-21 21:22:44 +00:00
|
|
|
}).map(method => this.renderMethod(method, namedTypes))}
|
2015-03-25 21:26:46 +00:00
|
|
|
</div>
|
|
|
|
</span>
|
2015-03-12 18:03:32 +00:00
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderProperty(property) {
|
2015-09-01 19:41:51 +00:00
|
|
|
return (
|
|
|
|
<div className="prop" key={property.name}>
|
|
|
|
<Header level={4} className="propTitle" toSlug={property.name}>
|
|
|
|
{property.name}
|
2017-03-02 02:39:40 +00:00
|
|
|
{(property.type || property.flowType) &&
|
2015-09-01 19:41:51 +00:00
|
|
|
<span className="propType">
|
2017-03-02 02:39:40 +00:00
|
|
|
{': ' + renderType(property.flowType || property.type)}
|
2015-09-01 19:41:51 +00:00
|
|
|
</span>
|
|
|
|
}
|
|
|
|
</Header>
|
|
|
|
{property.docblock && <Marked>
|
2016-04-09 18:12:46 +00:00
|
|
|
{removeCommentsFromDocblock(property.docblock)}
|
2015-09-01 19:41:51 +00:00
|
|
|
</Marked>}
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-09-01 19:41:51 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderProperties(properties) {
|
2015-09-01 19:41:51 +00:00
|
|
|
if (!properties || !properties.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Properties</Header>
|
2015-09-01 19:41:51 +00:00
|
|
|
<div className="props">
|
|
|
|
{properties.filter((property) => {
|
|
|
|
return property.name[0] !== '_';
|
|
|
|
}).map(this.renderProperty)}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-09-01 19:41:51 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderClasses(classes, namedTypes) {
|
2015-09-01 19:41:51 +00:00
|
|
|
if (!classes || !classes.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<div>
|
|
|
|
{classes.filter((cls) => {
|
|
|
|
return cls.name[0] !== '_' && cls.ownerProperty[0] !== '_';
|
|
|
|
}).map((cls) => {
|
|
|
|
return (
|
|
|
|
<span key={cls.name}>
|
|
|
|
<Header level={2} toSlug={cls.name}>
|
|
|
|
class {cls.name}
|
|
|
|
</Header>
|
2017-07-21 19:32:15 +00:00
|
|
|
<div>
|
2015-09-03 18:52:55 +00:00
|
|
|
{cls.docblock && <Marked>
|
2016-04-09 18:12:46 +00:00
|
|
|
{removeCommentsFromDocblock(cls.docblock)}
|
2015-09-03 18:52:55 +00:00
|
|
|
</Marked>}
|
2016-06-21 21:22:44 +00:00
|
|
|
{this.renderMethods(cls.methods, namedTypes)}
|
2015-09-01 19:41:51 +00:00
|
|
|
{this.renderProperties(cls.properties)}
|
2017-07-21 19:32:15 +00:00
|
|
|
</div>
|
2015-09-01 19:41:51 +00:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-09-01 19:41:51 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderTypeDef(typedef, namedTypes) {
|
2016-06-21 21:22:44 +00:00
|
|
|
return (
|
|
|
|
<TypeDef
|
|
|
|
key={typedef.name}
|
|
|
|
name={typedef.name}
|
|
|
|
description={typedef.description}
|
|
|
|
type={typedef.type}
|
|
|
|
properties={typedef.properties}
|
|
|
|
values={typedef.values}
|
|
|
|
apiName={this.props.apiName}
|
|
|
|
namedTypes={namedTypes}
|
|
|
|
/>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderTypeDefs(typedefs, namedTypes) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!typedefs || !typedefs.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={3}>Type Definitions</Header>
|
2016-06-21 21:22:44 +00:00
|
|
|
<div className="props">
|
|
|
|
{typedefs.map((typedef) => {
|
|
|
|
return this.renderTypeDef(typedef, namedTypes);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
};
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMainDescription(content) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (content.docblock) {
|
|
|
|
return (
|
|
|
|
<Marked>
|
|
|
|
{removeCommentsFromDocblock(content.docblock)}
|
|
|
|
</Marked>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (content.class && content.class.length && content.class[0].description) {
|
|
|
|
return (
|
|
|
|
<Marked>
|
|
|
|
{content.class[0].description}
|
|
|
|
</Marked>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
render() {
|
2015-03-12 18:03:32 +00:00
|
|
|
var content = this.props.content;
|
|
|
|
if (!content.methods) {
|
2015-04-06 22:22:43 +00:00
|
|
|
throw new Error(
|
|
|
|
'No component methods found for ' + content.componentName
|
|
|
|
);
|
2015-03-12 18:03:32 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
const namedTypes = getNamedTypes(content.typedef);
|
2015-03-12 18:03:32 +00:00
|
|
|
return (
|
|
|
|
<div>
|
2016-06-21 21:22:44 +00:00
|
|
|
{this.renderMainDescription(content)}
|
|
|
|
{this.renderMethods(content.methods, namedTypes)}
|
2015-09-01 19:41:51 +00:00
|
|
|
{this.renderProperties(content.properties)}
|
2016-06-21 21:22:44 +00:00
|
|
|
{this.renderClasses(content.classes, namedTypes)}
|
|
|
|
{this.renderTypeDefs(content.typedef, namedTypes)}
|
2015-03-12 18:03:32 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class Method extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
2015-03-12 18:03:32 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
this.renderTypehint = this.renderTypehint.bind(this);
|
|
|
|
this.renderTypehintRec = this.renderTypehintRec.bind(this);
|
|
|
|
this.renderMethodExamples = this.renderMethodExamples.bind(this);
|
|
|
|
this.renderMethodParameters = this.renderMethodParameters.bind(this);
|
|
|
|
}
|
|
|
|
renderTypehintRec(typehint) {
|
2016-04-09 18:12:46 +00:00
|
|
|
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);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderTypehint(typehint) {
|
2016-04-09 18:12:46 +00:00
|
|
|
if (typeof typehint === 'object' && typehint.name) {
|
|
|
|
return renderType(typehint);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
var typehint = JSON.parse(typehint);
|
|
|
|
} catch (e) {
|
|
|
|
return typehint;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.renderTypehintRec(typehint);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethodExamples(examples) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!examples || !examples.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return examples.map((example) => {
|
|
|
|
const re = /<caption>(.*?)<\/caption>/ig;
|
|
|
|
const result = re.exec(example);
|
|
|
|
const caption = result ? result[1] + ':' : 'Example:';
|
|
|
|
const code = example.replace(/<caption>.*?<\/caption>/ig, '')
|
|
|
|
.replace(/^\n\n/, '');
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<br/>
|
|
|
|
{caption}
|
|
|
|
<Prism>
|
|
|
|
{code}
|
|
|
|
</Prism>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|
2017-07-25 17:12:58 +00:00
|
|
|
};
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderMethodParameters(params) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!params || !params.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!params[0].type || !params[0].type.names) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const foundDescription = params.find(p => p.description);
|
|
|
|
if (!foundDescription) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-07-23 16:43:19 +00:00
|
|
|
|
2016-06-21 21:22:44 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<strong>Parameters:</strong>
|
|
|
|
<table className="params">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name and Type</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{params.map((param) => {
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{param.optional ? '[' + param.name + ']' : param.name}
|
|
|
|
<br/><br/>
|
2017-07-23 16:43:19 +00:00
|
|
|
{renderTypeWithLinks(param.type, this.props.entityName, this.props.namedTypes)}
|
2016-06-21 21:22:44 +00:00
|
|
|
</td>
|
|
|
|
<td className="description"><Marked>{param.description}</Marked></td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
render() {
|
2016-04-09 18:12:46 +00:00
|
|
|
return (
|
|
|
|
<div className="prop">
|
2016-06-27 15:18:05 +00:00
|
|
|
<Header level={4} className="methodTitle" toSlug={this.props.name}>
|
|
|
|
{this.props.modifiers && this.props.modifiers.length && <span className="methodType">
|
2016-04-09 18:12:46 +00:00
|
|
|
{this.props.modifiers.join(' ') + ' '}
|
|
|
|
</span> || ''}
|
|
|
|
{this.props.name}
|
2016-06-27 15:18:05 +00:00
|
|
|
<span className="methodType">
|
2017-03-02 02:39:40 +00:00
|
|
|
({(this.props.params && this.props.params.length && this.props.params
|
2016-04-09 18:12:46 +00:00
|
|
|
.map((param) => {
|
|
|
|
var res = param.name;
|
2016-06-21 21:22:44 +00:00
|
|
|
res += param.optional ? '?' : '';
|
2017-03-02 02:39:40 +00:00
|
|
|
param.type && param.type.names && (res += ': ' + param.type.names.join(', '));
|
2016-04-09 18:12:46 +00:00
|
|
|
return res;
|
|
|
|
})
|
2017-03-02 02:39:40 +00:00
|
|
|
.join(', ')) || ''})
|
2016-04-09 18:12:46 +00:00
|
|
|
{this.props.returns && ': ' + this.renderTypehint(this.props.returns.type)}
|
|
|
|
</span>
|
|
|
|
</Header>
|
|
|
|
{this.props.description && <Marked>
|
|
|
|
{this.props.description}
|
|
|
|
</Marked>}
|
2016-06-21 21:22:44 +00:00
|
|
|
{this.renderMethodParameters(this.props.params)}
|
|
|
|
{this.renderMethodExamples(this.props.examples)}
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TypeDef extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.renderProperties = this.renderProperties.bind(this);
|
|
|
|
this.renderValues = this.renderValues.bind(this);
|
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderProperties(properties) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!properties || !properties.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!properties[0].type || !properties[0].type.names) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<br/>
|
|
|
|
<strong>Properties:</strong>
|
|
|
|
<table className="params">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name and Type</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{properties.map((property) => {
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{property.optional ? '[' + property.name + ']' : property.name}
|
|
|
|
<br/><br/>
|
|
|
|
{renderTypeWithLinks(property.type, this.props.apiName, this.props.namedTypes)}
|
|
|
|
</td>
|
|
|
|
<td className="description"><Marked>{property.description}</Marked></td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderValues(values) {
|
2016-06-21 21:22:44 +00:00
|
|
|
if (!values || !values.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!values[0].type || !values[0].type.names) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<br/>
|
|
|
|
<strong>Constants:</strong>
|
|
|
|
<table className="params">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{values.map((value) => {
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{value.name}
|
|
|
|
</td>
|
|
|
|
<td className="description"><Marked>{value.description}</Marked></td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-06-21 21:22:44 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
render() {
|
2016-06-21 21:22:44 +00:00
|
|
|
return (
|
|
|
|
<div className="prop">
|
|
|
|
<Header level={4} className="propTitle" toSlug={this.props.name}>
|
|
|
|
{this.props.name}
|
|
|
|
</Header>
|
|
|
|
{this.props.description && <Marked>
|
|
|
|
{this.props.description}
|
|
|
|
</Marked>}
|
|
|
|
<strong>Type:</strong>
|
|
|
|
<br/>
|
|
|
|
{this.props.type.names.join(' | ')}
|
|
|
|
{this.renderProperties(this.props.properties)}
|
|
|
|
{this.renderValues(this.props.values)}
|
2016-04-09 18:12:46 +00:00
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 18:12:46 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
class Autodocs extends React.Component {
|
|
|
|
contsructor(props, context) {
|
|
|
|
super(props, context);
|
2016-02-29 17:20:24 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
this.renderFullDescription = this.renderFullDescription.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
getChildContext() {
|
2016-05-07 15:35:11 +00:00
|
|
|
return {
|
|
|
|
permalink: this.props.metadata.permalink,
|
|
|
|
version: Metadata.config.RN_VERSION || 'next'
|
|
|
|
};
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2016-02-29 17:20:24 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
renderFullDescription(docs) {
|
2015-03-31 17:10:05 +00:00
|
|
|
if (!docs.fullDescription) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={1}>Description</Header>
|
2015-03-31 17:10:05 +00:00
|
|
|
<Marked>
|
|
|
|
{docs.fullDescription}
|
|
|
|
</Marked>
|
2016-08-04 00:37:13 +00:00
|
|
|
<Footer path={'docs/' + docs.componentName + '.md'} />
|
2015-03-31 17:10:05 +00:00
|
|
|
</div>
|
|
|
|
);
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
2015-03-31 17:10:05 +00:00
|
|
|
|
2017-07-25 17:12:58 +00:00
|
|
|
render() {
|
2015-03-05 02:10:12 +00:00
|
|
|
var metadata = this.props.metadata;
|
2015-03-19 21:05:07 +00:00
|
|
|
var docs = JSON.parse(this.props.children);
|
2017-07-23 16:43:19 +00:00
|
|
|
var content = docs.type === 'component' || docs.type === 'style'
|
|
|
|
? <ComponentDoc content={docs} componentName={metadata.title} />
|
|
|
|
: <APIDoc content={docs} apiName={metadata.title} />;
|
2015-03-19 21:05:07 +00:00
|
|
|
|
2015-03-05 02:10:12 +00:00
|
|
|
return (
|
2016-08-30 06:08:50 +00:00
|
|
|
<Site
|
|
|
|
section="docs"
|
2016-08-30 17:56:48 +00:00
|
|
|
title={metadata.title} >
|
2015-03-05 02:10:12 +00:00
|
|
|
<section className="content wrap documentationContent">
|
|
|
|
<DocsSidebar metadata={metadata} />
|
|
|
|
<div className="inner-content">
|
|
|
|
<a id="content" />
|
2016-08-04 00:37:13 +00:00
|
|
|
<Header level={1}>{metadata.title}</Header>
|
2015-03-19 21:05:07 +00:00
|
|
|
{content}
|
2016-08-04 00:37:13 +00:00
|
|
|
<Footer path={metadata.path} />
|
2015-03-31 17:10:05 +00:00
|
|
|
{this.renderFullDescription(docs)}
|
2015-03-05 02:10:12 +00:00
|
|
|
<div className="docs-prevnext">
|
2016-02-17 15:30:04 +00:00
|
|
|
{metadata.previous && <a className="docs-prev" href={'docs/' + metadata.previous + '.html#content'}>← Prev</a>}
|
|
|
|
{metadata.next && <a className="docs-next" href={'docs/' + metadata.next + '.html#content'}>Next →</a>}
|
2015-03-05 02:10:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</Site>
|
|
|
|
);
|
|
|
|
}
|
2017-07-25 17:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Autodocs.childContextTypes = {
|
|
|
|
permalink: PropTypes.string,
|
|
|
|
version: PropTypes.string
|
|
|
|
};
|
2015-03-05 02:10:12 +00:00
|
|
|
|
|
|
|
module.exports = Autodocs;
|