Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/config-md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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-md',
exclude: ['mocks'],
pageExtension: '.mdx',
pages: (_, file, config) => {
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;
}
}
},
};
158 changes: 158 additions & 0 deletions docs/templates-md/contract.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{{reset-function-counts}}<a id="{{anchor}}"></a>

<div style=\{{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `{{{name}}}`

<a target="_blank" style=\{{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v{{oz-version}}/{{__item_context.file.absolutePath}}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/{{__item_context.file.absolutePath}}";
```

{{{process-natspec natspec.dev}}}

{{#if modifiers}}
<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style=\{{ marginTop: "0"}}>Modifiers</h3>
<div className="font-mono">
{{#each modifiers}}
- [{{{name}}}({{names params}})](#{{anchor}})
{{/each}}
</div>
</div>
{{/if}}


{{#if has-functions}}
<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style=\{{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
{{#each inherited-functions}}
{{#unless @first}}
#### {{contract.name}} [!toc]
{{/unless}}
{{#each functions}}
- [{{{name}}}({{names params}})](#{{anchor}})
{{/each}}
{{/each}}
</div>
</div>
{{/if}}

{{#if has-events}}
<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style=\{{ marginTop: "0"}}>Events</h3>
<div className="font-mono">
{{#each inheritance}}
{{#unless @first}}
#### {{name}} [!toc]
{{/unless}}
{{#each events}}
- [{{{name}}}({{names params}})](#{{anchor}})
{{/each}}
{{/each}}
</div>
</div>
{{/if}}

{{#if has-errors}}
<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style=\{{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
{{#each inheritance}}
{{#unless @first}}
#### {{name}} [!toc]
{{/unless}}
{{#each errors}}
- [{{{name}}}({{names params}})](#{{anchor}})
{{/each}}
{{/each}}
</div>
</div>
{{/if}}

{{#each modifiers}}
<a id="{{anchor}}"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">{{{name}}}({{typed-params params}})</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">{{visibility}}</p>
<a className="peer" data-card href="{{anchor}}">#</a>
</div>
</div>

<div className="px-4">

{{{process-natspec natspec.dev}}}

</div>
</div>

{{/each}}

{{#each functions}}
<a id="{{anchor}}"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">{{{name}}}({{typed-params params}}){{#if returns2}} → {{typed-params returns2}}{{/if}}</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">{{visibility}}</p>
<a className="peer" data-card href="{{anchor}}">#</a>
</div>
</div>
<div className="px-4">

{{{process-natspec natspec.dev}}}

</div>
</div>

{{/each}}

{{#each events}}
<a id="{{anchor}}"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">{{{name}}}({{typed-params params}})</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">event</p>
<a className="peer" data-card href="{{anchor}}">#</a>
</div>
</div>

<div className="px-4">

{{{process-natspec natspec.dev}}}

</div>
</div>
{{/each}}

{{#each errors}}
<a id="{{anchor}}"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">{{{name}}}({{typed-params params}})</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="{{anchor}}">#</a>
</div>
</div>
<div className="px-4">

{{{process-natspec natspec.dev}}}

</div>
</div>

{{/each}}
Loading
Loading