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

lang, docs: anchor does not export data structures idiomatically #1206

Closed
paul-schaaf opened this issue Dec 29, 2021 · 3 comments · Fixed by #1208
Closed

lang, docs: anchor does not export data structures idiomatically #1206

paul-schaaf opened this issue Dec 29, 2021 · 3 comments · Fixed by #1208
Labels
documentation Improvements or additions to documentation lang

Comments

@paul-schaaf
Copy link
Contributor

paul-schaaf commented Dec 29, 2021

Example:

Screenshot 2021-12-29 at 12 19 03

  • Anchor prelude paths are included in docs.rs. They should not be included because prelude is just a helper module (that is what the rust std docs do at least).
  • Account is exported directly under the root. It should be exported with its proper path (anchor_lang::accounts::account::Account).

Account is just one example of many. For Account (and the other types in the accounts folder) it can be solved by removing the Account export in lib.rs, making the accounts mod in lib.rs a pub mod and exporting accounts::account::Account in the prelude instead of just Account. Doing it this way makes Account a re-export instead of a struct inside prelude.

I dont think doc(hidden) on the prelude mod is the solution because if you search for it, you should find it, but its members shouldnt show up in the search because theyre just re-exports (or they should be re-exports, but arent right now, which is causing these problems)

@paul-schaaf paul-schaaf added documentation Improvements or additions to documentation lang labels Dec 29, 2021
@paul-schaaf
Copy link
Contributor Author

paul-schaaf commented Dec 29, 2021

open question: how to deal with crates like anchor_attribute_account. These are also currently not re-exported by anchor and can therefore be found in the docs in the prelude module, but not anywhere else. If the prelude just re-exported these, they could not be found in the docs of anchor_lang at all. So maybe it makes sense to leave these as they are or move them into a new module inside anchor_lang from which the prelude re-exports them (so we dont have prelude paths in the docs)

@armaniferrante
Copy link
Member

Note that crates like anchor_attribute_account must be in their own crate (or shared within a still separate crate) because they are proc macros.

@paul-schaaf
Copy link
Contributor Author

yes. I didnt mean that we should actually move them into anchor_lang.

prelude currently pub uses them but this does not re-export them (any idea why?). instead it defines them as members of prelude. my idea is to have a separate module pub use them. that way, they can be found in the docs via that module because it wont reexport them either. but I havent managed to reexport them from that module by the prelude yet. it still defines them as members of prelude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation lang
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants