1

I would like to document my smart contracts functions using NatSpec Format.

Is there a VSCode extension I can use to do this, that basically generates that boilerplate code for me to fill in?

1
  • 1
    I might be incorrect, but the Solidity plugin for Visual Studio Code gives you the boilerplate when you type /** for a function. I might be mixing with some other editor/language. Commented Aug 12, 2024 at 17:08

2 Answers 2

1
  • There's no such thing to auto-generate boilerplate code comments (NatSpec) in VSCode. You'll have to write them manually for now.
  • You can use basic code commenting and follow standard NatSpec rules to create clear and helpful documentation.

I recently did in my code using this pattern:

/** * @notice Mints a newly minted NFT and assigns it to the caller. * @param _tokenURI The URI to be associated with the newly minted NFT. * @return newItemId The ID of the newly minted NFT. */ function mintNFT(string memory _tokenURI) public returns (uint) { require(bytes(_tokenURI).length > 0, "Token URI cannot be empty"); uint256 newItemId = _tokenIds; _mint(msg.sender, newItemId); _setTokenURI(newItemId, _tokenURI); _tokenIds += 1; emit NFTMinted(msg.sender, newItemId, _tokenURI); return newItemId; } 
1

As Mikko said, if you type /** above a function name and choose NatSpec function documentation you will get the NatSpec boilerplate code for all the function parameters automatically.

The extension is called solidity.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.