From 87ffff37d0a54e03111643b9587f55006ebd4b96 Mon Sep 17 00:00:00 2001 From: Anatolii Kosorukov Date: Tue, 10 May 2022 18:52:05 +0300 Subject: [PATCH] Mix style documentation Add an option. Documentation generation based on [hex.pm](https://hex.pm/) publishing documentation recomendations using [rebar3_ex_doc](https://hexdocs.pm/rebar3_ex_doc/readme.html) functionality. Fix some typos. Simplify Edoc generation. --- .gitignore | 4 +++- Makefile | 20 +++++++++++-------- README.md | 36 ++++++++++++++++++++++++++-------- {doc_src => doc}/overview.edoc | 0 rebar.config | 21 ++++++++++++++++++-- 5 files changed, 62 insertions(+), 19 deletions(-) rename {doc_src => doc}/overview.edoc (100%) diff --git a/.gitignore b/.gitignore index e183d36..8b51e63 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,9 @@ logs/* rebar3 .rebar3 .rebar -doc +edoc +doc/* +!doc/overview.edoc ## libtool .deps diff --git a/Makefile b/Makefile index e648b62..f99037b 100644 --- a/Makefile +++ b/Makefile @@ -18,14 +18,6 @@ test: $(REBAR) dialyzer: $(REBAR) $(REBAR) as test dialyzer -edoc: - mkdir -p doc && cp -fR doc_src/* doc - $(REBAR) edoc - -edoc_private: - mkdir -p doc && cp -fR doc_src/* doc - $(REBAR) as edoc_private edoc - clean: $(REBAR) $(REBAR) clean @@ -34,3 +26,15 @@ clean: $(REBAR) -eval '{ok, saved_to_file} = httpc:request(get, {"$(REBAR_URL)", []}, [], [{stream, "./rebar3"}])' \ -s inets stop -s init stop chmod +x ./rebar3 + +## +## Doc targets +## +edoc: $(REBAR) + $(REBAR) edoc + +edoc_private: $(REBAR) + $(REBAR) as edoc_private edoc + +exdoc: $(REBAR) + $(REBAR) ex_doc --logo doc/img/logo.png --output edoc \ No newline at end of file diff --git a/README.md b/README.md index 75a7856..8b6c481 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Verify the password: true 4> {ok, Hash} =:= bcrypt:hashpw("bar", Hash). false -```` +``` Configuration ------------- @@ -97,23 +97,22 @@ application's environment: `default_log_rounds` Sets the default number of rounds which define the complexity of the - hash function. Defaults to ``12``. + hash function. Defaults to `12`. `mechanism` Specifies whether to use the NIF implementation (`'nif'`) or a pool of port programs (`'port'`). Defaults to `'nif'`. - `Note: the NIF implementation no longer blocks the Erlang VM - scheduler threads` + `Note: the NIF implementation no longer blocks the Erlang VM scheduler threads` `pool_size` - Specifies the size of the port program pool. Defaults to ``4``. + Specifies the size of the port program pool. Defaults to `4`. `nif_pool_size` - Specifies the size of the nif program pool. Defaults to ``4``. + Specifies the size of the nif program pool. Defaults to `4`. `nif_pool_max_overflow` - Specifies the max workers to overflow of the nif program pool. Defaults to ``10``. + Specifies the max workers to overflow of the nif program pool. Defaults to `10`. Run tests --------- @@ -130,7 +129,7 @@ To test all exported function of a module use: $ ./rebar3 as test shell ===> Verifying dependencies... ===> Compiling bcrypt -make: Nothing to be done for `all'. +make: Nothing to be done for all. Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] Eshell V11.0 (abort with ^G) @@ -157,6 +156,27 @@ OK: Passed 100 test(s). 4> ``` +## Documentation generation + +### Edoc + +#### Generate public API +``` +rebar3 edoc +``` + +#### Generate private API +``` +rebar3 as edoc_private edoc +``` + +### ExDoc + +``` +rebar3 ex_doc --output edoc +``` + + Both the _port_ and the _NIF_ version of bcrypt are tested. All tests should pass. diff --git a/doc_src/overview.edoc b/doc/overview.edoc similarity index 100% rename from doc_src/overview.edoc rename to doc/overview.edoc diff --git a/rebar.config b/rebar.config index ec7f445..6d00b4f 100644 --- a/rebar.config +++ b/rebar.config @@ -32,7 +32,9 @@ no_return ]} ]}, - + {plugins, [ + rebar3_proper + ]}, {deps, [{proper,"1.4.0"}]} ]}, {edoc_private, [ @@ -42,4 +44,19 @@ ]} ]}. -{project_plugins, [rebar3_proper]}. +{project_plugins, [rebar3_hex, rebar3_ex_doc]}. + +{hex, [ + {doc, #{provider => ex_doc}} +]}. + +{ex_doc, [ + {extras, [ + {"README.md", #{title => "Overview"}}, + {"LICENSE", #{title => "License"}} + ]}, + {main, "README.md"}, + {source_url, "https://github.com/erlangpack/bcrypt"}, + {assets, "assets"}, + {api_reference, true} +]}.