-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
OTP27 export moduledoc and doc for module docs and function docs #3010
Comments
Yooo this rules!! Let's do it for sure |
Cool. I may be alone with this but I think that gleam is not just great on itself but is the best way to create beam eco system libraries and this will help a lot <3. |
Hey, I'm pretty interested in this feature (I made a post about it on discord yesterday), and was looking through the code exploring ways that it could potentially be added. I was looking through the code and it looks like the function that generates erlang code is module_document. That takes a TypedModule, which includes a TypedDefinition, which has a TypedExpression, which has the Fn variant, but that variant doesn't carry the documentation info. There is the get_documentation that allows you to get documentation from some of the If that is way off track, do y'all have any ideas about how to go about adding this feature? Module docs would be cool as well, but so far I have only tried looking into the function level docs. |
I don't have any particular thoughts on the implementation, but I expect it to be fairly straightforward given we already use documentation for various things in the compiler. Maybe we should wait until OTP26 is EOL'd before implementing this as it doesn't support these attributes? |
At CodeBEAM someone showed a way to do it while keeping compatibility with lower OTP versions: -if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif. We could add this definition to the top of the generated modules. |
Sneaky! |
This EEP proposes two new attributes: -doc and -moduledoc. They could be used as follows:
See: https://www.erlang.org/eeps/eep-0059#new-module-attributes
Implemented in OTP 27 https://www.erlang.org/news/167#documentation
Maybe
moduledoc false
for@internal
? https://www.erlang.org/eeps/eep-0059#hidden-docsThe text was updated successfully, but these errors were encountered: