Skip to content

Commit

Permalink
fix: fix return tag in auto-gen doc, @return removed
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Aug 1, 2023
1 parent cc37fae commit 20421b4
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 1 deletion.
19 changes: 19 additions & 0 deletions examples/contracts/SomeOtherLibrary/SomeOtherLibrary.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.6;

contract SomeOtherLibrary {
/// @dev This function uses `keccak256(..)` to hash text.
/// @notice Hash returned.
/// @param someText Any text that you want to hash.
/// @return The hash that was sent as a parameter.
function someFunction(string memory someText) internal pure returns(bytes32) {
return keccak256(bytes(someText));
}
/// @dev This function uses `sha256(..)` to hash text.
/// @notice Hash returned.
/// @param someText Any text that you want to hash.
/// @return hash The hash that was sent as a parameter.
function someOtherFunction(string memory someText) internal pure returns(bytes32 hash) {
return sha256(bytes(someText));
}
}
43 changes: 43 additions & 0 deletions examples/docs/contracts/SomeOtherLibrary/SomeOtherLibrary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"methods": {},
"events": {},
"errors": {},
"internalMethods": {
"someFunction(string)": {
"code": "function someFunction(string someText) internal pure returns (bytes32)",
"inputs": {
"someText": {
"type": "string",
"description": "Any text that you want to hash."
}
},
"outputs": {
"_0": {
"type": "bytes32",
"description": "The hash that was sent as a parameter."
}
},
"details": "This function uses `keccak256(..)` to hash text.",
"notice": "Hash returned."
},
"someOtherFunction(string)": {
"code": "function someOtherFunction(string someText) internal pure returns (bytes32 hash)",
"inputs": {
"someText": {
"type": "string",
"description": "Any text that you want to hash."
}
},
"outputs": {
"hash": {
"type": "bytes32",
"description": "The hash that was sent as a parameter."
}
},
"details": "This function uses `sha256(..)` to hash text.",
"notice": "Hash returned."
}
},
"path": "SomeOtherLibrary",
"name": "SomeOtherLibrary"
}
66 changes: 66 additions & 0 deletions examples/docs/contracts/SomeOtherLibrary/SomeOtherLibrary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# SomeOtherLibrary












## Internal Methods

### someFunction

```solidity
function someFunction(string someText) internal pure returns (bytes32)
```

Hash returned.
*This function uses `keccak256(..)` to hash text.*




#### Parameters

| Name | Type | Description |
|---|---|---|
| someText | string | Any text that you want to hash. |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | The hash that was sent as a parameter. |

### someOtherFunction

```solidity
function someOtherFunction(string someText) internal pure returns (bytes32 hash)
```

Hash returned.
*This function uses `sha256(..)` to hash text.*




#### Parameters

| Name | Type | Description |
|---|---|---|
| someText | string | Any text that you want to hash. |

#### Returns

| Name | Type | Description |
|---|---|---|
| hash | bytes32 | The hash that was sent as a parameter. |




5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise<vo

doc[docEntry][functionName].outputs[returnVariableName] = {
type: returnParamType,
description: returnDoc[index].replace(`@return ${returnVariableName} `, ''),
// return tag param is not mandatory
description: returnDoc[index]
.replace(`@return ${returnVariableName} `, '') // this will be removed if param is present
.replace('@return ', ''), // this will be removed if param is not present
};
});
}
Expand Down

0 comments on commit 20421b4

Please sign in to comment.