Skip to content

Commit 355cb82

Browse files
committed
Add missing docs configuration
1 parent bf06a4c commit 355cb82

File tree

4 files changed

+148
-126
lines changed

4 files changed

+148
-126
lines changed

docs/index.md

Lines changed: 105 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,5 @@
11
# Solidity API
22

3-
## MyStablecoinAllowlist
4-
5-
### constructor
6-
7-
```solidity
8-
constructor(address initialAuthority) public
9-
```
10-
11-
### allowUser
12-
13-
```solidity
14-
function allowUser(address user) public
15-
```
16-
17-
### disallowUser
18-
19-
```solidity
20-
function disallowUser(address user) public
21-
```
22-
23-
## ERC20Allowlist
24-
25-
_Extension of {ERC20} that allows to implement an allowlist
26-
mechanism that can be managed by an authorized account with the
27-
{_disallowUser} and {_allowUser} functions.
28-
29-
The allowlist provides the guarantee to the contract owner
30-
(e.g. a DAO or a well-configured multisig) that any account won't be
31-
able to execute transfers or approvals to other entities to operate
32-
on its behalf if {_allowUser} was not called with such account as an
33-
argument. Similarly, the account will be disallowed again if
34-
{_disallowUser} is called._
35-
36-
### _allowed
37-
38-
```solidity
39-
mapping(address => bool) _allowed
40-
```
41-
42-
_Allowed status of addresses. True if allowed, False otherwise._
43-
44-
### UserAllowed
45-
46-
```solidity
47-
event UserAllowed(address user)
48-
```
49-
50-
_Emitted when a `user` is allowed to transfer and approve._
51-
52-
### UserDisallowed
53-
54-
```solidity
55-
event UserDisallowed(address user)
56-
```
57-
58-
_Emitted when a user is disallowed._
59-
60-
### ERC20Disallowed
61-
62-
```solidity
63-
error ERC20Disallowed(address user)
64-
```
65-
66-
_The operation failed because the user is not allowed._
67-
68-
### allowed
69-
70-
```solidity
71-
function allowed(address account) public virtual returns (bool)
72-
```
73-
74-
_Returns the allowed status of an account._
75-
76-
### _allowUser
77-
78-
```solidity
79-
function _allowUser(address user) internal virtual returns (bool)
80-
```
81-
82-
_Allows a user to receive and transfer tokens, including minting and burning._
83-
84-
### _disallowUser
85-
86-
```solidity
87-
function _disallowUser(address user) internal virtual returns (bool)
88-
```
89-
90-
_Disallows a user from receiving and transferring tokens, including minting and burning._
91-
92-
### _update
93-
94-
```solidity
95-
function _update(address from, address to, uint256 value) internal virtual
96-
```
97-
98-
_See {ERC20-_update}._
99-
100-
### _approve
101-
102-
```solidity
103-
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual
104-
```
105-
106-
_See {ERC20-_approve}._
107-
108-
## MyStablecoin
109-
110-
### constructor
111-
112-
```solidity
113-
constructor(address initialAuthority) public
114-
```
115-
116-
### allowUser
117-
118-
```solidity
119-
function allowUser(address user) public
120-
```
121-
122-
### disallowUser
123-
124-
```solidity
125-
function disallowUser(address user) public
126-
```
127-
1283
## AccessManagerLight
1294

1305
_Light version of an AccessManager contract that defines `bytes8` roles
@@ -323,6 +198,26 @@ WARNING: Implementing a signature validation algorithm is a security-sensitive o
323198
cryptographic verification. It is important to review and test thoroughly before deployment. Consider
324199
using one of the signature verification libraries ({ECDSA}, {P256} or {RSA})._
325200

201+
## MyStablecoinAllowlist
202+
203+
### constructor
204+
205+
```solidity
206+
constructor(address initialAuthority) public
207+
```
208+
209+
### allowUser
210+
211+
```solidity
212+
function allowUser(address user) public
213+
```
214+
215+
### disallowUser
216+
217+
```solidity
218+
function disallowUser(address user) public
219+
```
220+
326221
## ERC20CollateralMock
327222

328223
### constructor
@@ -399,6 +294,91 @@ IMPORTANT: The way this function identifies whether the implementation is a beac
399294
if it implements the {IBeacon-implementation} function. Consider that an actual implementation could
400295
define this function, mistakenly identifying it as a beacon._
401296

