foundry icon indicating copy to clipboard operation
foundry copied to clipboard

meta(doc): tracking issue for `forge doc` improvements

Open transmissions11 opened this issue 2 years ago • 4 comments

Features:

  • [ ] https://github.com/foundry-rs/foundry/issues/4241
  • [ ] https://github.com/foundry-rs/foundry/issues/5800
  • [ ] https://github.com/foundry-rs/foundry/issues/8488
  • [x] https://github.com/foundry-rs/foundry/issues/8484
  1. Resolve relative image imports in home properly

When testing forge doc w/ Art Gobblers the home page shows up like this:

image

The broken images seem to be due to the fact that the Art Gobblers readme uses relative imports like ![Gobbler Lifecycle](assets/state-machines/gobbler-lifecycle.png) for images which work on Github but not with forge doc. Would be nice if they were as 1:1 compatible as possible.

  1. More eager link resolving

i.e: Links in the author section do not get shown as hyperlinks:

image

  1. Table of contents sidebar for each file/contract

Would make it a lot easier to navigate large contracts' docs if there was a table of contents on sidebar that had a collapsable header for functions, events, errors, etc and you could open them to skip to specific functions/events/errors/etc.

transmissions11 avatar Jan 18 '23 04:01 transmissions11

I'm also loving forge doc! I was gonna create a new issue with a couple things I noticed, but figured I'd leave them here since this issue is already scoped broadly

  1. +1 on table of contents sidebar

  2. User-defined SUMMARY.md. Just like a user can provide their own settings for the book by specifying a path for book.toml, it would be great to be able to define book layout by specifying a path for a custom SUMMARY.md file.

  3. Support for extra-watch-dirs. This would be useful for allowing projects to include more detailed docs and guides outside of the project readme and NatSpec.

spengrah avatar Jan 21 '23 21:01 spengrah

Agree with everything here. Only comment is on @slgraham third item: Perhaps instead of extra-watch-dirs, we just put those additional docs in the same docs folder that gets created by forge doc. Might need to move all the autogenerated stuff into a subfolder like docs/docgen so it's easy to commit the custom SUMMARY.md and other custom files while not comitting the generated docs. And the SUMMARY.md file would specify what to do with your custom files

mds1 avatar Jan 24 '23 17:01 mds1

Hey guys, are there any workarounds for this ?

syahrul12345 avatar Jan 29 '23 11:01 syahrul12345

From: https://github.com/foundry-rs/foundry/issues/4241 by @alexange

All free functions (including custom errors) are exported with their own markdown file, leading to a lot of singular pages with only one piece of code. Since they are not defined within an interface or contract but they are within a solidity file, there should be a singular markdown file exported for each solidity file which includes all of its free functions, constants and custom errors.

Free constants are already exported to a dedicated "constants" file with the solidity file name, so this should just be extended to include all free functions and variables.

zerosnacks avatar Jun 28 '24 14:06 zerosnacks