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] Show contract documentation #8

Open
bartolomej opened this issue May 15, 2024 · 2 comments
Open

[FEATURE] Show contract documentation #8

bartolomej opened this issue May 15, 2024 · 2 comments

Comments

@bartolomej
Copy link

Issue to be solved

At the moment, when you click on the contract it takes you to the contract "overview" page, where various actions and metadata are shown. Besides that, the full contract source code is also shown - which can be used by devs to check if this contract is what they are looking for (by examining the source code) and to learn about the API and its usage (so for documentation purposes).

I wonder if the overview page could be simplified to show a more high-level overview of the code, instead of dumping the whole source code on the user, which can be pretty hard to digest for more complex contracts.

Suggest A Solution

What about using the Cadence documentation generator tool to automatically generate the contract docs on the fly and showing that on the overview page instead of the full source code?

This would also be aligned with how other package registries do it:

image

image

Instead, we could rename the "components" tab to "Source code" and show the source code (+ the existing list of components) there instead: https://contractbrowser.com/A.1d7e57aa55817448.NonFungibleToken/components

What are you currently working on that this is blocking?

No response

@muttoni
Copy link
Owner

muttoni commented Jun 4, 2024

Love this idea! Will look into this. How do you suggest integrating the doc gen tool? via a server+api or?

@bartolomej
Copy link
Author

@muttoni I think depending on what's easier - we need to have in mind that the Cadence docgen requires a wasm runtime, which is available in the browser out of the box, but would maybe require some additional setup on the server-side (e.g. in Vercel functions).

So I think we have these options (correct me if I'm wrong):

  • trigger docs generation in the API routes and return it to the client app (this maybe requires setting up wasm runtime in Vercel functions)
  • trigger docs generation when doing server-side rendering of the UI (not sure if this is any different from the above option, since I think we could also just request the API route as we are doing server-side rendering, instead of first returning the rendered HTML page to the client and only then calling the docgen API route)
  • trigger docs generation on the client-side (without calling the API route) - I think this would probably be the simplest approach as the wasm runtime is already available in the browser, so we'd just have to ensure the docs rendering component is mounted only once the app is rendered on the client-side and trigger docs generation/rendering at that time

Btw I was also planning to look into this and in general do some contributions to this tool (such as the other ideas I listed in issues), but I'm still a bit too busy for the next couple of weeks! But do let me know if you don't get a chance to look into this or if you need some help!

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

No branches or pull requests

2 participants