Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Dec 24, 2024
1 parent 01405a0 commit cb13e82
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 39 deletions.
4 changes: 2 additions & 2 deletions docs/accounts/erc1271.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ERC1271 mixin with nested EIP-712 approach.



<b>Inherits:</b>
<b>Inherits:</b>

- `utils/EIP712.sol`
- `utils/EIP712.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
10 changes: 5 additions & 5 deletions docs/accounts/erc4337.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ for security reviews. This implementation is intended to serve as a base referen
for smart account developers working in such companies. If you are using this
implementation, please do get one or more security reviews before deployment.

<b>Inherits:</b>
<b>Inherits:</b>

- `auth/Ownable.sol`
- `utils/UUPSUpgradeable.sol`
- `accounts/Receiver.sol`
- `accounts/ERC1271.sol`
- `auth/Ownable.sol`
- `utils/UUPSUpgradeable.sol`
- `accounts/Receiver.sol`
- `accounts/ERC1271.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
8 changes: 4 additions & 4 deletions docs/accounts/erc6551.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ user operation validation functionality (and use ERC6551's execution functionali
- Please refer to the official [ERC6551](https://github.com/erc6551/reference) reference
for latest updates on the ERC6551 standard, as well as canonical registry information.

<b>Inherits:</b>
<b>Inherits:</b>

- `utils/UUPSUpgradeable.sol`
- `accounts/Receiver.sol`
- `accounts/ERC1271.sol`
- `utils/UUPSUpgradeable.sol`
- `accounts/Receiver.sol`
- `accounts/ERC1271.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
4 changes: 2 additions & 2 deletions docs/accounts/erc7821.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Minimal batch executor mixin.



<b>Inherits:</b>
<b>Inherits:</b>

- `accounts/Receiver.sol`
- `accounts/Receiver.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
6 changes: 3 additions & 3 deletions docs/accounts/timelock.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Simple timelock.



<b>Inherits:</b>
<b>Inherits:</b>

- `accounts/ERC7821.sol`
- `auth/EnumerableRoles.sol`
- `accounts/ERC7821.sol`
- `auth/EnumerableRoles.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
4 changes: 2 additions & 2 deletions docs/auth/ownableroles.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ While the ownable portion follows
[EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,
the nomenclature for the 2-step ownership handover may be unique to this codebase.

<b>Inherits:</b>
<b>Inherits:</b>

- `auth/Ownable.sol`
- `auth/Ownable.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
4 changes: 2 additions & 2 deletions docs/tokens/erc20votes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ERC20 with votes based on ERC5805 and ERC6372.



<b>Inherits:</b>
<b>Inherits:</b>

- `tokens/ERC20.sol`
- `tokens/ERC20.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
4 changes: 2 additions & 2 deletions docs/tokens/erc4626.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Simple ERC4626 tokenized Vault implementation.



<b>Inherits:</b>
<b>Inherits:</b>

- `tokens/ERC20.sol`
- `tokens/ERC20.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
4 changes: 2 additions & 2 deletions docs/tokens/weth.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Simple Wrapped Ether implementation.



<b>Inherits:</b>
<b>Inherits:</b>

- `tokens/ERC20.sol`
- `tokens/ERC20.sol`


<!-- customintro:start --><!-- customintro:end -->
Expand Down
6 changes: 3 additions & 3 deletions prep/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const forEachWalkSync = (dirs, callback) => {
dirs.forEach(dir => walkSync(dir, callback));
};

const withSmallerLineLength = (src, lineLength) => {
const readSolWithLineLengthSync = (srcPath, lineLength) => {
const withModifiedToml = callback => {
const originalFile = path.resolve('foundry.toml');
const backupFile = path.resolve('__tmp_foundry.toml');
Expand All @@ -74,7 +74,7 @@ const withSmallerLineLength = (src, lineLength) => {
};
return withModifiedToml(() => {
const tempFile = '__tmp.sol';
fs.writeFileSync(tempFile, src, 'utf8');
fs.copyFileSync(srcPath, tempFile);
runCommandSync('forge', ['fmt', tempFile]);
let content = fs.readFileSync(tempFile, 'utf8');
fs.unlinkSync(tempFile);
Expand All @@ -93,5 +93,5 @@ module.exports = {
writeAndFmtSync,
walkSync,
forEachWalkSync,
withSmallerLineLength
readSolWithLineLengthSync
};
23 changes: 11 additions & 12 deletions prep/gen-docs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const { readSync, writeSync, forEachWalkSync, hasAnyPathSequence, withSmallerLineLength } = require('./common.js');
const { readSync, writeSync, forEachWalkSync, hasAnyPathSequence, readSolWithLineLengthSync } = require('./common.js');
const path = require('path');

async function main() {
Expand All @@ -12,7 +12,7 @@ async function main() {
'(<!--\\s?' + cleanForRegex(tag) + ':end\\s?-->)'
);

const hasSubString = (a, b) => a.toLowerCase().indexOf(b.toLowerCase()) !== -1;
const has = (a, b) => a.toLowerCase().indexOf(b.toLowerCase()) !== -1;

const replaceInTag = (src, tag, replacement) =>
src.replace(
Expand Down Expand Up @@ -69,7 +69,7 @@ async function main() {
});
}
return a
.filter(x => !hasSubString(x.header, 'private'))
.filter(x => !has(x.header, 'private'))
.map(item => {
const m = (/^((\s+\/\/\s[^\n]+)+)/).exec(item.src);
if (m) item.note = cleanNatspecOrNote(m[0]);
Expand All @@ -80,7 +80,7 @@ async function main() {
const getSubSections = (s, r) => {
let a = [];
for (let m = null; (m = r.exec(s)) !== null; ) {
if (!hasSubString(m[2], '///') && !/\sprivate\s/.test(m[2])) a.push(m);
if (!has(m[2], '///') && !/\sprivate\s/.test(m[2])) a.push(m);
}
return a;
}
Expand Down Expand Up @@ -140,17 +140,17 @@ async function main() {
l.replace(/^\/\/\/\s*/, '')
.replace(/^@dev\s?([\s\S]+?)\:/, '$1:\n\n')
.replace(/^Note\:/, 'Note:\n\n')
.replace(/^[\s\S]{1,64}\:/, m => hasSubString(m, 'http') ? m : '<b>' + m + '</b>')
.replace(/^[\s\S]{1,64}\:/, m => has(m, 'http') ? m : '<b>' + m + '</b>')
).join('\n')
.replace(/@dev\s/g, '')
)
);

const getInherits = (s, srcPath) => coalesce(
s.match(/contract\s+[A-Za-z0-9_]+\s+is\s+([^\{]*?)\s*\{/),
m => '<b>Inherits:</b> \n\n' +
m => '<b>Inherits:</b> \n\n' +
m[1].split(',').map(strip).map(p =>
getImports(s, srcPath).map(q => hasSubString(q, p) ? '- `' + q + '` \n' : '').join('')
getImports(s, srcPath).map(q => has(q, p) ? '- `' + q + '` \n' : '').join('')
).join('')
);

Expand All @@ -164,10 +164,10 @@ async function main() {
forEachWalkSync(['src'], srcPath => {
if (!srcPath.match(/\.sol$/i)) return;
if (hasAnyPathSequence(srcPath, pathSequencesToIgnore)) return;
if (hasSubString(srcPath, 'Milady.sol')) return;
if (has(srcPath, 'Milady.sol')) return;
console.log(srcPath);

let src = withSmallerLineLength(readSync(srcPath), 80);
let src = readSolWithLineLengthSync(srcPath, 80);
let sections = getSections(src);

if (sections.length < 1) {
Expand All @@ -184,8 +184,7 @@ async function main() {
const docHeader = '# ' + getTitle(srcPath) + '\n\n' + getNotice(src);
let writeDoc = false;
let docChunks = [];
for (let i = 0; i < sections.length; ++i) {
let x = sections[i];
sections.forEach(x => {
let a = getStructsAndEnums(x.src);
if (a.length < 1) a = getCustomErrors(x.src);
if (a.length < 1) a = getFunctionsAndModifiers(x.src);
Expand All @@ -200,7 +199,7 @@ async function main() {
y.natspec
));
}
}
});

if (writeDoc) {
writeSync(
Expand Down

0 comments on commit cb13e82

Please sign in to comment.