Apply prettier config

This commit is contained in:
Leonid Logvinov
2017-12-22 15:05:32 +01:00
parent 9a96e8c704
commit e744e4cd98
284 changed files with 6783 additions and 6205 deletions

View File

@@ -1,12 +1,12 @@
import * as _ from 'lodash';
import * as React from 'react';
import {DocsInfo} from 'ts/pages/documentation/docs_info';
import {Type} from 'ts/pages/documentation/type';
import {Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod} from 'ts/types';
import {constants} from 'ts/utils/constants';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Type } from 'ts/pages/documentation/type';
import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from 'ts/types';
import { constants } from 'ts/utils/constants';
interface MethodSignatureProps {
method: TypescriptMethod|SolidityMethod;
method: TypescriptMethod | SolidityMethod;
sectionName: string;
shouldHideMethodName?: boolean;
shouldUseArrowSyntax?: boolean;
@@ -21,31 +21,28 @@ const defaultProps = {
export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSignatureProps) => {
const sectionName = constants.TYPES_SECTION_NAME;
const parameters = renderParameters(
props.method, props.docsInfo, sectionName, props.typeDefinitionByName,
);
const parameters = renderParameters(props.method, props.docsInfo, sectionName, props.typeDefinitionByName);
const paramString = _.reduce(parameters, (prev: React.ReactNode, curr: React.ReactNode) => {
return [prev, ', ', curr];
});
const methodName = props.shouldHideMethodName ? '' : props.method.name;
const typeParameterIfExists = _.isUndefined((props.method as TypescriptMethod).typeParameter) ?
undefined :
renderTypeParameter(
props.method, props.docsInfo, sectionName, props.typeDefinitionByName,
);
const typeParameterIfExists = _.isUndefined((props.method as TypescriptMethod).typeParameter)
? undefined
: renderTypeParameter(props.method, props.docsInfo, sectionName, props.typeDefinitionByName);
return (
<span>
{props.method.callPath}{methodName}{typeParameterIfExists}({paramString})
{props.shouldUseArrowSyntax ? ' => ' : ': '}
{' '}
{props.method.returnType &&
{props.method.callPath}
{methodName}
{typeParameterIfExists}({paramString})
{props.shouldUseArrowSyntax ? ' => ' : ': '}{' '}
{props.method.returnType && (
<Type
type={props.method.returnType}
sectionName={sectionName}
typeDefinitionByName={props.typeDefinitionByName}
docsInfo={props.docsInfo}
/>
}
)}
</span>
);
};
@@ -53,8 +50,10 @@ export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSi
MethodSignature.defaultProps = defaultProps;
function renderParameters(
method: TypescriptMethod|SolidityMethod, docsInfo: DocsInfo,
sectionName: string, typeDefinitionByName?: TypeDefinitionByName,
method: TypescriptMethod | SolidityMethod,
docsInfo: DocsInfo,
sectionName: string,
typeDefinitionByName?: TypeDefinitionByName,
) {
const parameters = method.parameters;
const params = _.map(parameters, (p: Parameter) => {
@@ -69,7 +68,8 @@ function renderParameters(
);
return (
<span key={`param-${p.type}-${p.name}`}>
{p.name}{isOptional && '?'}: {type}
{p.name}
{isOptional && '?'}: {type}
</span>
);
});
@@ -77,19 +77,21 @@ function renderParameters(
}
function renderTypeParameter(
method: TypescriptMethod, docsInfo: DocsInfo,
sectionName: string, typeDefinitionByName?: TypeDefinitionByName,
method: TypescriptMethod,
docsInfo: DocsInfo,
sectionName: string,
typeDefinitionByName?: TypeDefinitionByName,
) {
const typeParameter = method.typeParameter;
const typeParam = (
<span>
{`<${typeParameter.name} extends `}
<Type
type={typeParameter.type}
sectionName={sectionName}
typeDefinitionByName={typeDefinitionByName}
docsInfo={docsInfo}
/>
<Type
type={typeParameter.type}
sectionName={sectionName}
typeDefinitionByName={typeDefinitionByName}
docsInfo={docsInfo}
/>
{`>`}
</span>
);