297+
## ERC20Allowlist
298+
299+
_Extension of {ERC20} that allows to implement an allowlist
300+
mechanism that can be managed by an authorized account with the
301+
{_disallowUser} and {_allowUser} functions.
302+
303+
The allowlist provides the guarantee to the contract owner
304+
(e.g. a DAO or a well-configured multisig) that any account won't be
305+
able to execute transfers or approvals to other entities to operate
306+
on its behalf if {_allowUser} was not called with such account as an
307+
argument. Similarly, the account will be disallowed again if
308+
{_disallowUser} is called._
309+
310+
### _allowed
311+
312+
```solidity
313+
mapping(address => bool) _allowed
314+
```
315+
316+
_Allowed status of addresses. True if allowed, False otherwise._
317+
318+
### UserAllowed
319+
320+
```solidity
321+
event UserAllowed(address user)
322+
```
323+
324+
_Emitted when a `user` is allowed to transfer and approve._
325+
326+
### UserDisallowed
327+
328+
```solidity
329+
event UserDisallowed(address user)
330+
```
331+
332+
_Emitted when a user is disallowed._
333+
334+
### ERC20Disallowed
335+
336+
```solidity
337+
error ERC20Disallowed(address user)
338+
```
339+
340+
_The operation failed because the user is not allowed._
341+
342+
### allowed
343+
344+
```solidity
345+
function allowed(address account) public virtual returns (bool)
346+
```
347+
348+
_Returns the allowed status of an account._
349+
350+
### _allowUser
351+
352+
```solidity
353+
function _allowUser(address user) internal virtual returns (bool)
354+
```
355+
356+
_Allows a user to receive and transfer tokens, including minting and burning._
357+
358+
### _disallowUser
359+
360+
```solidity
361+
function _disallowUser(address user) internal virtual returns (bool)
362+
```
363+
364+
_Disallows a user from receiving and transferring tokens, including minting and burning._
365+
366+
### _update
367+
368+
```solidity
369+
function _update(address from, address to, uint256 value) internal virtual
370+
```
371+
372+
_See {ERC20-_update}._
373+
374+
### _approve
375+
376+
```solidity
377+
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual
378+
```
379+
380+
_See {ERC20-_approve}._
381+
402382
## ERC20Blocklist
403383

404384
_Extension of {ERC20} that allows to implement a blocklist

hardhat.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ module.exports = {
3434
hardfork: argv.hardfork,
3535
},
3636
},
37+
docgen: require('./docs/config'),
3738
};

scripts/gen-nav.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
3+
const path = require('path');
4+
const glob = require('glob');
5+
const startCase = require('lodash.startcase');
6+
7+
const baseDir = process.argv[2];
8+
9+
const files = glob.sync(baseDir + '/**/*.adoc').map(f => path.relative(baseDir, f));
10+
11+
console.log('.API');
12+
13+
function getPageTitle(directory) {
14+
switch (directory) {
15+
case 'metatx':
16+
return 'Meta Transactions';
17+
case 'common':
18+
return 'Common (Tokens)';
19+
default:
20+
return startCase(directory);
21+
}
22+
}
23+
24+
const links = files.map(file => {
25+
const doc = file.replace(baseDir, '');
26+
const title = path.parse(file).name;
27+
28+
return {
29+
xref: `* xref:${doc}[${getPageTitle(title)}]`,
30+
title,
31+
};
32+
});
33+
34+
// Case-insensitive sort based on titles (so 'token/ERC20' gets sorted as 'erc20')
35+
const sortedLinks = links.sort(function (a, b) {
36+
return a.title.toLowerCase().localeCompare(b.title.toLowerCase(), undefined, { numeric: true });
37+
});
38+
39+
for (const link of sortedLinks) {
40+
console.log(link.xref);
41+
}

scripts/prepare-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ examples_target_dir="docs/modules/api/examples"
2020
for f in "$examples_source_dir"/**/*.sol; do
2121
name="${f/#"$examples_source_dir/"/}"
2222
mkdir -p "$examples_target_dir/$(dirname "$name")"
23-
sed -Ee '/^import/s|"(\.\./)+|"@openzeppelin/contracts/|' "$f" > "$examples_target_dir/$name"
23+
sed -Ee '/^import/s|"(\.\./)+|"@openzeppelin/community-contracts/|' "$f" > "$examples_target_dir/$name"
2424
done
2525

2626
node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc"

0 commit comments

Comments
 (0)