diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-02 20:23:07 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-02 20:23:07 +0800 |
commit | 8162394797342cef268cc8072fc860326974e269 (patch) | |
tree | 2826b02715a8cb794571be6c7dccdb395329361c /packages/react-docs/src/components/documentation.tsx | |
parent | fd001186dd281a11920246c6b9afcefe1d55bc23 (diff) | |
parent | 695b697cdf6c73bb4b5f920869ce128f9a9e7523 (diff) | |
download | dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar.gz dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar.bz2 dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar.lz dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar.xz dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.tar.zst dexon-sol-tools-8162394797342cef268cc8072fc860326974e269.zip |
Merge branch 'development'
* development: (175 commits)
small README fixes
Update docs list in README
Add manual postpublish command to all public packages and update CHANGELOG.json
Fix postpublish util to ignore namespace
Fix release notes bug
Should print out `lerna publish` stdout so we can see if anything went wrong
Publish
Updated CHANGELOGS
Generate CHANGELOG.json files
Fix hasty find/replace
Default to 4sp
Update moment, no longer need separate moment types
Move prettify command to utils and also call it on CHANGELOG.md
Add prettier run on generated CHANGELOG.json and fix scripts
Remove semi-colons from monorepo-scripts package.json
Get rid of ; in top-level package.json
Fix TSLint error
Make dry-run configurable from top-level package.json
Improve naming
Run prettier, update deployer CHANGELOG
...
Diffstat (limited to 'packages/react-docs/src/components/documentation.tsx')
-rw-r--r-- | packages/react-docs/src/components/documentation.tsx | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index b46358159..14fe175cf 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -25,6 +25,7 @@ import { SolidityMethod, SupportedDocJson, TypeDefinitionByName, + TypescriptFunction, TypescriptMethod, } from '../types'; import { constants } from '../utils/constants'; @@ -33,7 +34,7 @@ import { utils } from '../utils/utils'; import { Badge } from './badge'; import { Comment } from './comment'; import { EventDefinition } from './event_definition'; -import { MethodBlock } from './method_block'; +import { SignatureBlock } from './signature_block'; import { SourceLink } from './source_link'; import { Type } from './type'; import { TypeDefinition } from './type_definition'; @@ -216,8 +217,12 @@ export class Documentation extends React.Component<DocumentationProps, Documenta const sortedMethods = _.sortBy(docSection.methods, 'name'); const methodDefs = _.map(sortedMethods, method => { - const isConstructor = false; - return this._renderMethodBlocks(method, sectionName, isConstructor, typeDefinitionByName); + return this._renderSignatureBlocks(method, sectionName, typeDefinitionByName); + }); + + const sortedFunctions = _.sortBy(docSection.functions, 'name'); + const functionDefs = _.map(sortedFunctions, func => { + return this._renderSignatureBlocks(func, sectionName, typeDefinitionByName); }); const sortedEvents = _.sortBy(docSection.events, 'name'); @@ -243,25 +248,31 @@ export class Documentation extends React.Component<DocumentationProps, Documenta {this._renderNetworkBadgesIfExists(sectionName)} </div> {docSection.comment && <Comment comment={docSection.comment} />} - {docSection.constructors.length > 0 && + {!_.isEmpty(docSection.constructors) && this.props.docsInfo.isVisibleConstructor(sectionName) && ( <div> <h2 style={headerStyle}>Constructor</h2> {this._renderConstructors(docSection.constructors, sectionName, typeDefinitionByName)} </div> )} - {docSection.properties.length > 0 && ( + {!_.isEmpty(docSection.properties) && ( <div> <h2 style={headerStyle}>Properties</h2> <div>{propertyDefs}</div> </div> )} - {docSection.methods.length > 0 && ( + {!_.isEmpty(docSection.methods) && ( <div> <h2 style={headerStyle}>Methods</h2> <div>{methodDefs}</div> </div> )} + {!_.isEmpty(docSection.functions) && ( + <div> + <h2 style={headerStyle}>Functions</h2> + <div>{functionDefs}</div> + </div> + )} {!_.isUndefined(docSection.events) && docSection.events.length > 0 && ( <div> @@ -318,7 +329,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta typeDefinitionByName: TypeDefinitionByName, ): React.ReactNode { const constructorDefs = _.map(constructors, constructor => { - return this._renderMethodBlocks(constructor, sectionName, constructor.isConstructor, typeDefinitionByName); + return this._renderSignatureBlocks(constructor, sectionName, typeDefinitionByName); }); return <div>{constructorDefs}</div>; } @@ -340,14 +351,13 @@ export class Documentation extends React.Component<DocumentationProps, Documenta </div> ); } - private _renderMethodBlocks( - method: SolidityMethod | TypescriptMethod, + private _renderSignatureBlocks( + method: SolidityMethod | TypescriptFunction | TypescriptMethod, sectionName: string, - isConstructor: boolean, typeDefinitionByName: TypeDefinitionByName, ): React.ReactNode { return ( - <MethodBlock + <SignatureBlock key={`method-${method.name}-${sectionName}`} sectionName={sectionName} method={method} |