Skip to content

Commit

Permalink
chore(contracts): replace dodoc by solidity-docgen (#14826)
Browse files Browse the repository at this point in the history
* replace dodoc by solidity-docgen

* move from deps todevDeps

* add back hooks
  • Loading branch information
clemsos authored Oct 10, 2024
1 parent ed32a2c commit f2d74d8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
12 changes: 11 additions & 1 deletion packages/contracts/bin/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
SRC_DOCS_FOLDER="$(pwd)/docs"
DEST_DOCS_FOLDER="$(pwd)/docs-reorg"

#cleanup
rm -rf $SRC_DOCS_FOLDER

# build docs
yarn hardhat dodoc
yarn hardhat docgen

# delete existing folder
rm -rf $DEST_DOCS_FOLDER
mkdir -p $DEST_DOCS_FOLDER

# delete all contracts than are NOT interfaces
find ./docs -type f -name 'PublicLock*' -exec rm {} \;
find ./docs -type f -name 'Unlock*' -exec rm {} \;

# first archive all
cp -R $SRC_DOCS_FOLDER $DEST_DOCS_FOLDER
mv $DEST_DOCS_FOLDER/docs $DEST_DOCS_FOLDER/archive
Expand Down Expand Up @@ -153,3 +160,6 @@ echo '{
rm -rf $SRC_DOCS_FOLDER
mv $DEST_DOCS_FOLDER $SRC_DOCS_FOLDER

# cleanup tmp files
find ./docs -type f -name '*.md-e' -exec rm {} \;

33 changes: 14 additions & 19 deletions packages/contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,14 @@
*/

// to build contract docs
require('@primitivefi/hardhat-dodoc')
// require('@primitivefi/hardhat-dodoc')
require('solidity-docgen')

const fs = require('fs-extra')
require('./task/exportAbis')

const contractsPath = './src/contracts'

// list all interfaces to document
const contractsToDocument = fs
.readdirSync(contractsPath)
.map((contractName) =>
fs.readdirSync(`${contractsPath}/${contractName}`).filter(
(n) =>
n.startsWith('I') && // only interfaces
!n.includes('Sol') && // exclude various solc versions
!n.startsWith('IUnlockDiscountToken') // exclude UDT
)
)
.flat()

const settings = {
optimizer: {
enabled: true,
Expand Down Expand Up @@ -53,11 +41,18 @@ module.exports = {
},
],
},
dodoc: {
// debugMode: true,
keepFileStructure: true,
include: contractsToDocument,
exclude: ['IERC165', 'IERC721', 'IERC721Enumerable', 'Initializable'],
docgen: {
pages: 'files',
exclude: [
'IERC165',
'IERC721',
'IERC721Enumerable',
'Initializable',
'UP',
'utils',
'Governor',
'UnlockDiscountToken',
],
},
paths: {
sources: contractsPath,
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"copyutils": "cp dist/src/utils/* dist",
"copyindex": "cp dist/src/index.js dist && cp -r dist/src/abis dist",
"docs": "sh ./bin/build_docs.sh",
"docs:docgen": "yarn hardhat docgen",
"docs:copy": "copyfiles --verbose docs/**/*.json docs/**/*.md dist",
"prepublish": "yarn clean && yarn build && yarn build:docs",
"publish:npm": "yarn prepublish && npm publish"
Expand All @@ -27,14 +28,14 @@
"directory": "packages/contracts"
},
"devDependencies": {
"@primitivefi/hardhat-dodoc": "0.2.3",
"@unlock-protocol/networks": "workspace:^",
"@unlock-protocol/tsconfig": "workspace:./packages/tsconfig",
"@unlock-protocol/types": "workspace:^",
"copyfiles": "2.4.1",
"eslint": "9.11.1",
"fs-extra": "11.2.0",
"hardhat": "2.22.9",
"solidity-docgen": "0.6.0-beta.36",
"typescript": "5.6.2"
},
"files": [
Expand Down
42 changes: 21 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14368,18 +14368,6 @@ __metadata:
languageName: node
linkType: hard

"@primitivefi/hardhat-dodoc@npm:0.2.3":
version: 0.2.3
resolution: "@primitivefi/hardhat-dodoc@npm:0.2.3"
dependencies:
squirrelly: "npm:^8.0.8"
peerDependencies:
hardhat: ^2.6.4
squirrelly: ^8.0.8
checksum: 10/0db4f31bf0fbcf3dbce5a58e5570e5bb915247d9fafecc0239bfeb50fda20d6fd76c16bae704b092714d81a42ee378f63b50a51c06423638d536325e5be2f1a9
languageName: node
linkType: hard

"@prisma/instrumentation@npm:5.19.1":
version: 5.19.1
resolution: "@prisma/instrumentation@npm:5.19.1"
Expand Down Expand Up @@ -20527,14 +20515,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "@unlock-protocol/contracts@workspace:packages/contracts"
dependencies:
"@primitivefi/hardhat-dodoc": "npm:0.2.3"
"@unlock-protocol/networks": "workspace:^"
"@unlock-protocol/tsconfig": "workspace:./packages/tsconfig"
"@unlock-protocol/types": "workspace:^"
copyfiles: "npm:2.4.1"
eslint: "npm:9.11.1"
fs-extra: "npm:11.2.0"
hardhat: "npm:2.22.9"
solidity-docgen: "npm:0.6.0-beta.36"
typescript: "npm:5.6.2"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -33982,7 +33970,7 @@ __metadata:
languageName: node
linkType: hard

"handlebars@npm:4.7.8":
"handlebars@npm:4.7.8, handlebars@npm:^4.7.7":
version: 4.7.8
resolution: "handlebars@npm:4.7.8"
dependencies:
Expand Down Expand Up @@ -49019,6 +49007,13 @@ __metadata:
languageName: node
linkType: hard

"solidity-ast@npm:^0.4.38":
version: 0.4.59
resolution: "solidity-ast@npm:0.4.59"
checksum: 10/95172fcc3b4ea183c328c36b72b1b861c2e1a2c0f8334f5375f05c1f7a11e13b10f126818dd1a65bb672b4bca87278faaa2bae5c25d2433e162bc86a47d43daa
languageName: node
linkType: hard

"solidity-ast@npm:^0.4.51, solidity-ast@npm:^0.4.56":
version: 0.4.56
resolution: "solidity-ast@npm:0.4.56"
Expand Down Expand Up @@ -49091,6 +49086,18 @@ __metadata:
languageName: node
linkType: hard

"solidity-docgen@npm:0.6.0-beta.36":
version: 0.6.0-beta.36
resolution: "solidity-docgen@npm:0.6.0-beta.36"
dependencies:
handlebars: "npm:^4.7.7"
solidity-ast: "npm:^0.4.38"
peerDependencies:
hardhat: ^2.8.0
checksum: 10/7c055101f5801d9eb812c0275551de59f0bdd0ec886ab23af1cd25dc33322947205f298a78b9389ba155aee9338718b5d93933fb303c00144b556178808d6656
languageName: node
linkType: hard

"sonic-boom@npm:^2.2.1":
version: 2.8.0
resolution: "sonic-boom@npm:2.8.0"
Expand Down Expand Up @@ -49409,13 +49416,6 @@ __metadata:
languageName: node
linkType: hard

"squirrelly@npm:^8.0.8":
version: 8.0.8
resolution: "squirrelly@npm:8.0.8"
checksum: 10/b07f7456b9f7709cdfd5b04d9756304838384fd7f932fb76fab0d1489a85158fd3e78cc22cb2c93e8b92156003a2f5f12fd614c202b72d538f293a5dc25f505b
languageName: node
linkType: hard

"srcset@npm:^1.0.0":
version: 1.0.0
resolution: "srcset@npm:1.0.0"
Expand Down

0 comments on commit f2d74d8

Please sign in to comment.