Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: md documentation generation from natspec #1410

Closed
simluyt opened this issue Apr 25, 2022 · 3 comments
Closed

Feature Request: md documentation generation from natspec #1410

simluyt opened this issue Apr 25, 2022 · 3 comments
Labels
C-forge Command: forge D-average Difficulty: average P-low Priority: low T-feature Type: feature

Comments

@simluyt
Copy link

simluyt commented Apr 25, 2022

Component

Forge

Describe the feature you would like

A nice feature that is included in most dev tools is the generation of documentation using natspec. In the past there have been a multitude of tools that do this. OpenZeppelin has solidity-docgen to generate markdown form natspec solidity code and afaik this is also what hardhat-docgen is using.

Ideally there would be a new subcommand for forge like

forge docgen

that generates documentation from natspec to markdown (or other formats) that can be used to populate a gitbook, docs.rs, docusaurus or any other style documentation website.

Example:
forge docgen --md
could generate markdown from natspec like this:

 /**
   * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
   * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
   * @param asset The address of the underlying asset to withdraw
   * @param amount The underlying amount to be withdrawn
   *   - Send the value type(uint256).max in order to withdraw the whole aToken balance
   * @param to Address that will receive the underlying, same as msg.sender if the user
   *   wants to receive it on his own wallet, or a different address if the beneficiary is a
   *   different wallet
   * @return The final amount withdrawn
   **/
  function withdraw(
    address asset,
    uint256 amount,
    address to
  ) external returns (uint256);

to this:

### withdraw

'''solidity
  function withdraw(
    address asset,
    uint256 amount,
    address to
  ) external returns (uint256);'''


@notice here if there was one

*@dev here: Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
   * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC**

#### Parameters

| Name | Type | Description |
|---|---|---|
| asset | address | The address of the underlying asset to withdraw. |
| amount | uint256 | The underlying amount to be withdrawn. |
| to | address | Address that will receive the underlying... |

#### Returns

| Name | Type | Description |
|---|---|---|
| undefined | uint256 | The final amount withdrawn |

which could be used in the documentation services mentioned before.

hardhat docgen gives additional options like --output, --exclude and a bunch of others which might also be useful here.

Additional context

No response

@simluyt simluyt added the T-feature Type: feature label Apr 25, 2022
@onbjerg onbjerg added this to Foundry Apr 25, 2022
@onbjerg onbjerg moved this to Todo in Foundry Apr 25, 2022
@simluyt simluyt changed the title md documentation generation from natspec Feature Request: md documentation generation from natspec Apr 25, 2022
@onbjerg
Copy link
Collaborator

onbjerg commented Apr 26, 2022

There are some things I would like for a Forge documentation generator:

  • Structured file names and paths, like docs.rs. For example, docs for:
    • Contracts would be something like relative/path/contract.SomeContract.html
    • Structs would be struct.SomeStruct.html
    • And so on
  • Support for rustdoc-style docs. Natspec is kind of annoying (imo), so it would be nice to have some sort of Rustdoc-like comment format where the first sentence is userdoc and the next sentences (after an empty line) would be devdoc or something similar
  • Docs for contracts, libraries, events and interfaces
  • "Module-level" docs like we have in Rust for mod.rs so you can create index pages
  • Output to HTML and Markdown
  • Easy linking to other parts of the code, like in Rust, where you can do e.g. [SomeStruct] and it would link to the struct if it is in scope, or [SomeInterface] and so on

This would allow us to build a docs.rs for Solidity

@onbjerg onbjerg added P-low Priority: low D-average Difficulty: average C-forge Command: forge labels Apr 26, 2022
@mattsse
Copy link
Member

mattsse commented Apr 26, 2022

Ref gakonst/ethers-rs#1182

@onbjerg onbjerg mentioned this issue Jul 1, 2022
4 tasks
@onbjerg
Copy link
Collaborator

onbjerg commented Jul 1, 2022

I'm going to close this issue in favor of #1675

@onbjerg onbjerg closed this as completed Jul 1, 2022
Repository owner moved this from Todo to Done in Foundry Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge D-average Difficulty: average P-low Priority: low T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

3 participants