-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Trying to get solidity-docgen (installed from npm, specified as '^0.6.0-beta.17' in package.json) to compile files for me, without transitioning from Truffle to Hardhat, by using the following script:
const { docgen } = require('solidity-docgen');
const fs = require("fs");
const json = JSON.parse(fs.readFileSync('build/contracts/CurrencyManager.json'));
// console.log(json);
docgen([{ output: json }]).then(res => {
console.log(res);
});Note that the CurrencyManager.json file is the json output after truffle compiled -- it does have an 'ast' field present, as indicated by the readme. To my understanding, this this script is equivalent the current readme example usage, although I am of course confused by what exactly the 'output' parameter needs to be. The error I get if I run this:
undefined:1
undefined
^
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at clone (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/utils/clone.js:9:29)
at buildSite (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/site.js:27:41)
at main (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/main.js:20:39)
at Object.<anonymous> (/home/miko/solidity/karmaToken/docify.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
Taking a look at the offending function in site.js, I get the following -- the error occurs when we try to pass originalBuild.input to some function clone, where originalBuild is actually the element inside the array I passed in the config. The error seems to be happening because the code required the 'input' field to be json-parseable, while it is recommended to be undefined in the readme.
function buildSite(builds, siteConfig) {
var _a;
const assign = typeof siteConfig.pages === 'string' ? exports.pageAssigner[siteConfig.pages] : siteConfig.pages;
const seen = new Set();
const items = [];
const pages = {};
for (const originalBuild of builds) {
// Clone because we will mutate in order to add item context.
const output = (0, clone_1.clone)(originalBuild.output);
const input = (0, clone_1.clone)(originalBuild.input);
const deref = (0, utils_1.astDereferencer)(output);
const build = { input, output, deref };
for (const { ast: file } of Object.values(build.output.sources)) {I understand that this project is mostly concerned with supporting the hardhat use-case. Was hoping for clarification if this raw use-case is even possible and, if so, how we should go about doing it.
👍👍 Thanks for supporting!