aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-docs/src/components/documentation.tsx
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-19 01:44:52 +0800
committerFabio Berger <me@fabioberger.com>2018-03-19 01:44:52 +0800
commit794b155827868d67f1cec45bbe8c3a3e4be02597 (patch)
tree8f46fb1fe23f0317b50f9d37e6fa8c671615c981 /packages/react-docs/src/components/documentation.tsx
parent4941ffd354a7bbc4fb48cd66acd6db1e36d5ed87 (diff)
downloaddexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar.gz
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar.bz2
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar.lz
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar.xz
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.tar.zst
dexon-sol-tools-794b155827868d67f1cec45bbe8c3a3e4be02597.zip
Add support for displaying exported functions
Diffstat (limited to 'packages/react-docs/src/components/documentation.tsx')
-rw-r--r--packages/react-docs/src/components/documentation.tsx26
1 files changed, 18 insertions, 8 deletions
diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx
index b46358159..67523dcc3 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');
@@ -262,6 +267,12 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
<div>{methodDefs}</div>
</div>
)}
+ {docSection.functions.length > 0 && (
+ <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}