OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
448 stars 118 forks source link

Not able to access contract from other directory #14

Closed ghost closed 5 years ago

ghost commented 5 years ago

I am trying to run following command - solidity-docgen . ./contracts ./docs Dir: /home/ganeshdip/KCS/tryImport/dir1 contract: MyContract1.sol in which I am importing MyContract2.sol Location of contract MyContract1: /home/ganeshdip/KCS/tryImport/dir1/contracts Location of contract MyContract2: /home/ganeshdip/KCS/tryImport/dir2/contracts I am getting following error-

exec: /home/ganeshdip/KCS/tryImport/dir1/contracts/MyContract1.sol:2:1: Error: Source "/home/ganeshdip/KCS/tryImport/dir2/contracts/MyContract2.sol" not found: File outside of allowed directories.
import "../../dir2/contracts/MyContract2.sol";
^--------------------------------------------^

/usr/local/lib/node_modules/solidity-docgen/lib/index.js:133
    throw new Error(['Command line operation failed with code ' + commandOutput.code + '.', 'Standard error output: ' + commandOutput.stderr].join('\n'));
    ^

Error: Command line operation failed with code 1.
Standard error output: /home/ganeshdip/KCS/tryImport/dir1/contracts/MyContract1.sol:2:1: Error: Source "/home/ganeshdip/KCS/tryImport/dir2/contracts/MyContract2.sol" not found: File outside of allowed directories.
import "../../dir2/contracts/MyContract2.sol";
^--------------------------------------------^

    at handleErrorCode (/usr/local/lib/node_modules/solidity-docgen/lib/index.js:133:11)
    at parseProject (/usr/local/lib/node_modules/solidity-docgen/lib/index.js:123:3)
    at exports.default (/usr/local/lib/node_modules/solidity-docgen/lib/index.js:20:23)
    at Command.program.version.arguments.option.action (/usr/local/lib/node_modules/solidity-docgen/bin/solidity-docgen:32:5)
    at Command.listener (/usr/local/lib/node_modules/solidity-docgen/node_modules/commander/index.js:315:8)
    at emitOne (events.js:116:13)
    at Command.emit (events.js:211:7)
    at Command.parseArgs (/usr/local/lib/node_modules/solidity-docgen/node_modules/commander/index.js:656:12)
    at Command.parse (/usr/local/lib/node_modules/solidity-docgen/node_modules/commander/index.js:474:21)
    at Object.<anonymous> (/usr/local/lib/node_modules/solidity-docgen/bin/solidity-docgen:44:9)

Can you please let me know, how to successfully generate the documentation.

Aniket-Engg commented 5 years ago

Have you gone through this? https://github.com/OpenZeppelin/solidity-docgen#dealing-with-imports

ghost commented 5 years ago

I have gone through the same. Finally it is working with following approach by giving full path- SOLC_ARGS="truffle/Assert.sol=$PWD/node_modules/truffle/build/Assert.sol tokens=$PWD/node_modules/truffle/test/sources/ethpm/installed_contracts/tokens/contracts/ ethpmpkg=$PWD/node_modules/truffle/test/sources/monorepo/installed_contracts/ethpmpkg /app/konfidio-id-generator-lib/IdGenerator.sol /app/authenticator/contracts/Authorizer.sol" solidity-docgen . . .

Aniket-Engg commented 5 years ago

Great! I think issue can be closed now. :blush:

ghost commented 5 years ago

It is fixed by supplying path for each file in SOLC_ARGS.