diff --git a/README.md b/README.md index 4f326f2..aca2ae7 100644 --- a/README.md +++ b/README.md @@ -119,5 +119,6 @@ See [bin/MARKEDOC-README.md](http://github.com/esl/edown/blob/master/bin/MARKEDO edown_doclet edown_layout edown_lib +edown_make edown_xmerl diff --git a/doc/README.md b/doc/README.md index ce4327e..a5b99be 100644 --- a/doc/README.md +++ b/doc/README.md @@ -119,5 +119,6 @@ See [bin/MARKEDOC-README.md](bin/MARKEDOC-README.md). edown_doclet edown_layout edown_lib +edown_make edown_xmerl diff --git a/doc/edoc-info b/doc/edoc-info index 0794cd3..5af118b 100644 --- a/doc/edoc-info +++ b/doc/edoc-info @@ -1,3 +1,3 @@ {application,edown}. {packages,[]}. -{modules,[edown_doclet,edown_layout,edown_lib,edown_xmerl]}. +{modules,[edown_doclet,edown_layout,edown_lib,edown_make,edown_xmerl]}. diff --git a/doc/edown_doclet.md b/doc/edown_doclet.md index 8d4e208..19acadd 100644 --- a/doc/edown_doclet.md +++ b/doc/edown_doclet.md @@ -31,9 +31,9 @@ __Authors:__ Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erla -
run(Command :: doclet_gen() | doclet_toc(),
-    Ctxt :: edoc_context()) ->
-       ok
+
run(Command::doclet_gen() | doclet_toc(), Ctxt::edoc_context()) -> ok
+

+ @@ -43,8 +43,8 @@ Main doclet entry point. -Also see [`//edoc/edoc:layout/2`](/Users/uwiger/ETC/git/edoc/doc/edoc.md#layout-2) for layout-related options, and -[`//edoc/edoc:get_doc/2`](/Users/uwiger/ETC/git/edoc/doc/edoc.md#get_doc-2) for options related to reading source +Also see [`//edoc/edoc:layout/2`](http://www.erlang.org/doc/man/edoc.html#layout-2) for layout-related options, and +[`//edoc/edoc:get_doc/2`](http://www.erlang.org/doc/man/edoc.html#get_doc-2) for options related to reading source files. Options: @@ -77,7 +77,7 @@ functions will also be included. The default value is false. -
{overview, //edoc/edoc:filename()} +
{overview, //edoc/edoc:filename()}
@@ -117,7 +117,7 @@ specified, no stylesheet reference will be generated. -
{stylesheet_file, //edoc/edoc:filename()} +
{stylesheet_file, //edoc/edoc:filename()}
diff --git a/doc/edown_layout.md b/doc/edown_layout.md index ef94c7b..160336b 100644 --- a/doc/edown_layout.md +++ b/doc/edown_layout.md @@ -118,15 +118,15 @@ the source file. The default value is true. -
Specifies an xmerl callback module to be -used for exporting the documentation. See //xmerl/xmerl:export_simple_content/2 for details. +
Specifies an xmerl callback module to be +used for exporting the documentation. See //xmerl/xmerl:export_simple_content/2 for details.
-__See also:__ [//edoc/edoc:layout/2](/Users/uwiger/ETC/git/edoc/doc/edoc.md#layout-2), [edown_doclet:layout/2](edown_doclet.md#layout-2). +__See also:__ [//edoc/edoc:layout/2](http://www.erlang.org/doc/man/edoc.html#layout-2), [edown_doclet:layout/2](edown_doclet.md#layout-2). ###overview/2## diff --git a/doc/edown_make.md b/doc/edown_make.md new file mode 100644 index 0000000..fb586db --- /dev/null +++ b/doc/edown_make.md @@ -0,0 +1,88 @@ + + +#Module edown_make# +* [Function Index](#index) +* [Function Details](#functions) + + + + + + +##Function Index## + + +
from_script/1Reads ConfigFile and calls edoc:application/3
main/1Escript entry point for building edown (or edoc) documentation.
+ + + + +##Function Details## + + + +###from_script/1## + + + + +
from_script(Config::ConfigFile) -> ok | {error, Reason}
+

+ + + + + + +Reads ConfigFile and calls [`edoc:application/3`](edoc.md#application-3) + + + +The ConfigFile will be read using [`file:script/1`](file.md#script-1), and should return +`{App, Dir, Options}`, as required by [`edoc:application/3`](edoc.md#application-3). + +This function does not manage dependencies. It is simply a wrapper around +[`edoc:application/3`](edoc.md#application-3). + +###main/1## + + + + +
main(Args::[Config]) -> no_return()
+

+ + + + + + +Escript entry point for building edown (or edoc) documentation + + + +Usage: edown_make -config ConfigFile [-pa P] [-pz P] + + + +Calls [from_script(ConfigFile)](#from_script-1) and then terminates, +with a normal or non-normal exit code, depending on the outcome. + + + +Make sure `$EDOWN/edown_make` is runnable, and in the command path, and +that the edown BEAM files are in the Erlang path (e.g. using $ERL_LIBS). +The `edown_make` escript also accepts `-pa P` and/or `-pz P` flags as a +means of locating the edown byte code. + + + +Note, however, that the function `edoc_make:main/1` only expects the +config file as an input argument, corresponding to + + + +`escript edoc_make.beam ConfigFile` + +(The reason for this is that if the beam file can be passed directly to +the escript command, setting the path should also be doable that way). diff --git a/edown_make b/edown_make new file mode 100755 index 0000000..f4100d1 --- /dev/null +++ b/edown_make @@ -0,0 +1,42 @@ +#!/usr/bin/env escript +%% -*- erlang -*- + +%% @spec main() -> no_return() +%% @doc Escript for building edown (or edoc) documentation +%% +%% Usage: edown_make ConfigFile +%% +%% The ConfigFile will be read using {@link file:script/1}, and should return +%% `{App, Dir, Options}', as required by {@link edoc:application/3}. +%% +%% This function does not manage dependencies. It is simply a wrapper around +%% {@link edoc:application/3}. +%% @end +%% +main(Args) -> + Config = parse_args(Args), + edown_make:main([Config]). + +parse_args(Args) -> + parse_args(Args, "edown.config"). + +parse_args([], Config) -> + Config; +parse_args(["-config", Config|Args], _) -> + parse_args(Args, Config); +parse_args(["-pa", P|Args], Config) -> + code:add_patha(P), + parse_args(Args, Config); +parse_args(["-pz", P|Args], Config) -> + code:add_pathz(P), + parse_args(Args, Config); +parse_args(Args, _) -> + io:fwrite("Unknown options: ~p~n", [Args]), + usage(), + halt(1). + +usage() -> + Full = escript:script_name(), + Base = filename:basename(Full), + io:fwrite("~s~nUsage: ~s -config Config [-pa Path] [-pz Path]~n", + [Full, Base]). diff --git a/src/edown_make.erl b/src/edown_make.erl new file mode 100644 index 0000000..5c4e19b --- /dev/null +++ b/src/edown_make.erl @@ -0,0 +1,64 @@ +%% -*- erlang -*- +-module(edown_make). + +-export([from_script/1]). +-export([main/1]). + +%% @spec main(Args::[Config]) -> no_return() +%% @doc Escript entry point for building edown (or edoc) documentation +%% +%% Usage: edown_make -config ConfigFile [-pa P] [-pz P] +%% +%% Calls {@link from_script/1. from_script(ConfigFile)} and then terminates, +%% with a normal or non-normal exit code, depending on the outcome. +%% +%% Make sure `$EDOWN/edown_make' is runnable, and in the command path, and +%% that the edown BEAM files are in the Erlang path (e.g. using $ERL_LIBS). +%% The `edown_make' escript also accepts `-pa P' and/or `-pz P' flags as a +%% means of locating the edown byte code. +%% +%% Note, however, that the function `edoc_make:main/1' only expects the +%% config file as an input argument, corresponding to +%% +%% `escript edoc_make.beam ConfigFile' +%% +%% (The reason for this is that if the beam file can be passed directly to +%% the escript command, setting the path should also be doable that way). +%% +%% @end +%% +main([Config]) -> + case from_script(Config) of + ok -> + halt(); + {error, _} -> + halt(1) + end. + +%% @spec from_script(ConfigFile) -> ok | {error, Reason} +%% @doc Reads ConfigFile and calls {@link edoc:application/3} +%% +%% The ConfigFile will be read using {@link file:script/1}, and should return +%% `{App, Dir, Options}', as required by {@link edoc:application/3}. +%% +%% This function does not manage dependencies. It is simply a wrapper around +%% {@link edoc:application/3}. +%% @end +%% +from_script(Config) -> + case file:script(Config) of + {ok, {App, Dir, Options}} -> + R = edoc:application(App, Dir, Options), + case R of + ok -> + ok; + Err -> + io:fwrite("~p~n", [Err]), + Err + end; + Other -> + io:fwrite("Error reading config ~s:~n" + "~p~n", [Config, Other]), + {error, {config, Other}} + end. +