chore: added markdown docs templates#220
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
♻️ Duplicate comments (1)
docs/templates-md/properties.js (1)
23-29: Code duplication and null safety issue.This code duplicates the signature-building logic from the
anchorfunction and has the same null safety concerns.See the refactor suggestion in the previous comment (lines 10-16) which addresses both issues by extracting common logic and adding null checks.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/config-md.js(1 hunks)docs/templates-md/contract.hbs(1 hunks)docs/templates-md/helpers.js(1 hunks)docs/templates-md/page.hbs(1 hunks)docs/templates-md/properties.js(1 hunks)hardhat.config.js(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
hardhat.config.js (2)
docs/templates-md/helpers.js (2)
require(1-1)require(4-4)docs/templates-md/properties.js (2)
require(1-1)require(2-2)
docs/templates-md/properties.js (1)
docs/templates-md/helpers.js (2)
slug(67-72)i(139-139)
docs/templates-md/helpers.js (1)
docs/templates-md/properties.js (5)
require(1-1)require(2-2)item(83-83)signature(11-11)signature(24-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: slither
- GitHub Check: tests-foundry
- GitHub Check: coverage
- GitHub Check: tests
🔇 Additional comments (3)
docs/templates-md/properties.js (3)
59-65: LGTM! Good defensive coding.The ternary operator properly handles the case where
item.variablesdoesn't exist, preventing potential runtime errors.
67-72: LGTM!The function correctly aggregates publicly visible functions and public variables using AST queries with appropriate visibility filters.
47-57: Add null safety checks foritem.inheritance.All three functions assume
item.inheritanceexists and is an array. If it'sundefined, calling.some()will throw a runtime error.Apply this diff to add defensive checks:
module.exports['has-functions'] = function ({ item }) { - return item.inheritance && item.inheritance.some(c => c.functions.length > 0); + return item.inheritance?.some(c => c.functions?.length > 0) ?? false; }; module.exports['has-events'] = function ({ item }) { - return item.inheritance && item.inheritance.some(c => c.events.length > 0); + return item.inheritance?.some(c => c.events?.length > 0) ?? false; }; module.exports['has-errors'] = function ({ item }) { - return item.inheritance && item.inheritance.some(c => c.errors.length > 0); + return item.inheritance?.some(c => c.errors?.length > 0) ?? false; };Likely an incorrect or invalid review comment.
- Updated all README.adoc to README.mdx - Moved `templates-md` and the contents to just `templates` - Updated `hardhat.config.js` to use `docs/config` - Updated `helpers.js` to account for adoc change - Updated `docs/config.js` to use mdx
Updated the following legacy patterns: - `https://url[Link Text]` -> `[Link Text](https://url)` - `WARNING: | IMPORTANT: | CAUTION: | IMPORTANT:` -> `<Callout type=warn"></Callout>` - `NOTE: | TIP:` -> <Callout></Callout> - Delimitters such as `====` -> `####` or removed if no header text present
|
Updated the following legacy patterns in the natspec:
With the |
| return `${pagePath}#${anchor}`; | ||
| } | ||
|
|
||
| // Process {REF} and other references |
There was a problem hiding this comment.
So most replacing logic can be removed now right?
There was a problem hiding this comment.
I think for this repo we could remove pieces like L:146-149 and maybe L:157-162, but these are patterns used in other libraries. We definitely still need L:151-155 and the rest of functions to handle instances where a contract references another contract, .e.g. you might have {ERC20} inside ERC1155 comments and we need to turn that into a markdown link.
There was a problem hiding this comment.
I would also remove L:146-149
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>
|
I honestly do not like the NatSpec changes of TIP, WARNING and NOTE into writting HTML components inside our contracts. While it remains functional, I think it looks much worse for a human reading the contracts directly. Therefore, I think the parsing into HTML components should happen outside of the contracts and maintain human-first readability. |
Yes, at the very beginning I thought changing these were the only things required for the API doc migration so why not doing it, but afterward considering the later high templating/processing, I would also like to come back to the original NatSpec 👍 |
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>
|
Just automated the watch mode so changes are hot-refreshed on the local copy of the docs repository. Also added cache so it is updated instead of being re-clonned each time docs are run |
ernestognw
left a comment
There was a problem hiding this comment.
I'm leaving some observations and recommendations but I don't want to block the PR. There may be still some details in how we're processing the docs but we can sort them out easily as long as we have a preview for future PRs.
There was a problem hiding this comment.
Haven't checked personally but I feel there might be orphan exported functions here now that we changed the contract.hbs and page.hbs. It may be good to do a cleanup of this and the properties.js file
There was a problem hiding this comment.
At least internal-variables things got removed from documentation, do you confirm we don't need it in the final public documentation?
There was a problem hiding this comment.
They're not referenced in the docs repo, and also these should apply only to the templates in this repo so I think it's safe to remove them
Co-authored-by: Ernesto García <ernestognw@gmail.com>
121336e
|
Closing in favor of #225 |
31/10/2025:
This PR adds the updated
templates-mdandconfig-md.jsto thedocsdirectory. By doing this we can generate API documentation forOpenZeppelin/docsremotely. Please see the guide hereUpdate (18/12/2025):
docs-utils, which clones the@openzeppelin/docsrepository and runs it locally with a chokidar watcher that re-prepares and syncs the docs into the local docs project on changes for a hot refresh experience.