From 32a2790bea9df75e74cf1b06c8a99e9778347d16 Mon Sep 17 00:00:00 2001 From: Daniel Reverri Date: Sat, 27 Nov 2010 23:10:17 -0800 Subject: [PATCH] Removed sys.conf; erldocs now accepts list of source paths and one destination path --- priv/sys.conf | 15 -------------- src/erldocs.erl | 49 ++++++++++++++++---------------------------- src/erldocs_core.erl | 4 ++-- 3 files changed, 20 insertions(+), 48 deletions(-) delete mode 100644 priv/sys.conf diff --git a/priv/sys.conf b/priv/sys.conf deleted file mode 100644 index e784f3fb..00000000 --- a/priv/sys.conf +++ /dev/null @@ -1,15 +0,0 @@ -%% -*- erlang -*- -[{erldocs, - [ - % generated files will be stored in /priv/www/$name/ - {name, "R14A"}, - - % this is the path to the application directories that the docs will be - % build for, either src/ or doc/ should exist under these dirs, wildcard - % paths are accepted - {apps, - ["/home/dale/lib/otp_src_R13B04/erts/", - "/home/dale/lib/otp_src_R13B04/lib/*/" - ]} - ]} -]. diff --git a/src/erldocs.erl b/src/erldocs.erl index 498d5ea1..6bb30e6a 100644 --- a/src/erldocs.erl +++ b/src/erldocs.erl @@ -3,44 +3,31 @@ %% @doc Called automatically by escript -spec main(list()) -> ok. +main([]) -> + Conf = [{apps, ["."]}, {dest, "doc/erldocs"}], + run(Conf); + +main([Dest]) -> + Conf = [{apps, ["."]}, {dest, Dest}], + run(Conf); + main(Args) -> - Conf = create_conf(Args), + main(Args, []). + +main([Dest], Apps) -> + Conf = [{apps, Apps}, {dest, Dest}], + run(Conf); + +main([App|Rest], Apps) -> + main(Rest, [App|Apps]). + +run(Conf) -> try erldocs_core:dispatch(Conf) catch Type:Error -> log("Error running script:~n~p~n~p~n", [erlang:get_stacktrace(), {Type, Error}]) end. --spec parse_options([string()]) -> [{atom(), _}]. -parse_options(Args) -> - lists:flatmap(fun (Arg) -> parse_option(Arg) end, Args). - --spec parse_option(string()) -> [{atom(), _}]. -parse_option("--sys-conf=" ++ Path) -> - [{sys_conf, Path}]; -parse_option("--name=" ++ Name) -> - [{name, Name}]; -parse_option(Unknown) -> - throw({unknown_option, Unknown}). - --spec getopt(atom(), [{atom(), _}], _) -> _. -getopt(Key, Opts, Default) -> - case lists:keyfind(Key, 1, Opts) of - false -> - Default; - {_, V} -> - V - end. - --spec create_conf([string()]) -> [{atom(), _}]. -create_conf(Args) -> - Opts = parse_options(Args), - Path = getopt(sys_conf, Opts, "priv/sys.conf"), - {ok, [Config]} = file:consult(Path), - {erldocs, Conf} = lists:keyfind(erldocs, 1, Config), - {ok, Root} = file:get_cwd(), - Opts ++ [{root, Root} | Conf]. - -spec log(string(), [_]) -> ok. log(Str, Args) -> io:format(Str, Args). diff --git a/src/erldocs_core.erl b/src/erldocs_core.erl index caab7259..45ad66d0 100644 --- a/src/erldocs_core.erl +++ b/src/erldocs_core.erl @@ -207,7 +207,7 @@ render(erlref, App, Mod, Xml, Conf) -> || X <- lists:reverse(Funs) ], Args = [{base, "../"}, - {title, Mod ++ " (" ++ App ++ ") - " ++ kf(name, Conf)}, + {title, Mod ++ " (" ++ App ++ ") - "}, {content, xml_to_str(NXml)}, {funs, xml_to_str({ul, [{id, "funs"}], XmlFuns})}], @@ -459,7 +459,7 @@ kf(Key, Conf) -> %% @doc path to the destination folder -spec dest(list()) -> list(). dest(Conf) -> - [kf(root, Conf), "/priv/www/", kf(name, Conf), "/"]. + [kf(dest, Conf)]. bname(Name) -> filename:basename(Name).