diff --git a/README.md b/README.md index 3b9a2a5..6c134b5 100644 --- a/README.md +++ b/README.md @@ -95,13 +95,13 @@ The options are passed via a map: % Default: true. enabled => boolean(), false. - % Enable or turn off `-moduledoc` tests. + % Enable or turn off module doc tests. % Default: true. moduledoc => boolean(), - % Enable or turn off function tests or define a list of functions to be tested. + % Enable or turn off functions doc tests or define a list of functions to be tested. % Default: true. - funs => boolean() | [{atom(), arity()}], + doc => boolean() | [{atom(), arity()}], % Set the EUnit options. 'rebar3_config' tries to resolve the options defined in the rebar3. % Default: rebar3_config. @@ -128,7 +128,7 @@ In a module, the `-doctest` attribute is used to override the default settings v ```erlang -doctest {moduledoc, true}. ``` -- `{funs, boolean() | [{atom(), arity()}]}` or `[{atom(), arity()}]`: equivalent to funs option. +- `{doc, boolean() | [{atom(), arity()}]}` or `[{atom(), arity()}]`: equivalent to doc option. ```erlang -doctest [print/0]. ``` @@ -153,7 +153,7 @@ Options can be globally defined via a [config file](https://www.erlang.org/doc/m [{doctest, [ {enabled, true}, {moduledoc, true}, - {funs, true}, + {doc, true}, {eunit_opts, rebar3_config}, {extractors, [doctest_extract_attr, doctest_extract_tag]} ]}]. diff --git a/src/doctest.erl b/src/doctest.erl index 97b8e01..c28478c 100644 --- a/src/doctest.erl +++ b/src/doctest.erl @@ -27,7 +27,7 @@ -type options() :: #{ enabled => boolean(), moduledoc => boolean(), - funs => boolean() | [{atom(), arity()}], + doc => boolean() | [{atom(), arity()}], eunit_opts => rebar3_config | [term()], extractors => [module()] }. @@ -79,8 +79,8 @@ parse_opts(Opts) when is_map(Opts) -> proplists:get_value(enabled, Env, true)), moduledoc => maps:get(moduledoc, Opts, proplists:get_value(moduledoc, Env, true)), - funs => maps:get(funs, Opts, - proplists:get_value(funs, Env, true)), + doc => maps:get(doc, Opts, + proplists:get_value(doc, Env, true)), eunit_opts => maps:get(eunit_opts, Opts, proplists:get_value(eunit_opts, Env, rebar3_config)), extractors => maps:get(extractors, Opts, diff --git a/src/doctest_extract.erl b/src/doctest_extract.erl index 68d3771..02f9056 100644 --- a/src/doctest_extract.erl +++ b/src/doctest_extract.erl @@ -136,13 +136,13 @@ should_test_moduledoc(#{moduledoc := false}) -> should_test_moduledoc(Opts) when not is_map_key(moduledoc, Opts) -> true. -should_test_doc(#{funs := true}, _Fun) -> +should_test_doc(#{doc := true}, _Fun) -> true; -should_test_doc(#{funs := false}, _Fun) -> +should_test_doc(#{doc := false}, _Fun) -> false; -should_test_doc(#{funs := Funs}, Fun) when is_list(Funs) -> +should_test_doc(#{doc := Funs}, Fun) when is_list(Funs) -> lists:member(Fun, Funs); -should_test_doc(Opts, _Fun) when not is_map_key(funs, Opts) -> +should_test_doc(Opts, _Fun) when not is_map_key(doc, Opts) -> true. loc(Doc, Pos) -> diff --git a/src/doctest_transform.erl b/src/doctest_transform.erl index e975a36..eb1e9e3 100644 --- a/src/doctest_transform.erl +++ b/src/doctest_transform.erl @@ -62,15 +62,15 @@ doctest_attrs(Forms) -> parse_opts([Enabled | T], Opts) when is_boolean(Enabled) -> parse_opts(T, Opts#{enabled => Enabled}); parse_opts([Funs | T], Opts) when is_list(Funs) -> - parse_opts(T, Opts#{funs => Funs}); + parse_opts(T, Opts#{doc => Funs}); parse_opts([{enabled, Enabled} | T], Opts) when is_boolean(Enabled) -> parse_opts(T, Opts#{enabled => Enabled}); parse_opts([{moduledoc, Enabled} | T], Opts) when is_boolean(Enabled) -> parse_opts(T, Opts#{moduledoc => Enabled}); -parse_opts([{funs, Enabled} | T], Opts) when is_boolean(Enabled) -> - parse_opts(T, Opts#{funs => Enabled}); -parse_opts([{funs, Funs} | T], Opts) when is_list(Funs) -> - parse_opts(T, Opts#{funs => Funs}); +parse_opts([{doc, Enabled} | T], Opts) when is_boolean(Enabled) -> + parse_opts(T, Opts#{doc => Enabled}); +parse_opts([{doc, Funs} | T], Opts) when is_list(Funs) -> + parse_opts(T, Opts#{doc => Funs}); parse_opts([{eunit_opts, EunitOpts} | T], Opts) -> parse_opts(T, Opts#{eunit_opts => EunitOpts}); parse_opts([{extractors, Extractors} | T], Opts) when is_list(Extractors) ->