From f5ea400361cb157cf7b6f8947ee97a82ba1f260b Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Tue, 19 Apr 2022 20:45:37 +0100 Subject: [PATCH] Modernize doc generation --- Makefile | 7 +++---- rebar.config | 24 ++++++++++++++++-------- support/scripts/generate_docs.config | 4 ---- support/scripts/generate_docs.sh | 23 ----------------------- 4 files changed, 19 insertions(+), 39 deletions(-) delete mode 100644 support/scripts/generate_docs.config delete mode 100755 support/scripts/generate_docs.sh diff --git a/Makefile b/Makefile index 4082e35..efc914f 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ CLI_ARTIFACT_PATH = _build/escriptize/bin/locus .PHONY: all build clean check .PHONY: xref hank-dead-code-cleaner elvis-linter dialyzer .PHONY: test cover -.PHONY: shell console doc publish cli +.PHONY: shell console doc-dry publish cli .NOTPARALLEL: check cover test @@ -61,11 +61,10 @@ shell: console: shell -doc: $(REBAR3) - ./support/scripts/generate_docs.sh +doc-dry: $(REBAR3) + @$(REBAR3) hex publish docs --dry-run publish: $(REBAR3) -publish: doc @$(REBAR3) hex publish cli: $(REBAR3) diff --git a/rebar.config b/rebar.config index 3dd5143..9b51247 100644 --- a/rebar.config +++ b/rebar.config @@ -23,6 +23,7 @@ ]}. {project_plugins, [ + {rebar3_ex_doc, "0.2.8"}, {rebar3_hank, "1.2.2"}, {rebar3_hex, "7.0.1"}, {rebar3_lint, "1.0.1"} @@ -91,14 +92,7 @@ ]}, {cover_enabled, true}, {cover_opts, [verbose]} - ]}, - - {docs, - [{edoc_opts, [{preprocess, true}, - {doclet, edoc_doclet_chunks}, - {layout, edoc_layout_chunks}, - {dir, "_build/default/lib/locus/doc"}]} - ]} + ]} ]}. %% == Hank == @@ -108,3 +102,17 @@ "test/**" ]} ]}. + +%% == ex_doc +++ + +{ex_doc, [ + {source_url, <<"https://github.com/g-andrade/locus">>}, + {extras, [<<"README.md">>, <<"CHANGELOG.md">>, <<"MIGRATION.md">>, <<"LICENSE">>]}, + {main, <<"readme">>}, + {proglang, erlang} +]}. +{hex, [ + {doc, #{ + provider => ex_doc + }} +]}. diff --git a/support/scripts/generate_docs.config b/support/scripts/generate_docs.config deleted file mode 100644 index d5f39fb..0000000 --- a/support/scripts/generate_docs.config +++ /dev/null @@ -1,4 +0,0 @@ -{source_url, <<"https://github.com/g-andrade/locus">>}. -{extras, [<<"README.md">>, <<"CHANGELOG.md">>, <<"MIGRATION.md">>, <<"LICENSE">>]}. -{main, <<"readme">>}. -{proglang, erlang}. diff --git a/support/scripts/generate_docs.sh b/support/scripts/generate_docs.sh deleted file mode 100755 index 744c4a3..0000000 --- a/support/scripts/generate_docs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# Based on: -# * https://github.com/beam-telemetry/telemetry/blob/main/docs.sh - -set -eu - -OTP_VERSION=$(erl -eval 'io:format("~ts", [erlang:system_info(otp_release)]), halt().' -noshell) - -if [[ "$OTP_VERSION" < "24" ]]; then - >&2 echo "Doc generation requires OTP 24+ (found: ${OTP_VERSION})" - exit 1 -fi - -OUR_DIRECTORY=$(dirname $0) -LIB_VERSION=$(git describe --tags) - -rebar3 compile -rebar3 as docs edoc -ex_doc locus "$LIB_VERSION" \ - _build/default/lib/locus/ebin \ - --source-ref "$LIB_VERSION" \ - --config "$OUR_DIRECTORY/generate_docs.config"