aboutsummaryrefslogtreecommitdiffstats
path: root/src/asciideck_to_manpage.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-10-31 18:45:31 +0200
committerLoïc Hoguin <[email protected]>2016-10-31 18:45:31 +0200
commitc64ba0a7927e5c7706e3874e3acb7a35558ac526 (patch)
treebbb7224956a8fef818b6c2b32bdc9f43deb1e9b1 /src/asciideck_to_manpage.erl
parente466d925f69eb145b6576be6a2b7603bb8d0f9b4 (diff)
downloadasciideck-c64ba0a7927e5c7706e3874e3acb7a35558ac526.tar.gz
asciideck-c64ba0a7927e5c7706e3874e3acb7a35558ac526.tar.bz2
asciideck-c64ba0a7927e5c7706e3874e3acb7a35558ac526.zip
Make extra man page fields configurable
Diffstat (limited to 'src/asciideck_to_manpage.erl')
-rw-r--r--src/asciideck_to_manpage.erl14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/asciideck_to_manpage.erl b/src/asciideck_to_manpage.erl
index eafd275..47eb932 100644
--- a/src/asciideck_to_manpage.erl
+++ b/src/asciideck_to_manpage.erl
@@ -19,7 +19,7 @@
-export([translate/2]).
translate(AST, Opts) ->
- {Man, Section, Output0} = man(AST),
+ {Man, Section, Output0} = translate_man(AST, Opts),
{CompressExt, Output} = case Opts of
#{compress := gzip} -> {".gz", zlib:gzip(Output0)};
_ -> {"", Output0}
@@ -32,11 +32,11 @@ translate(AST, Opts) ->
Output
end.
-man([{title, #{level := 0}, Title0, _Ann}|AST]) ->
+translate_man([{title, #{level := 0}, Title0, _Ann}|AST], Opts) ->
[Title, << Section:1/binary, _/bits >>] = binary:split(Title0, <<"(">>),
- Extra1 = "2016-10-17", %% @todo
- Extra2 = "Project 1.0", %% @todo
- Extra3 = "Project Function Reference", %% @todo
+ Extra1 = maps:get(extra1, Opts, today()),
+ Extra2 = maps:get(extra2, Opts, ""),
+ Extra3 = maps:get(extra3, Opts, ""),
{Title, Section, [
".TH \"", Title, "\" \"", Section, "\" \"",
Extra1, "\" \"", Extra2, "\" \"", Extra3, "\"\n"
@@ -44,6 +44,10 @@ man([{title, #{level := 0}, Title0, _Ann}|AST]) ->
man(AST, [])
]}.
+today() ->
+ {{Y, M, D}, _} = calendar:universal_time(),
+ io_lib:format("~b-~2.10.0b-~2.10.0b", [Y, M, D]).
+
man([], Acc) ->
lists:reverse(Acc);
man([{title, #{level := 1}, Title, _Ann}|Tail], Acc) ->