Add import statements and GitHub link in API docs (#2714)
This commit is contained in:
committed by
GitHub
parent
9d5f77db9d
commit
75f6dbb86c
@ -8,7 +8,12 @@
|
|||||||
|
|
||||||
[.contract]
|
[.contract]
|
||||||
[[{{anchor}}]]
|
[[{{anchor}}]]
|
||||||
=== `++{{name}}++`
|
=== `++{{name}}++` link:{{github-link file.path}}[{github-icon},role=heading-link]
|
||||||
|
|
||||||
|
[.hljs-theme-light.nopadding]
|
||||||
|
```solidity
|
||||||
|
import "@openzeppelin/contracts/{{file.path}}";
|
||||||
|
```
|
||||||
|
|
||||||
{{natspec.devdoc}}
|
{{natspec.devdoc}}
|
||||||
|
|
||||||
|
|||||||
10
docs/helpers.js
Normal file
10
docs/helpers.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const { version } = require('../package.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
'github-link': (contractPath) => {
|
||||||
|
if (typeof contractPath !== 'string') {
|
||||||
|
throw new Error('Missing argument');
|
||||||
|
}
|
||||||
|
return `https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v${version}/contracts/${contractPath}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
:github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
|
||||||
|
|
||||||
{{#links}}
|
{{#links}}
|
||||||
:{{slug target.fullName}}: pass:normal[xref:{{path}}#{{target.anchor}}[`{{target.fullName}}`]]
|
:{{slug target.fullName}}: pass:normal[xref:{{path}}#{{target.anchor}}[`{{target.fullName}}`]]
|
||||||
:xref-{{slug target.anchor}}: xref:{{path}}#{{target.anchor}}
|
:xref-{{slug target.anchor}}: xref:{{path}}#{{target.anchor}}
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
"compile": "hardhat compile",
|
"compile": "hardhat compile",
|
||||||
"coverage": "hardhat coverage",
|
"coverage": "hardhat coverage",
|
||||||
"docs": "oz-docs",
|
"docs": "oz-docs",
|
||||||
"docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
|
"docs:watch": "npm run docs watch contracts 'docs/*.hbs' docs/helpers.js",
|
||||||
"prepare-docs": "scripts/prepare-docs.sh",
|
"prepare-docs": "scripts/prepare-docs.sh",
|
||||||
"lint": "npm run lint:js && npm run lint:sol",
|
"lint": "npm run lint:js && npm run lint:sol",
|
||||||
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",
|
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",
|
||||||
|
|||||||
@ -15,6 +15,7 @@ solidity-docgen \
|
|||||||
-o "$OUTDIR" \
|
-o "$OUTDIR" \
|
||||||
-e contracts/mocks,contracts/examples \
|
-e contracts/mocks,contracts/examples \
|
||||||
--output-structure readmes \
|
--output-structure readmes \
|
||||||
|
--helpers ./docs/helpers.js \
|
||||||
--solc-module ./scripts/prepare-docs-solc.js
|
--solc-module ./scripts/prepare-docs-solc.js
|
||||||
|
|
||||||
node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc"
|
node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc"
|
||||||
|
|||||||
Reference in New Issue
Block a user