mirror of
https://github.com/encounter/react-add-to-calendar.git
synced 2026-07-10 21:18:44 -07:00
Revert "Publish new docs (automated commit)"
This reverts commit ed2526c801.
This commit is contained in:
Executable
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 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.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
function stringOfLength(string, length) {
|
||||
var newString = '';
|
||||
for (var i = 0; i < length; i++) {
|
||||
newString += string;
|
||||
}
|
||||
return newString;
|
||||
}
|
||||
|
||||
function generateTitle(name) {
|
||||
var title = '`' + name + '` (component)';
|
||||
return title + '\n' + stringOfLength('=', title.length) + '\n';
|
||||
}
|
||||
|
||||
function generateDesciption(description) {
|
||||
return description + '\n';
|
||||
}
|
||||
|
||||
function generatePropType(type) {
|
||||
var values;
|
||||
if (Array.isArray(type.value)) {
|
||||
values = '(' +
|
||||
type.value.map(function(typeValue) {
|
||||
return typeValue.name || typeValue.value;
|
||||
}).join('|') +
|
||||
')';
|
||||
} else {
|
||||
values = type.value;
|
||||
}
|
||||
|
||||
return 'type: `' + type.name + (values ? values: '') + '`\n';
|
||||
}
|
||||
|
||||
function generatePropDefaultValue(value) {
|
||||
return 'defaultValue: `' + value.value + '`\n';
|
||||
}
|
||||
|
||||
function generateProp(propName, prop) {
|
||||
return (
|
||||
'### `' + propName + '`' + (prop.required ? ' (required)' : '') + '\n' +
|
||||
'\n' +
|
||||
(prop.description ? prop.description + '\n\n' : '') +
|
||||
(prop.type ? generatePropType(prop.type) : '') +
|
||||
(prop.defaultValue ? generatePropDefaultValue(prop.defaultValue) : '') +
|
||||
'\n'
|
||||
);
|
||||
}
|
||||
|
||||
function generateProps(props) {
|
||||
var title = 'Props';
|
||||
|
||||
return (
|
||||
title + '\n' +
|
||||
stringOfLength('-', title.length) + '\n' +
|
||||
'\n' +
|
||||
Object.keys(props).sort().map(function(propName) {
|
||||
return generateProp(propName, props[propName]);
|
||||
}).join('\n')
|
||||
);
|
||||
}
|
||||
|
||||
function generateMarkdown(name, reactAPI) {
|
||||
var markdownString =
|
||||
generateTitle(name) + '\n' +
|
||||
generateDesciption(reactAPI.description) + '\n' +
|
||||
generateProps(reactAPI.props);
|
||||
|
||||
return markdownString;
|
||||
}
|
||||
|
||||
module.exports = generateMarkdown;
|
||||
Reference in New Issue
Block a user