-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs pipeline to solidity-docgen@0.6 (#3707)
(cherry picked from commit c526250)
- Loading branch information
Showing
24 changed files
with
10,885 additions
and
16,313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
/** @type import('solidity-docgen/dist/config').UserConfig */ | ||
module.exports = { | ||
outputDir: 'docs/modules/api/pages', | ||
templates: 'docs/templates', | ||
exclude: ['mocks'], | ||
pageExtension: '.adoc', | ||
pages: (_, file, config) => { | ||
// For each contract file, find the closest README.adoc and return its location as the output page path. | ||
const sourcesDir = path.resolve(config.root, config.sourcesDir); | ||
let dir = path.resolve(config.root, file.absolutePath); | ||
while (dir.startsWith(sourcesDir)) { | ||
dir = path.dirname(dir); | ||
if (fs.existsSync(path.join(dir, 'README.adoc'))) { | ||
return path.relative(sourcesDir, dir) + config.pageExtension; | ||
} | ||
} | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{{#each items}} | ||
:{{name}}: pass:normal[xref:#{{anchor}}[`++{{name}}++`]] | ||
{{/each}} | ||
|
||
[.contract] | ||
[[{{anchor}}]] | ||
=== `++{{name}}++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v{{oz-version}}/{{__item_context.file.absolutePath}}[{github-icon},role=heading-link] | ||
|
||
[.hljs-theme-light.nopadding] | ||
```solidity | ||
import "@openzeppelin/{{__item_context.file.absolutePath}}"; | ||
``` | ||
|
||
{{{natspec.dev}}} | ||
|
||
{{#if modifiers}} | ||
[.contract-index] | ||
.Modifiers | ||
-- | ||
{{#each modifiers}} | ||
* {xref-{{anchor~}} }[`++{{name}}({{names params}})++`] | ||
{{/each}} | ||
-- | ||
{{/if}} | ||
|
||
{{#if has-functions}} | ||
[.contract-index] | ||
.Functions | ||
-- | ||
{{#each inherited-functions}} | ||
{{#unless @first}} | ||
[.contract-subindex-inherited] | ||
.{{contract.name}} | ||
{{/unless}} | ||
{{#each functions}} | ||
* {xref-{{anchor~}} }[`++{{name}}({{names params}})++`] | ||
{{/each}} | ||
|
||
{{/each}} | ||
-- | ||
{{/if}} | ||
|
||
{{#if has-events}} | ||
[.contract-index] | ||
.Events | ||
-- | ||
{{#each inheritance}} | ||
{{#unless @first}} | ||
[.contract-subindex-inherited] | ||
.{{name}} | ||
{{/unless}} | ||
{{#each events}} | ||
* {xref-{{anchor~}} }[`++{{name}}({{names params}})++`] | ||
{{/each}} | ||
|
||
{{/each}} | ||
-- | ||
{{/if}} | ||
|
||
{{#each modifiers}} | ||
[.contract-item] | ||
[[{{anchor}}]] | ||
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}})++` [.item-kind]#modifier# | ||
|
||
{{{natspec.dev}}} | ||
|
||
{{/each}} | ||
|
||
{{#each functions}} | ||
[.contract-item] | ||
[[{{anchor}}]] | ||
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}}){{#if returns}} → {{typed-params returns}}{{/if}}++` [.item-kind]#{{visibility}}# | ||
|
||
{{{natspec.dev}}} | ||
|
||
{{/each}} | ||
|
||
{{#each events}} | ||
[.contract-item] | ||
[[{{anchor}}]] | ||
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}})++` [.item-kind]#event# | ||
|
||
{{{natspec.dev}}} | ||
|
||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const { version } = require('../../package.json'); | ||
|
||
module.exports['oz-version'] = () => version; | ||
|
||
module.exports['readme-path'] = (opts) => { | ||
return 'contracts/' + opts.data.root.id.replace(/\.adoc$/, '') + '/README.adoc'; | ||
}; | ||
|
||
module.exports.names = (params) => params.map(p => p.name).join(', '); | ||
|
||
module.exports['typed-params'] = (params) => { | ||
return params.map(p => `${p.type}${p.name ? ' ' + p.name : ''}`).join(', '); | ||
}; | ||
|
||
const slug = module.exports.slug = (str) => { | ||
if (str === undefined) { | ||
throw new Error('Missing argument'); | ||
} | ||
return str.replace(/\W/g, '-'); | ||
}; | ||
|
||
const linksCache = new WeakMap(); | ||
|
||
function getAllLinks (items) { | ||
if (linksCache.has(items)) { | ||
return linksCache.get(items); | ||
} | ||
const res = {}; | ||
linksCache.set(items, res); | ||
for (const item of items) { | ||
res[`xref-${item.anchor}`] = `xref:${item.__item_context.page}#${item.anchor}`; | ||
res[slug(item.fullName)] = `pass:normal[xref:${item.__item_context.page}#${item.anchor}[\`${item.fullName}\`]]`; | ||
} | ||
return res; | ||
} | ||
|
||
module.exports['with-prelude'] = (opts) => { | ||
const links = getAllLinks(opts.data.site.items); | ||
const contents = opts.fn(); | ||
const neededLinks = contents | ||
.match(/\{[-._a-z0-9]+\}/ig) | ||
.map(m => m.replace(/^\{(.+)\}$/, '$1')) | ||
.filter(k => k in links); | ||
const prelude = neededLinks.map(k => `:${k}: ${links[k]}`).join('\n'); | ||
return prelude + '\n' + contents; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>] | ||
{{#with-prelude}} | ||
{{readme (readme-path)}} | ||
{{/with-prelude}} |
Oops, something went wrong.