Permalink
Browse files

added edown_make script

  • Loading branch information...
1 parent 4d41ead commit b5f16755fc04f6c08e7b9b0208dd71913f39a163 Ulf Wiger committed Oct 3, 2011
Showing with 207 additions and 11 deletions.
  1. +1 −0 README.md
  2. +1 −0 doc/README.md
  3. +1 −1 doc/edoc-info
  4. +7 −7 doc/edown_doclet.md
  5. +3 −3 doc/edown_layout.md
  6. +88 −0 doc/edown_make.md
  7. +42 −0 edown_make
  8. +64 −0 src/edown_make.erl
View
@@ -119,5 +119,6 @@ See [bin/MARKEDOC-README.md](http://github.com/esl/edown/blob/master/bin/MARKEDO
<tr><td><a href="http://github.com/esl/edown/blob/master/doc/edown_doclet.md" class="module">edown_doclet</a></td></tr>
<tr><td><a href="http://github.com/esl/edown/blob/master/doc/edown_layout.md" class="module">edown_layout</a></td></tr>
<tr><td><a href="http://github.com/esl/edown/blob/master/doc/edown_lib.md" class="module">edown_lib</a></td></tr>
+<tr><td><a href="http://github.com/esl/edown/blob/master/doc/edown_make.md" class="module">edown_make</a></td></tr>
<tr><td><a href="http://github.com/esl/edown/blob/master/doc/edown_xmerl.md" class="module">edown_xmerl</a></td></tr></table>
View
@@ -119,5 +119,6 @@ See [bin/MARKEDOC-README.md](bin/MARKEDOC-README.md).
<tr><td><a href="edown_doclet.md" class="module">edown_doclet</a></td></tr>
<tr><td><a href="edown_layout.md" class="module">edown_layout</a></td></tr>
<tr><td><a href="edown_lib.md" class="module">edown_lib</a></td></tr>
+<tr><td><a href="edown_make.md" class="module">edown_make</a></td></tr>
<tr><td><a href="edown_xmerl.md" class="module">edown_xmerl</a></td></tr></table>
View
@@ -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]}.
View
@@ -31,9 +31,9 @@ __Authors:__ Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erla
-<pre>run(Command :: <a href="#type-doclet_gen">doclet_gen()</a> | <a href="#type-doclet_toc">doclet_toc()</a>,
- Ctxt :: <a href="#type-edoc_context">edoc_context()</a>) ->
- ok</pre>
+<pre>run(Command::<a href="#type-doclet_gen">doclet_gen()</a> | <a href="#type-doclet_toc">doclet_toc()</a>, Ctxt::<a href="#type-edoc_context">edoc_context()</a>) -> ok</pre>
+<br></br>
+
@@ -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 <code>false</code>.
-<dt><code>{overview, <a href="/Users/uwiger/ETC/git/edoc/doc/edoc.md#type-filename">//edoc/edoc:filename()</a>}</code>
+<dt><code>{overview, <a href="http://www.erlang.org/doc/man/edoc.html#type-filename">//edoc/edoc:filename()</a>}</code>
</dt>
@@ -117,7 +117,7 @@ specified, no stylesheet reference will be generated.
-<dt><code>{stylesheet_file, <a href="/Users/uwiger/ETC/git/edoc/doc/edoc.md#type-filename">//edoc/edoc:filename()</a>}</code>
+<dt><code>{stylesheet_file, <a href="http://www.erlang.org/doc/man/edoc.html#type-filename">//edoc/edoc:filename()</a>}</code>
</dt>
View
@@ -118,15 +118,15 @@ the source file. The default value is <code>true</code>.
-<dd>Specifies an <a href="/Users/uwiger/ETC/git/xmerl/doc/index.md" target="_top"><code>xmerl</code></a> callback module to be
-used for exporting the documentation. See <a href="/Users/uwiger/ETC/git/xmerl/doc/xmerl.md#export_simple_content-2"><code>//xmerl/xmerl:export_simple_content/2</code></a> for details.
+<dd>Specifies an <a href="http://www.erlang.org/doc/man/index.html" target="_top"><code>xmerl</code></a> callback module to be
+used for exporting the documentation. See <a href="http://www.erlang.org/doc/man/xmerl.html#export_simple_content-2"><code>//xmerl/xmerl:export_simple_content/2</code></a> for details.
</dd>
-__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).<a name="overview-2"></a>
+__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).<a name="overview-2"></a>
###overview/2##
View
@@ -0,0 +1,88 @@
+
+
+#Module edown_make#
+* [Function Index](#index)
+* [Function Details](#functions)
+
+
+
+
+<a name="index"></a>
+
+##Function Index##
+
+
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#from_script-1">from_script/1</a></td><td>Reads ConfigFile and calls <a href="edoc.md#application-3"><code>edoc:application/3</code></a></td></tr><tr><td valign="top"><a href="#main-1">main/1</a></td><td>Escript entry point for building edown (or edoc) documentation.</td></tr></table>
+
+
+<a name="functions"></a>
+
+##Function Details##
+
+<a name="from_script-1"></a>
+
+###from_script/1##
+
+
+
+
+<pre>from_script(Config::ConfigFile) -> ok | {error, Reason}</pre>
+<br></br>
+
+
+
+
+
+
+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).<a name="main-1"></a>
+
+###main/1##
+
+
+
+
+<pre>main(Args::[Config]) -> <a href="#type-no_return">no_return()</a></pre>
+<br></br>
+
+
+
+
+
+
+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).
View
@@ -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]).
View
@@ -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.
+

0 comments on commit b5f1675

Please sign in to comment.