import * as _ from 'lodash'; import * as React from 'react'; import * as ReactMarkdown from 'react-markdown'; import {Chip} from 'material-ui/Chip'; import {colors} from 'material-ui/styles'; import { TypeDocNode, Styles, TypeDefinitionByName, TypescriptMethod, SolidityMethod, Parameter, HeaderSizes, } from 'ts/types'; import {utils} from 'ts/utils/utils'; import {SourceLink} from 'ts/pages/documentation/source_link'; import {MethodSignature} from 'ts/pages/documentation/method_signature'; import {AnchorTitle} from 'ts/pages/shared/anchor_title'; import {Comment} from 'ts/pages/documentation/comment'; import {typeDocUtils} from 'ts/utils/typedoc_utils'; interface MethodBlockProps { method: SolidityMethod|TypescriptMethod; libraryVersion: string; typeDefinitionByName: TypeDefinitionByName; } interface MethodBlockState { shouldShowAnchor: boolean; } const styles: Styles = { chip: { fontSize: 13, backgroundColor: colors.lightBlueA700, color: 'white', height: 11, borderRadius: 14, marginTop: 19, lineHeight: 0.8, }, }; export class MethodBlock extends React.Component { constructor(props: MethodBlockProps) { super(props); this.state = { shouldShowAnchor: false, }; } public render() { const method = this.props.method; if (typeDocUtils.isPrivateOrProtectedProperty(method.name)) { return null; } return (
{!method.isConstructor &&
{(method as TypescriptMethod).isStatic && this.renderChip('Static') } {(method as SolidityMethod).isConstant && this.renderChip('Constant') } {(method as SolidityMethod).isPayable && this.renderChip('Payable') }
} {(method as TypescriptMethod).source && } {method.comment && } {method.parameters && !_.isEmpty(method.parameters) &&

ARGUMENTS

{this.renderParameterDescriptions(method.parameters)}
} {method.returnComment &&

RETURNS

}
); } private renderChip(text: string) { return (
{text}
); } private renderParameterDescriptions(parameters: Parameter[]) { const descriptions = _.map(parameters, parameter => { const isOptional = parameter.isOptional; return (
{parameter.name}
{isOptional && 'optional'}
{parameter.comment && }
); }); return descriptions; } private setAnchorVisibility(shouldShowAnchor: boolean) { this.setState({ shouldShowAnchor, }); } }