solidity-docgen
Advanced tools
Comparing version 0.4.0-beta.0 to 0.4.0-beta.1
@@ -82,2 +82,20 @@ "use strict"; | ||
} | ||
if (semver_1.default.satisfies(this.solc.version(), '^0.6')) { | ||
const adaptDocumentation = (node) => { | ||
var _a; | ||
if ((_a = node.documentation) === null || _a === void 0 ? void 0 : _a.text) { | ||
node.documentation = node.documentation.text; | ||
} | ||
}; | ||
for (const source of Object.values(solcOutput.sources)) { | ||
for (const fileNode of source.ast.nodes) { | ||
adaptDocumentation(fileNode); | ||
if (fileNode.nodeType === 'ContractDefinition') { | ||
for (const contractNode of fileNode.nodes) { | ||
adaptDocumentation(contractNode); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return solcOutput; | ||
@@ -84,0 +102,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const solidity_1 = require("./solidity"); | ||
const compile_1 = require("./compile"); | ||
function buildSource(solcOutput) { | ||
@@ -130,2 +131,46 @@ return new solidity_1.SoliditySource('', solcOutput, c => c.name); | ||
}); | ||
ava_1.default('using real compiler output (0.6)', async (t) => { | ||
const sourceText = ` | ||
pragma solidity ^0.6; | ||
contract Foo { | ||
uint public x; | ||
/** | ||
* @dev docs | ||
*/ | ||
function fun(uint a) public pure returns (uint r) { return a; } | ||
event Ev(uint a); | ||
modifier mod(uint a) { _; } | ||
receive() external payable {} | ||
} | ||
`; | ||
const adapter = await compile_1.SolcAdapter.require('solc'); | ||
const solcOutput = adapter.compile({ | ||
language: 'Solidity', | ||
sources: { | ||
test: { | ||
content: sourceText, | ||
}, | ||
}, | ||
settings: { | ||
outputSelection: compile_1.outputSelection, | ||
}, | ||
}); | ||
t.is('object', typeof solcOutput); | ||
t.is(undefined, solcOutput.errors); | ||
const getName = (x) => x.name; | ||
const source = buildSource(solcOutput); | ||
t.deepEqual(['Foo'], source.contracts.map(getName)); | ||
const foo = source.contracts[0]; | ||
t.deepEqual(['x'], foo.variables.map(getName)); | ||
t.deepEqual(['fun', 'receive'], foo.functions.map(getName)); | ||
t.deepEqual(['mod'], foo.modifiers.map(getName)); | ||
t.deepEqual(['Ev'], foo.events.map(getName)); | ||
const fun = foo.functions[0]; | ||
t.is('public', fun.visibility); | ||
t.deepEqual(['uint256 a'], Array.from(fun.args, a => a.toString())); | ||
t.deepEqual(['uint256 r'], Array.from(fun.outputs, a => a.toString())); | ||
t.is('docs', fun.natspec.devdoc); | ||
const mod = foo.functions[0]; | ||
t.deepEqual(['uint256 a'], Array.from(mod.args, a => a.toString())); | ||
}); | ||
//# sourceMappingURL=solidity.test.js.map |
{ | ||
"name": "solidity-docgen", | ||
"version": "0.4.0-beta.0", | ||
"version": "0.4.0-beta.1", | ||
"description": "Solidity API documentation automatic generator.", | ||
@@ -5,0 +5,0 @@ "bin": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
276495
1381