Skip to content

Docs generation for the Contracts + GH action for detecting missing Natspec comments. #1937

Merged
elenadimitrova merged 25 commits intoethereum-optimism:developfrom
indeavr:develop
Dec 29, 2021
Merged

Docs generation for the Contracts + GH action for detecting missing Natspec comments. #1937
elenadimitrova merged 25 commits intoethereum-optimism:developfrom
indeavr:develop

Conversation

@indeavr
Copy link
Copy Markdown
Contributor

@indeavr indeavr commented Dec 15, 2021

Contains the dodoc output with the purpose of quick feedback.

Description:

  1. Docs generation from Natspec comments using dodoc harhat plugin
  2. Task (at compilation) checking for public/external components with missing Natspec comments.

Resolves #1933

… example output.

This is a WIP commit with the purpose of quick feedback on the result.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 15, 2021

⚠️ No Changeset found

Latest commit: 767fb0e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@smartcontracts
Copy link
Copy Markdown
Contributor

This is awesome, thank you! Since this is still a WIP, I'm going to convert this PR into a draft. Feel free to convert it back once you're ready for review.

@smartcontracts smartcontracts marked this pull request as draft December 15, 2021 19:06
…e are any missing Natspec comments.

Still WIP. Better console formatting + configurations is next :)
@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 16, 2021

I've just added the validation script that goes through the output and checks if there are any missing Natspec comments.
The task is currently ran on compilation & can be configured to throw. (no custom GH action will be required)

Next:

  1. Validate that the Dodoc md format is okay with Optimism.
  • Feedback required.
    --> If not ok -> I can edit the dodoc source (fork / PR)
  1. Add Config to the validate-output task
    --> error = throw or warn.
    --> checks = list of enabled checks.
    --> include; exclude; runOnCompile;

  2. Beautify the console output.

  3. Make a separate package (hardhat plugin) with the validate-output task. (optional)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 16, 2021

Codecov Report

Merging #1937 (767fb0e) into develop (a5001aa) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1937   +/-   ##
========================================
  Coverage    74.42%   74.42%           
========================================
  Files           79       79           
  Lines         2545     2545           
  Branches       397      397           
========================================
  Hits          1894     1894           
  Misses         651      651           
Flag Coverage Δ
batch-submitter 62.50% <ø> (ø)
contracts 90.48% <ø> (ø)
core-utils 57.50% <ø> (ø)
data-transport-layer 38.64% <ø> (ø)
message-relayer 70.86% <ø> (ø)
sdk 87.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5001aa...767fb0e. Read the comment docs.

@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 16, 2021

Update:

  • Added the config options for the output-checker.
  • Added one extra check = "Compilation Warnings" in build.
  • Refactored based on Elena's feedback :)

Next:

  • Get Feedback on approach & output (both md and logs).
  • Let me know if there are any other requirnments (How would the docs be deployed live ?).
  • Thorough Testing.
  • Move code to a npm package :)

@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 18, 2021

Update:

  • Added the config options for the output-checker.
  • Added one extra check = "Compilation Warnings" in build.
  • Refactored based on Elena's feedback :)

Next:

  • Get Feedback on approach & output (both md and logs).
  • Let me know if there are any other requirnments (How would the docs be deployed live ?).
  • Thorough Testing.
  • Move code to a npm package :)

Update:

  • Around 50-60 "missing comments" are found by the new plugin.
  • Plugin is published in npm - hardhat-output-validator
  • Awaiting Feedback & Additional Work :)

@indeavr indeavr marked this pull request as ready for review December 19, 2021 08:45
@elenadimitrova
Copy link
Copy Markdown

Can you please update the docs to docs/Initializable.md which appears to have changed.

Another thing for the wish list is to also detect incorrect or missing function parameters or return values. I am certain this was a feature of the solidity complier before although not sure why we're not getting these reports now.

@elenadimitrova
Copy link
Copy Markdown

There is also one failure in CI on https://github.com/ethereum-optimism/optimism/runs/4616712161?check_suite_focus=true if you can fix pls.

@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 23, 2021

Can you please update the docs to docs/Initializable.md which appears to have changed.

Another thing for the wish list is to also detect incorrect or missing function parameters or return values. I am certain this was a feature of the solidity complier before although not sure why we're not getting these reports now.

👍 Updated.
🥇 Added support for @return & @param !
I as well have a memory of these errors of the compiler. However I believe the "DocstringParsingError" appears only when you misspell a @param name and not when it's missing.

@elenadimitrova
Copy link
Copy Markdown

Nice but missing @param comments are now being inherited from external libraries, e.g.

Comments Error: Function: (transferOwnership) is missing @param comment
   @ Lib_AddressManager
   --> contracts/libraries/resolver/Lib_AddressManager.sol

@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 23, 2021

Nice but missing @param comments are now being inherited from external libraries, e.g.

Comments Error: Function: (transferOwnership) is missing @param comment
   @ Lib_AddressManager
   --> contracts/libraries/resolver/Lib_AddressManager.sol

Pff this proved to be tricky.

Should be working now :)

@elenadimitrova
Copy link
Copy Markdown

elenadimitrova commented Dec 23, 2021

Yep working now thanks. Checking output one by one, meanwhile I found these to be false positives

Comments Error: Function: (deleteElementsAfterInclusive), param: (_globalMetadata) is missing @param comment
   @ IChainStorageContainer
   --> contracts/L1/rollup/IChainStorageContainer.sol`

Comments Error: Function: (push), param: (_globalMetadata) is missing @param comment
   @ IChainStorageContainer
   --> contracts/L1/rollup/IChainStorageContainer.sol

Maybe there is a problem with overloads?

@indeavr
Copy link
Copy Markdown
Contributor Author

indeavr commented Dec 23, 2021

Yep working now thanks. Checking output one by one, meanwhile I found these to be false positives

Comments Error: Function: (deleteElementsAfterInclusive), param: (_globalMetadata) is missing @param comment
   @ IChainStorageContainer
   --> contracts/L1/rollup/IChainStorageContainer.sol`

Comments Error: Function: (push), param: (_globalMetadata) is missing @param comment
   @ IChainStorageContainer
   --> contracts/L1/rollup/IChainStorageContainer.sol

Maybe there is a problem with overloads?

Fixed. Good catch ! :)
Dodoc has the same issue - overloads don't get their docs generated. I've created a PR for this as well :)

Copy link
Copy Markdown

@elenadimitrova elenadimitrova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. Great work 🎉

@elenadimitrova elenadimitrova merged commit a7cf8e6 into ethereum-optimism:develop Dec 29, 2021
theochap pushed a commit that referenced this pull request Dec 10, 2025
## Overview

Updates the consolidate task to only send a forkchoice update for safe
head promotion if the attributes are either derived from a
`SingleBatch`, or if the attributes are the last attributes within a
`SpanBatch`.

closes #1757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contract API reference

4 participants