Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
better formatting and persist generated docs as circleci build artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
xianny committed Aug 5, 2019
1 parent 792fe8e commit 9d945f6
Show file tree
Hide file tree
Showing 28 changed files with 3,260 additions and 2,400 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ jobs:
key: coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/sra_client/.coverage
- store_artifacts:
path: ~/repo/packages/abi-gen-wrappers/generated_docs
- store_artifacts:
path: ~/repo/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_token/__init__.py
- store_artifacts:
Expand Down
22 changes: 11 additions & 11 deletions packages/abi-gen-templates/contract.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export class {{contractName}}Contract extends BaseContract {
}{{#if events}}
/**
* Subscribe to an event type emitted by the {{contractName}} contract.
* @param eventName The {{contractName}} contract event you would like to subscribe to.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
* @param callback Callback that gets called when a log is added/removed
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @param eventName The {{contractName}} contract event you would like to subscribe to.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
* @param callback Callback that gets called when a log is added/removed
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
public subscribe<ArgsType extends {{contractName}}EventArgs>(
Expand All @@ -182,7 +182,7 @@ export class {{contractName}}Contract extends BaseContract {
}
/**
* Cancel a subscription
* @param subscriptionToken Subscription token returned by `subscribe()`
* @param subscriptionToken Subscription token returned by `subscribe()`
*/
public unsubscribe(subscriptionToken: string): void {
this._subscriptionManager.unsubscribe(subscriptionToken);
Expand All @@ -195,11 +195,11 @@ export class {{contractName}}Contract extends BaseContract {
}
/**
* Gets historical logs without creating a subscription
* @param eventName The {{contractName}} contract event you would like to subscribe to.
* @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
* @param eventName The {{contractName}} contract event you would like to subscribe to.
* @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
public async getLogsAsync<ArgsType extends {{contractName}}EventArgs>(
eventName: {{contractName}}Events,
Expand Down
9 changes: 6 additions & 3 deletions packages/abi-gen-templates/partials/callAsync.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas since they don't modify state.
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
* since they don't modify state.
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
{{#if devdoc.return}}
* @returns {{devdoc.return}}
Expand Down Expand Up @@ -41,9 +43,10 @@ async callAsync(
// tslint:enable boolean-naming
return result;
},

/**
* Returns the ABI encoded transaction data needed to send an Ethereum tx calling this method. Before sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used to create a 0x transaction (see protocol spec for more details).
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
* to create a 0x transaction (see protocol spec for more details).
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
*/
getABIEncodedTransactionData(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#each inputs}}
{{#if (getDocstringForParamTs name ../docstrings)}}
* @param {{name}} {{getDocstringForParamTs name ../docstrings}}
{{formatDocstringForParamTs name (getDocstringForParamTs name ../docstrings)}}
{{/if}}
{{/each}}
20 changes: 11 additions & 9 deletions packages/abi-gen-templates/partials/tx.handlebars
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
public {{languageSpecificName}} = {
/**
* Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write Ethereum operation and will cost gas.
* Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write
* Ethereum operation and will cost gas.
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @returns The hash of the transaction
* @param txData Additional data for transaction
* @returns The hash of the transaction
*/
async sendTransactionAsync(
{{> typed_params inputs=inputs}}
Expand Down Expand Up @@ -34,11 +35,12 @@ public {{languageSpecificName}} = {
return txHash;
},
/**
* Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. If the transaction was mined, but reverted, an error is thrown.
* Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting.
* If the transaction was mined, but reverted, an error is thrown.
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @param pollingIntervalMs Interval at which to poll for success
* @returns A promise that resolves when the transaction is successful
* @param txData Additional data for transaction
* @param pollingIntervalMs Interval at which to poll for success
* @returns A promise that resolves when the transaction is successful
*/
awaitTransactionSuccessAsync(
{{> typed_params inputs=inputs}}
Expand Down Expand Up @@ -70,8 +72,8 @@ public {{languageSpecificName}} = {
/**
* Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments.
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @returns The hash of the transaction
* @param txData Additional data for transaction
* @returns The hash of the transaction
*/
async estimateGasAsync(
{{> typed_params inputs=inputs}}
Expand Down
3 changes: 2 additions & 1 deletion packages/abi-gen-wrappers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ yarn lint
yarn test
```

### Reading Documentation
### Documentation

Documentation for this package is generated by TypeDoc, using the Solidity source code for 0x contracts. Each contract corresponds to one global-level module, which contains relevant enums and interfaces for its events and structs. Most significantly, each module exports a class, `<ContractName>Contract`, e.g. `ExchangeContract`, which implements helper methods for all the functions defined in the corresponding contract.

A convention to note is that these contract-specific helper methods are defined as _object literals_, which are separated from methods in the generated documentation. Each contract method has a number of sub-methods, e.g. `sendTransactionAsync`, or `estimateGasAsync`, which are documented separately. This is an example of an expected method call signature: `exchangeContractInstance.fillOrder.sendTransactionAsync(...arguments)`.
2 changes: 1 addition & 1 deletion packages/abi-gen-wrappers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build": "yarn pre_build && tsc -b && yarn docs",
"build:ci": "yarn build",
"lint": "tslint --format stylish --project .",
"fix": "tslint --fix --format stylish --project .",
Expand Down
Loading

0 comments on commit 9d945f6

Please sign in to comment.