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

Add option to force compiler to always generate doc chunks #9404

Open
michalmuskala opened this issue Feb 7, 2025 · 1 comment
Open

Add option to force compiler to always generate doc chunks #9404

michalmuskala opened this issue Feb 7, 2025 · 1 comment
Labels
enhancement team:VM Assigned to OTP team VM

Comments

@michalmuskala
Copy link
Contributor

michalmuskala commented Feb 7, 2025

Is your feature request related to a problem? Please describe.

Using the new documentation system, I noticed a distinct difference in behaviour of the Erlang compiler compared to Elixir. The Elixir compiler, unless explicitly supressed with @moduledoc false, always generates a "stub" doc chunks with the list of functions/macros/types/etc. In contrast, the Erlang compiler doesn't generate anything unless the module has at least one -moduledoc or -doc attributes.
This behaviour is problematic when trying to access the documentation or generate the documentation with ex_doc. The list of exported functions and types, even if without explicit documentation is still a useful artefact. In the limit, where the project is starting to embrace the new documentation system, you end up with no documentation whatsoever - a list of modules and their public functions/types would be useful to have and better than nothing. This was also very frustrating - and meant I spent quite some time trying to understand if the toolchain was broken somewhere that we were ending up with empty documentation.

Describe the solution you'd like

If the current behaviour of the compiler is intentional to avoid "bloat" of .beam files if the new feature is not used, we should at least expose a compiler option that would force the compiler to always generate chunks for modules, unless explicitly suppressed.

Describe alternatives you've considered

The alternative is to do a mass code-mod of the codebase adding some sort of "dummy" -moduledoc "". attribute, but this feels rather silly and counterproductive.

@garazdawi
Copy link
Contributor

The reason it works like that is because when edoc emits doc chunks it does it as .chunk files on disk and EEP-48 specifies that the code should first looks in the beam chunk for docs and then if it does not find it it looks on disk. So in order for edoc chunk files to to be found, the current behaviour is needed (or all applications using edoc need to compile with +no_docs).

Adding a +docs seems reasonable (there already is a +no_docs).

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants