-
Notifications
You must be signed in to change notification settings - Fork 524
Adopt ExDoc & Move Documentation In-Tree #2973
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,4 @@ env | |
|
|
||
| # hex_core artifact | ||
| apps/rebar/src/vendored/r3_safe_erl_term.erl | ||
| apps/rebar/doc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| -module(cth_fail_fast). | ||
| -moduledoc false. | ||
|
|
||
| %% Callbacks | ||
| -export([id/1]). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| -module(cth_retry). | ||
| -moduledoc false. | ||
|
|
||
| %% Callbacks | ||
| -export([id/1]). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| %% ./bootstrap | ||
| %% REBAR_CONFIG=doc.config ./rebar3 ex_doc | ||
|
|
||
| {project_plugins, [ | ||
| {rebar3_ex_doc, "0.2.30"}, | ||
| {rebar3_hex, "7.0.11"} | ||
| ]}. | ||
|
|
||
| {hex, [{doc, #{provider => ex_doc}}]}. | ||
| {ex_doc, [ | ||
| {source_url, ~"https://example.com"}, | ||
| {extras, [ | ||
| ~"README.md", | ||
| ~"LICENSE", | ||
| ~"CONTRIBUTING.md" | ||
|
||
| ]}, | ||
| {main, ~"readme"} | ||
| ]}. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| case filelib:is_dir("rebar3.org") of | ||
| true -> | ||
| ok; | ||
| false -> | ||
| erlang:error(""" | ||
| This demo requires that you clone the rebar3.org repository from GitHub | ||
| so that we can bundle the documentation together. | ||
|
|
||
| git clone https://github.com/tsloughter/rebar3.org.git | ||
| """) | ||
| end, | ||
|
|
||
| GetRebar3OrgFiles = fun() -> | ||
| Files = filelib:wildcard("rebar3.org/content/en/docs/**/*.md"), | ||
| lists:filter(fun(X) -> nomatch =:= re:run(X, "_index", [{capture, none}]) end, Files) | ||
| end, | ||
|
|
||
| FixHeader = fun(File) -> | ||
| io:format("Processing ~p~n", [File]), | ||
| {ok, Content} = file:read_file(File), | ||
| NewContent = re:replace(Content, "^---$\n+title: \"(?<title>[^\"]*)\"$.*^---$", "# \\1", [unicode, dotall, anchored, multiline]), | ||
| file:write_file(File, NewContent), | ||
| File | ||
| end, | ||
|
|
||
| MdFiles = GetRebar3OrgFiles(), | ||
| MdFiles = lists:map(FixHeader, MdFiles), | ||
|
|
||
| ExDoc = proplists:get_value(ex_doc, CONFIG), | ||
| Extras = proplists:get_value(extras, ExDoc), | ||
| Extras2 = Extras ++ MdFiles, | ||
| ExDoc2 = lists:keystore(extras, 1, ExDoc, {extras, Extras2}), | ||
| CONFIG2 = lists:keystore(ex_doc, 1, CONFIG, {ex_doc, ExDoc2}), | ||
| CONFIG2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works and I'm not opposed to it. I think this method omits the rest of the Rebar3 config when working on the project, which may drop some settings. Was this on purpose because they might clash?
If it wasn't on purpose, then one option here would have been to use profiles for this whole section within the default
rebar.configfile, and then allow calling./rebar3 as docs ex_doc. This would require unscripting the stuff indoc.config.scriptthough, which would be way too much work for a demo I imagine, but might be worth it in the end if we go for full support.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it with doc.config[.script] on purpose for the first draft to demonstrate the blast radius of the change. Specifically, that the ex_doc config should be expected to have no impact on the rest of the project, to alleviate concerns about circular dependencies. I think we're on the same page here, so this is no longer a goal for the PR. 👍
I can continue the effort by exploring what it looks like in a merged rebar.config and without the script. However, without the script I think this will mean listing all markdown files explicitly in the rebar.config. I'll make it so and we can see how unmanageable that list looks. I don't mind doing multiple iterations to get it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't mind the file being distinct, the main concern is whether we'll require some duplication of config file values at some point. If we can survive without it, that's not a big deal.