Add .eq() usage to docs and fix docs typos (#1405)

* Use `eq` for example

* Use the base `eq` function rather than `===`, so that comparisons are made in a consistent manner in docs

* Add `eq` example

* Add an example of using the `eq` method to the base docs

* Adjust docs/examples

* Fix a number of typos in the static docs and examples
* Adjust various comments in docs examples such that they are written in a consistent case

* Fix metadata docs spacing

* Adjust the metadata documentation generation such that unnecessary spaces are trimmed
This commit is contained in:
James Lefrère
2019-09-19 11:43:47 +02:00
committed by Jaco Greeff
parent 229fd72526
commit 73d7a57d38
29 changed files with 152 additions and 130 deletions
+9 -4
View File
@@ -90,7 +90,8 @@ function addConstants (metadata: MetadataV7): string {
return orderedConstants.reduce((md, func): string => {
const methodName = stringCamelCase(func.name.toString());
const doc = func.documentation.reduce((md, doc): string => `${md} ${doc}`, '');
const doc = func.documentation
.reduce((md, doc): string => `${md.length ? `${md} ` : ''}${doc.trim()}`, '');
const type = func.type;
const renderSignature = `${md}\n▸ **${methodName}**: ` + '`' + type + '`';
const renderSummary = `${doc ? `\n- **summary**: ${doc}\n` : '\n'}`;
@@ -122,7 +123,9 @@ function addEvents (metadata: MetadataV7): string {
return orderedMethods.reduce((md, func): string => {
const methodName = func.name.toString();
const args = func.args.map((type): string => '`' + type + '`').join(', ');
const doc = func.documentation.reduce((md, doc): string => `${md} ${doc}`, '');
const doc = func.documentation
.reduce((md, doc): string => `${md.length ? `${md} ` : ''}${doc.trim()}`, '');
const renderSignature = `${md}\n▸ **${methodName}**(${args})`;
const renderSummary = `${doc ? `\n- **summary**: ${doc}\n` : '\n'}`;
@@ -153,7 +156,8 @@ function addExtrinsics (metadata: MetadataV7): string {
return orderedMethods.reduce((md, func): string => {
const methodName = stringCamelCase(func.name.toString());
const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', ');
const doc = func.documentation.reduce((md, doc): string => `${md} ${doc}`, '');
const doc = func.documentation
.reduce((md, doc): string => `${md.length ? `${md} ` : ''}${doc.trim()}`, '');
const renderSignature = `${md}\n▸ **${methodName}**(${args})`;
const renderSummary = `${doc ? `\n- **summary**: ${doc}\n` : '\n'}`;
@@ -187,7 +191,8 @@ function addStorage (metadata: MetadataV7): string {
: func.type.isDoubleMap
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
: '';
const doc = func.documentation.reduce((md, doc): string => `${md} ${doc}`, '');
const doc = func.documentation
.reduce((md, doc): string => `${md.length ? `${md} ` : ''}${doc.trim()}`, '');
let result = (
func.type.isDoubleMap
? func.type.asDoubleMap.value