Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from dpilch/develop
Browse files Browse the repository at this point in the history
v0.1.5
  • Loading branch information
dpilch authored Sep 5, 2017
2 parents a89b3d1 + 6e2ade1 commit 114064e
Show file tree
Hide file tree
Showing 18 changed files with 445 additions and 133 deletions.
8 changes: 6 additions & 2 deletions lib/compile/parse-abi.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ exports.default = function (contract) {
argumentList: argumentList,
outputs: outputs,
signature: signature,
signatureHash: signature && (0, _helpers.getFunctionSignature)(signature)
signatureHash: signature && (0, _helpers2.default)(signature)
});
});
};

var _helpers = require('../helpers');
var _helpers = require('../helpers');

var _helpers2 = _interopRequireDefault(_helpers);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 changes: 1 addition & 23 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,14 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.clearDirectory = clearDirectory;
exports.getFunctionSignature = getFunctionSignature;

var _rimraf = require('rimraf');

var _rimraf2 = _interopRequireDefault(_rimraf);

var _mkdirp = require('mkdirp');

var _mkdirp2 = _interopRequireDefault(_mkdirp);
exports.default = getFunctionSignature;

var _keccakjs = require('keccakjs');

var _keccakjs2 = _interopRequireDefault(_keccakjs);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function clearDirectory(target) {
return new Promise(function (resolve, reject) {
(0, _mkdirp2.default)(target, function () {
(0, _rimraf2.default)(target, function (err) {
if (err) {
return reject(err);
}
return resolve();
});
});
});
}

function getFunctionSignature(signature) {
return new _keccakjs2.default(256).update(signature).digest('hex').substr(0, 8);
}
2 changes: 1 addition & 1 deletion lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.default = function (_ref) {
resolve();
});
// build the table of contents
if (args.notoc) {
if (!args.notoc) {
data.forEach(function (contract) {
// contract name
writeStream.write('* [' + contract.name + '](#' + contract.name.toLowerCase() + ')\n');
Expand Down
2 changes: 1 addition & 1 deletion lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _dot2 = _interopRequireDefault(_dot);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var template = '\n# {{=it.name}}\n{{? it.author }}\n{{=it.author}}{{?}}\n{{~it.abiDocs :docItem:index}}{{? docItem.type === \'function\'}}\n## *{{=docItem.type}}* {{=docItem.name}}\n\n{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}){{?docItem.payable}}`payable`{{?}} `{{=docItem.signatureHash}}`\n{{?docItem.notice}}\n**{{=docItem.notice}}**\n{{?}}\n{{?docItem.details}}> {{=docItem.details}}\n{{?}}\n{{? docItem.inputs.length > 0 }}Inputs\n\n| | | |\n|-|-|-|{{~docItem.inputs :input}}\n| *{{=input.type}}* | {{=input.name}} | {{=input.description}} |{{~}}{{?}}\n{{? docItem.outputs.length > 0 }}\nOutputs\n\n| | | |\n|-|-|-|{{~docItem.outputs :output}}\n| *{{=output.type}}* | {{=output.name}} | {{=output.description}} |{{~}}{{?}}{{?}}\n{{~}}\n---';
var template = '\n# {{=it.name}}\n{{? it.author }}\n{{=it.author}}{{?}}\n{{~it.abiDocs :docItem:index}}{{? docItem.type === \'event\'}}## *{{=docItem.type}}* {{=docItem.name}}\n\n{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}) {{?docItem.anonymous}}`anonymous` {{?}}`{{=docItem.signatureHash}}`\n\n{{? docItem.inputs.length > 0 }}Arguments\n\n| | | |\n|-|-|-|{{~docItem.inputs :argument}}\n| *{{=argument.type}}* | {{=argument.name}} | {{? argument.indexed === false}}not {{?}}indexed |{{~}}{{?}}\n{{?}}{{? docItem.type === \'function\'}}\n## *{{=docItem.type}}* {{=docItem.name}}\n\n{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}) `{{=docItem.stateMutability}}` `{{=docItem.signatureHash}}`\n{{?docItem.notice}}\n**{{=docItem.notice}}**\n{{?}}\n{{?docItem.details}}> {{=docItem.details}}\n{{?}}\n{{? docItem.inputs.length > 0 }}Inputs\n\n| | | |\n|-|-|-|{{~docItem.inputs :input}}\n| *{{=input.type}}* | {{=input.name}} | {{=input.description}} |{{~}}{{?}}\n{{? docItem.outputs.length > 0 }}\nOutputs\n\n| | | |\n|-|-|-|{{~docItem.outputs :output}}\n| *{{=output.type}}* | {{=output.name}} | {{=output.description}} |{{~}}{{?}}{{?}}\n{{~}}\n---';

_dot2.default.templateSettings.strip = false;

Expand Down
64 changes: 39 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solmd",
"version": "0.1.4",
"version": "0.1.5",
"description": "Markdown documentation generator for Solidity",
"engines": {
"node": ">=4"
Expand Down Expand Up @@ -45,9 +45,7 @@
"dependencies": {
"dot": "^1.1.2",
"keccakjs": "^0.2.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.1"
"minimist": "^1.2.0"
},
"pre-commit": [
"lint",
Expand Down
2 changes: 1 addition & 1 deletion src/compile/parse-abi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFunctionSignature } from '../helpers';
import getFunctionSignature from '../helpers';

export default function (contract) {
return contract.abi.map((method) => {
Expand Down
15 changes: 1 addition & 14 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
import rmdir from 'rimraf';
import mkdirp from 'mkdirp';
import Keccak from 'keccakjs';

export function clearDirectory(target) {
return new Promise((resolve, reject) => {
mkdirp(target, () => {
rmdir(target, (err) => {
if (err) { return reject(err); }
return resolve();
});
});
});
}

export function getFunctionSignature(signature) {
export default function getFunctionSignature(signature) {
return new Keccak(256).update(signature).digest('hex').substr(0, 8);
}
2 changes: 1 addition & 1 deletion src/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function ({ args, data }) {
resolve();
});
// build the table of contents
if (args.notoc) {
if (!args.notoc) {
data.forEach((contract) => {
// contract name
writeStream.write(`* [${contract.name}](#${contract.name.toLowerCase()})\n`);
Expand Down
13 changes: 11 additions & 2 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ const template = `
# {{=it.name}}
{{? it.author }}
{{=it.author}}{{?}}
{{~it.abiDocs :docItem:index}}{{? docItem.type === 'function'}}
{{~it.abiDocs :docItem:index}}{{? docItem.type === 'event'}}## *{{=docItem.type}}* {{=docItem.name}}
{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}) {{?docItem.anonymous}}\`anonymous\` {{?}}\`{{=docItem.signatureHash}}\`
{{? docItem.inputs.length > 0 }}Arguments
| | | |
|-|-|-|{{~docItem.inputs :argument}}
| *{{=argument.type}}* | {{=argument.name}} | {{? argument.indexed === false}}not {{?}}indexed |{{~}}{{?}}
{{?}}{{? docItem.type === 'function'}}
## *{{=docItem.type}}* {{=docItem.name}}
{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}){{?docItem.payable}}\`payable\`{{?}} \`{{=docItem.signatureHash}}\`
{{=it.name}}.{{=docItem.name}}({{=docItem.argumentList}}) \`{{=docItem.stateMutability}}\` \`{{=docItem.signatureHash}}\`
{{?docItem.notice}}
**{{=docItem.notice}}**
{{?}}
Expand Down
Loading

0 comments on commit 114064e

Please sign in to comment.