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

Allow doclet and layout modules chaining #22

Merged
merged 2 commits into from
Jun 2, 2022

Conversation

dumbbell
Copy link
Collaborator

@dumbbell dumbbell commented Jun 2, 2022

To implement this plugin, we override the doclet and layout modules with our own. However, a user may want to set his own modules too.

With this patch, the plugin remembers the user-configured modules, if any, and calls them or the default modules, before it patches the output.

This is useful when a user wants to enable doc chunks (EEP-48) to be able to get the API documentation from the Erlang shell or an IDE. For that, he has to set edoc_doclet_chunks and edoc_layout_chunks in the EDoc options. Thanks to this patch, the doc chunks are generated as well as the improved HTML documentation.

dumbbell added 2 commits June 2, 2022 17:54
To implement this plugin, we override the `doclet` and `layout` modules
with our own. However, a user may want to set his own modules too.

With this patch, the plugin remembers the user-configured modules, if
any, and calls them or the default modules, before it patches the
output.

This is useful when a user wants to enable doc chunks (EEP-48) to be
able to get the API documentation from the Erlang shell or an IDE. For
that, he has to set `edoc_doclet_chunks` and `edoc_layout_chunks` in the
EDoc options. Thanks to this patch, the doc chunks are generated as well
as the improved HTML documentation.
We use dynamic calls to chain user-configured `doclet` and `layout`
modules.
@dumbbell dumbbell added the enhancement New feature or request label Jun 2, 2022
@dumbbell dumbbell self-assigned this Jun 2, 2022
@dumbbell dumbbell marked this pull request as ready for review June 2, 2022 16:05
@dumbbell dumbbell merged commit e338751 into main Jun 2, 2022
@dumbbell dumbbell deleted the allow-doclet-and-layout-module-chaining branch June 2, 2022 16:06
@vkatsuba
Copy link
Owner

vkatsuba commented Jun 2, 2022

OTP 24:

===> Fetching rebar3_format v1.2.0
===> Fetching katana_code v2.0.0
===> Analyzing applications...
===> Compiling katana_code
===> Compiling rebar3_format
===> Fetching rebar3_lint v1.1.0
===> Fetching elvis_core v1.4.0
===> Fetching zipper v1.0.1
===> Analyzing applications...
===> Compiling zipper
===> Compiling elvis_core
===> Compiling rebar3_lint
===> Fetching rebar3_edoc_extensions v1.2.0
===> Analyzing applications...
===> Compiling rebar3_edoc_extensions
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_edoc_extensions
===> Downloading GitHub Markdown CSS for rebar3_edoc_extensions
===> Downloading PrismJS (v1.26.0) for rebar3_edoc_extensions
===> Running edoc for rebar3_edoc_extensions
edoc: error in doclet 'rebar3_edoc_extensions_wrapper': {'EXIT',
                                                   {undef,
                                                    [{undefined,run,
                                                      [{doclet_gen,
                                                        [{rebar3_edoc_extensions,
                                                          "rebar3_edoc_extensions.erl",
                                                          "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/src"},
                                                         {rebar3_edoc_extensions_wrapper,
                                                          "rebar3_edoc_extensions_wrapper.erl",
                                                          "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/src"},
                                                         {rebar3_edoc_extensions_prv,
                                                          "rebar3_edoc_extensions_prv.erl",
                                                          "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/src"},
                                                         {rebar3_edoc_extensions_export,
                                                          "rebar3_edoc_extensions_export.erl",
                                                          "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/src"}],
                                                        rebar3_edoc_extensions,
                                                        [rebar3_edoc_extensions,
                                                         rebar3_edoc_extensions_export,
                                                         rebar3_edoc_extensions_prv,
                                                         rebar3_edoc_extensions_wrapper]},
                                                       {doclet_context,
                                                        "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/doc",
                                                        {env,[],[],".html",
                                                         #Fun<edoc_lib.1.43957458>,
                                                         #Fun<edoc_lib.1.43957458>,...},
                                                        [{application,
                                                          rebar3_edoc_extensions},
                                                         {app_default,
                                                          "/home/runner/work/rebar3_edoc_extensions"},
                                                         {application,
                                                          rebar3_edoc_extensions},
                                                         {doclet,...},
                                                         {...}|...]}],
                                                      []},
                                                     {rebar3_edoc_extensions_wrapper,
                                                      run,2,
                                                      [{file,
                                                        "/home/runner/work/rebar3_edoc_extensions/rebar3_edoc_extensions/src/rebar3_edoc_extensions_wrapper.erl"},
                                                       {line,42}]},
                                                     {edoc_lib,run_plugin,5,
                                                      [{file,"edoc_lib.erl"},
                                                       {line,886}]},
                                                     {rebar_prv_edoc,
                                                      '-do/1-fun-0-',6,
                                                      [{file,
                                                        "/home/runner/work/rebar3/rebar3/src/rebar_prv_edoc.erl"},
                                                       {line,52}]},
                                                     {lists,foldl,3,
                                                      [{file,"lists.erl"},
                                                       {line,1267}]},
                                                     {rebar_prv_edoc,do,1,
                                                      [{file,
                                                        "/home/runner/work/rebar3/rebar3/src/rebar_prv_edoc.erl"},
                                                       {line,43}]},
                                                     {rebar_core,do,2,
                                                      [{file,
                                                        "/home/runner/work/rebar3/rebar3/src/rebar_core.erl"},
                                                       {line,155}]},
                                                     {rebar3,run_aux,2,
                                                      [{file,[...]},
                                                       {line,...}]}]}}.
===> Failed to generate documentation for app 'rebar3_edoc_extensions'

@dumbbell
Copy link
Collaborator Author

dumbbell commented Jun 2, 2022

I can't reproduce this issue. How do you run the tests?

@vkatsuba
Copy link
Owner

vkatsuba commented Jun 2, 2022

OTP 24. Run rebar3 edoc.

@dumbbell
Copy link
Collaborator Author

dumbbell commented Jun 2, 2022

That's because of the circular dependency apparently: rebar3_edoc_extensions_prv from a previous version is used, but rebar3_edoc_extensions_wrapper from the local working copy is also used. There are incompatible unfortunately.

@vkatsuba
Copy link
Owner

vkatsuba commented Jun 2, 2022

Hm... then... need to play a little bit... will create a few minor versions

@vkatsuba
Copy link
Owner

vkatsuba commented Jun 2, 2022

And released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants