Add import statements and GitHub link in API docs (#2714)

This commit is contained in:
Francisco Giordano
2021-06-11 15:09:32 -03:00
committed by GitHub
parent 9d5f77db9d
commit 75f6dbb86c
5 changed files with 20 additions and 2 deletions

View File

@ -8,7 +8,12 @@
[.contract]
[[{{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}}

10
docs/helpers.js Normal file
View 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}`;
},
};

View File

@ -1,3 +1,5 @@
:github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
{{#links}}
:{{slug target.fullName}}: pass:normal[xref:{{path}}#{{target.anchor}}[`{{target.fullName}}`]]
:xref-{{slug target.anchor}}: xref:{{path}}#{{target.anchor}}

View File

@ -14,7 +14,7 @@
"compile": "hardhat compile",
"coverage": "hardhat coverage",
"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",
"lint": "npm run lint:js && npm run lint:sol",
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",

View File

@ -15,6 +15,7 @@ solidity-docgen \
-o "$OUTDIR" \
-e contracts/mocks,contracts/examples \
--output-structure readmes \
--helpers ./docs/helpers.js \
--solc-module ./scripts/prepare-docs-solc.js
node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc"