forked from primitivefinance/primitive-dodoc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66ffc09
Showing
15 changed files
with
9,392 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
env: { | ||
browser: false, | ||
es2021: true, | ||
mocha: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
rules: { | ||
'import/extensions': ['error', 'never'], | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
paths: ['./src'], | ||
extensions: ['.ts'], | ||
}, | ||
}, | ||
}, | ||
}; |
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,8 @@ | ||
/node_modules | ||
.env | ||
/build | ||
/cache | ||
/typechain | ||
/artifacts | ||
/flatten | ||
.vscode |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Primitive | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# Dodoc |
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,10 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity 0.8.9; | ||
|
||
/// @title Bar contract | ||
/// @author Vitalik | ||
contract Bar { | ||
/// @notice Cool function | ||
function bar() external { | ||
} | ||
} |
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,59 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity 0.8.9; | ||
|
||
/// @title Title goes here | ||
/// @author Author goes here | ||
/// @notice Notice of the contract goes here | ||
/// @dev Dev of the contract goes here | ||
contract Foo { | ||
/// @notice Emitted when doSomething is called | ||
/// @dev More info about the event | ||
/// @param a Address of someone | ||
/// @param b A random number | ||
event DoSomething( | ||
address a, | ||
uint256 b | ||
); | ||
|
||
/// @notice Thrown when an error happens | ||
/// @dev More info about the error | ||
/// @param expected Bad address | ||
/// @param actual Good address | ||
error DoSomethingError(address expected, address actual); | ||
|
||
/// @notice This is the fallback | ||
/// @dev Please send ETH | ||
fallback() external { | ||
// A fallback function | ||
} | ||
|
||
/// @notice Does something | ||
/// @dev More info about do something | ||
/// @param a Address to do something | ||
/// @param b Number to do something | ||
/// @return foo First Return variable | ||
/// @return bar second Return variable | ||
function doSomething(address a, uint256 b) external returns ( | ||
uint256 foo, | ||
uint256 bar | ||
) { | ||
if (a == address(0)) revert DoSomethingError(a, msg.sender); | ||
emit DoSomething(a, b); | ||
|
||
bar = 42; | ||
foo = 0; | ||
} | ||
|
||
/// @notice Does another thing | ||
/// @dev More info about doing another thing | ||
/// @param num A random number | ||
/// @return A random variable | ||
function anotherThing(uint256 num) external pure returns (uint256) { | ||
return 42 + num; | ||
} | ||
|
||
/// @notice Poorly documented function | ||
function boop() external view returns (address) { | ||
return msg.sender; | ||
} | ||
} |
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,81 @@ | ||
# Foo | ||
|
||
*Author goes here* | ||
|
||
> Title goes here | ||
Notice of the contract goes here | ||
|
||
*Dev of the contract goes here* | ||
|
||
## Methods | ||
|
||
### `anotherThing` | ||
|
||
```anotherThing(uint256) pure``` | ||
|
||
Does another thing | ||
|
||
*More info about doing another thing* | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| num | uint256 | A random number | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | uint256 | A random variable | | ||
|
||
### `doSomething` | ||
|
||
```doSomething(address,uint256) nonpayable``` | ||
|
||
Does something | ||
|
||
*More info about do something* | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| a | address | Address to do something | | ||
| b | uint256 | Number to do something | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| bar | uint256 | second Return variable | | ||
| foo | uint256 | First Return variable | | ||
|
||
### `boop` | ||
|
||
```boop() view``` | ||
|
||
Poorly documented function | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | address | | | ||
|
||
### Events | ||
|
||
### `DoSomething` | ||
|
||
Emitted when doSomething is called | ||
|
||
*More info about the event* | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| a | address | Address of someone | | ||
| b | uint256 | A random number | | ||
|
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,15 @@ | ||
import { HardhatUserConfig } from 'hardhat/config'; | ||
import '@nomiclabs/hardhat-waffle'; | ||
import '@nomiclabs/hardhat-ethers'; | ||
import './src'; | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: '0.8.9', | ||
dodoc: { | ||
runOnCompile: true, | ||
include: ['Foo'], | ||
exclude: [], | ||
}, | ||
}; | ||
|
||
export default config; |
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,28 @@ | ||
{ | ||
"name": "primitive-dodoc", | ||
"version": "0.0.1", | ||
"description": "Documentation generator plugin for Hardhat", | ||
"main": "index.js", | ||
"author": "clemlak", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.0.2", | ||
"@nomiclabs/hardhat-waffle": "^2.0.1", | ||
"@types/chai": "^4.2.22", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.10.1", | ||
"chai": "^4.3.4", | ||
"ethereum-waffle": "^3.4.0", | ||
"ethers": "^5.4.7", | ||
"hardhat": "^2.6.4", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.2.4" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.21.0", | ||
"@typescript-eslint/parser": "^4.21.0", | ||
"eslint": "^7.24.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.22.1" | ||
} | ||
} |
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,117 @@ | ||
import { CompilerOutputContract } from 'hardhat/types'; | ||
|
||
export interface CompilerOutputContractWithDocumentation extends CompilerOutputContract { | ||
devdoc?: { | ||
author?: string; | ||
details?: string; | ||
title?: string; | ||
errors?: { | ||
[key: string]: { | ||
|
||
} | ||
} | ||
events?: { | ||
[key: string]: { | ||
details: string; | ||
params: { | ||
[key: string]: string; | ||
} | ||
} | ||
} | ||
methods?: { | ||
[key: string]: { | ||
details?: string; | ||
params: { | ||
[key: string]: string; | ||
}, | ||
returns: { | ||
[key: string]: string; | ||
} | ||
} | ||
}, | ||
returns?: { | ||
[key: string]: { | ||
details?: string; | ||
params: { | ||
[key: string]: string; | ||
} | ||
} | ||
} | ||
}, | ||
userdoc?: { | ||
errors?: any; | ||
events?: { | ||
[key: string]: { | ||
notice: string; | ||
}, | ||
}, | ||
methods?: { | ||
[key: string]: { | ||
notice: string; | ||
}, | ||
}, | ||
notice?: string; | ||
} | ||
} | ||
|
||
export interface Event { | ||
notice?: string; | ||
details?: string; | ||
params?: { | ||
[key: string]: { | ||
type?: string; | ||
description?: string; | ||
} | ||
} | ||
} | ||
|
||
export interface Events { | ||
[key: string]: Event; | ||
} | ||
|
||
export interface Method { | ||
sig: string; | ||
stateMutability?: string; | ||
notice?: string; | ||
details?: string; | ||
params?: { | ||
[key: string]: { | ||
type?: string; | ||
description?: string; | ||
} | ||
}; | ||
returns?: { | ||
[key: string]: { | ||
type?: string; | ||
description?: string; | ||
} | ||
}; | ||
} | ||
|
||
export interface Methods { | ||
[key: string]: Method; | ||
} | ||
|
||
export interface ContractDocumentation { | ||
name: string; | ||
title?: string; | ||
author?: string; | ||
notice?: string; | ||
details?: string; | ||
methods?: Methods; | ||
events?: Events; | ||
} | ||
|
||
export interface AbiElementPut { | ||
internalType: string; | ||
name: string; | ||
type: string; | ||
} | ||
|
||
export interface AbiElement { | ||
type: 'function' | 'event' | 'error'; | ||
name: string; | ||
stateMutability?: string; | ||
inputs?: AbiElementPut[]; | ||
outputs?: AbiElementPut[]; | ||
} |
Oops, something went wrong.