summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorUlf Wiger <ulf@feuerlabs.com>2015-11-27 08:57:13 -0800
committerUlf Wiger <ulf@feuerlabs.com>2015-11-27 08:57:13 -0800
commit60b9bd3c233233dfd1709f8b753e233adaf38423 (patch)
treee737ea09bdf20215c69dc6bb2f69b85ce38876d4 /deps
parente667c4a9565fb09c97457396462eb54b98aceb45 (diff)
downloadrvi_core-60b9bd3c233233dfd1709f8b753e233adaf38423.tar.gz
upgrade edown for OTP 18.1
Diffstat (limited to 'deps')
-rw-r--r--deps/edown/README.md22
-rw-r--r--deps/edown/doc/README.md22
-rw-r--r--deps/edown/doc/edoc-info1
-rw-r--r--deps/edown/doc/edown_doclet.md10
-rw-r--r--deps/edown/doc/edown_layout.md13
-rw-r--r--deps/edown/doc/edown_lib.md14
-rw-r--r--deps/edown/doc/edown_make.md20
-rw-r--r--deps/edown/doc/edown_xmerl.md5
-rw-r--r--deps/edown/doc/overview.edoc8
-rw-r--r--deps/edown/src/edown_doclet.erl198
-rw-r--r--deps/edown/src/edown_layout.erl48
-rw-r--r--deps/edown/src/edown_lib.erl10
-rw-r--r--deps/edown/src/edown_xmerl.erl32
13 files changed, 154 insertions, 249 deletions
diff --git a/deps/edown/README.md b/deps/edown/README.md
index df8e8ec..73f628b 100644
--- a/deps/edown/README.md
+++ b/deps/edown/README.md
@@ -4,10 +4,8 @@
Copyright (c) 2014 Ulf Wiger
-
__Authors:__ [`ulf@wiger.net`](mailto:ulf@wiger.net).
-
Status:
------
More-or-less readable Markdown can be generated.
@@ -51,11 +49,11 @@ It is also possible to add the branch information specifically:
`{top_level_readme, {File, BaseHref, Branch}}`, although this shouldn't be
necessary as long as edown can derive the branch name from git.
-Using Atlassian Stash as target
--------------------------------
+Using Atlassian Stash or Gitlab as target
+-----------------------------------------
-The option `{edown_target, github | stash}` can be used to control which
-is the intended host repository. This affects how links are rewritten in
+The option `{edown_target, github | stash | gitlab}` can be used to control
+which is the intended host repository. This affects how links are rewritten in
order to find related files and stay on the correct branch.
The default value is `github`.
@@ -63,6 +61,7 @@ The default value is `github`.
Note that at the moment, the
[Markdown viewer plugin](https://bitbucket.org/atlassianlabs/stash-markdown-viewer-plugin) will be needed in order to render the generated documentation
as Markdown on Stash.
+
Github customizations
=====================
`pre` tags are converted into github "fenced" code blocks, i.e.
@@ -167,14 +166,3 @@ See [bin/MARKEDOC-README.md](http://github.com/uwiger/edown/blob/master/bin/MARK
**Linux**`$ sed -r -f markedoc.sed <markdown file> > <edoc file>`
-
-## Modules ##
-
-
-<table width="100%" border="0" summary="list of modules">
-<tr><td><a href="http://github.com/uwiger/edown/blob/master/doc/edown_doclet.md" class="module">edown_doclet</a></td></tr>
-<tr><td><a href="http://github.com/uwiger/edown/blob/master/doc/edown_layout.md" class="module">edown_layout</a></td></tr>
-<tr><td><a href="http://github.com/uwiger/edown/blob/master/doc/edown_lib.md" class="module">edown_lib</a></td></tr>
-<tr><td><a href="http://github.com/uwiger/edown/blob/master/doc/edown_make.md" class="module">edown_make</a></td></tr>
-<tr><td><a href="http://github.com/uwiger/edown/blob/master/doc/edown_xmerl.md" class="module">edown_xmerl</a></td></tr></table>
-
diff --git a/deps/edown/doc/README.md b/deps/edown/doc/README.md
index 37dba3f..7a5f296 100644
--- a/deps/edown/doc/README.md
+++ b/deps/edown/doc/README.md
@@ -4,10 +4,8 @@
Copyright (c) 2014 Ulf Wiger
-
__Authors:__ [`ulf@wiger.net`](mailto:ulf@wiger.net).
-
Status:
------
More-or-less readable Markdown can be generated.
@@ -51,11 +49,11 @@ It is also possible to add the branch information specifically:
`{top_level_readme, {File, BaseHref, Branch}}`, although this shouldn't be
necessary as long as edown can derive the branch name from git.
-Using Atlassian Stash as target
--------------------------------
+Using Atlassian Stash or Gitlab as target
+-----------------------------------------
-The option `{edown_target, github | stash}` can be used to control which
-is the intended host repository. This affects how links are rewritten in
+The option `{edown_target, github | stash | gitlab}` can be used to control
+which is the intended host repository. This affects how links are rewritten in
order to find related files and stay on the correct branch.
The default value is `github`.
@@ -63,6 +61,7 @@ The default value is `github`.
Note that at the moment, the
[Markdown viewer plugin](https://bitbucket.org/atlassianlabs/stash-markdown-viewer-plugin) will be needed in order to render the generated documentation
as Markdown on Stash.
+
Github customizations
=====================
`pre` tags are converted into github "fenced" code blocks, i.e.
@@ -167,14 +166,3 @@ See [bin/MARKEDOC-README.md](bin/MARKEDOC-README.md).
**Linux**`$ sed -r -f markedoc.sed <markdown file> > <edoc file>`
-
-## Modules ##
-
-
-<table width="100%" border="0" summary="list of modules">
-<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>
-
diff --git a/deps/edown/doc/edoc-info b/deps/edown/doc/edoc-info
index 87b2449..14075fb 100644
--- a/deps/edown/doc/edoc-info
+++ b/deps/edown/doc/edoc-info
@@ -1,4 +1,3 @@
%% encoding: UTF-8
{application,edown}.
-{packages,[]}.
{modules,[edown_doclet,edown_layout,edown_lib,edown_make,edown_xmerl]}.
diff --git a/deps/edown/doc/edown_doclet.md b/deps/edown/doc/edown_doclet.md
index fcf0178..c8af959 100644
--- a/deps/edown/doc/edown_doclet.md
+++ b/deps/edown/doc/edown_doclet.md
@@ -5,11 +5,12 @@
* [Function Index](#index)
* [Function Details](#functions)
-
EDoc Doclet module for producing Markdown.
-Copyright (c) 2014 Ulf Wiger
+
+Copyright (c) 2014-2015 Ulf Wiger
__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
+
<a name="index"></a>
## Function Index ##
@@ -26,22 +27,17 @@ __Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
### run/2 ###
-
<pre><code>
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>) -&gt; ok
</code></pre>
<br />
-
Main doclet entry point.
-
-
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:
diff --git a/deps/edown/doc/edown_layout.md b/deps/edown/doc/edown_layout.md
index 10c00c1..109b8a9 100644
--- a/deps/edown/doc/edown_layout.md
+++ b/deps/edown/doc/edown_layout.md
@@ -5,15 +5,16 @@
* [Function Index](#index)
* [Function Details](#functions)
-
Markdown layout module for EDoc.
+
Copyright (c) 2014 Ulf Wiger
__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
+
<a name="description"></a>
## Description ##
- Derived from `edoc_layout`, which is part of the Erlang/OTP application EDoc.
+Derived from `edoc_layout`, which is part of the Erlang/OTP application EDoc.
The module is intended to be used together with edoc.<a name="index"></a>
## Function Index ##
@@ -32,17 +33,14 @@ The module is intended to be used together with edoc.<a name="index"></a>
`markdown(Title, CSS, Body) -> any()`
-
<a name="module-2"></a>
### module/2 ###
`module(Element, Options) -> any()`
-
The layout function.
-
Options to the standard layout:
@@ -116,26 +114,23 @@ used for exporting the documentation. See <a href="http://www.erlang.org/doc/man
-
__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 ###
`overview(E, Options) -> any()`
-
<a name="package-2"></a>
### package/2 ###
`package(E, Options) -> any()`
-
<a name="type-1"></a>
### type/1 ###
`type(E) -> any()`
-
diff --git a/deps/edown/doc/edown_lib.md b/deps/edown/doc/edown_lib.md
index 4db33d3..c999693 100644
--- a/deps/edown/doc/edown_lib.md
+++ b/deps/edown/doc/edown_lib.md
@@ -5,29 +5,29 @@
* [Function Index](#index)
* [Function Details](#functions)
-
Markdown for EDoc - common support functions.
+
Copyright (c) 2014 Ulf Wiger
__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
+
<a name="index"></a>
## Function Index ##
-<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#export-1">export/1</a></td><td></td></tr><tr><td valign="top"><a href="#get_attrval-2">get_attrval/2</a></td><td></td></tr><tr><td valign="top"><a href="#redirect_uri-1">redirect_uri/1</a></td><td></td></tr></table>
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#export-2">export/2</a></td><td></td></tr><tr><td valign="top"><a href="#get_attrval-2">get_attrval/2</a></td><td></td></tr><tr><td valign="top"><a href="#redirect_uri-1">redirect_uri/1</a></td><td></td></tr></table>
<a name="functions"></a>
## Function Details ##
-<a name="export-1"></a>
+<a name="export-2"></a>
-### export/1 ###
-
-`export(Data) -> any()`
+### export/2 ###
+`export(Data, Options) -> any()`
<a name="get_attrval-2"></a>
@@ -35,11 +35,9 @@ __Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
`get_attrval(Name, XmlElement) -> any()`
-
<a name="redirect_uri-1"></a>
### redirect_uri/1 ###
`redirect_uri(XmlElement) -> any()`
-
diff --git a/deps/edown/doc/edown_make.md b/deps/edown/doc/edown_make.md
index 09f30f4..f460863 100644
--- a/deps/edown/doc/edown_make.md
+++ b/deps/edown/doc/edown_make.md
@@ -4,7 +4,6 @@
* [Function Index](#index)
* [Function Details](#functions)
-
<a name="index"></a>
## Function Index ##
@@ -21,62 +20,45 @@
### from_script/1 ###
-
<pre><code>
from_script(Config::ConfigFile) -&gt; ok | {error, Reason}
</code></pre>
<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><code>
main(Args::[Config]) -&gt; no_return()
</code></pre>
<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).
diff --git a/deps/edown/doc/edown_xmerl.md b/deps/edown/doc/edown_xmerl.md
index 1ad3f3b..5628164 100644
--- a/deps/edown/doc/edown_xmerl.md
+++ b/deps/edown/doc/edown_xmerl.md
@@ -7,6 +7,7 @@
Copyright (c) 2014 Ulf Wiger
__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
+
<a name="index"></a>
## Function Index ##
@@ -25,25 +26,21 @@ __Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
`#element#(Tag, Data, Attrs, Parents, E) -> any()`
-
<a name="%23root%23-4"></a>
### '#root#'/4 ###
`#root#(Data, Attrs, X3, E) -> any()`
-
<a name="%23text%23-1"></a>
### '#text#'/1 ###
`#text#(Text) -> any()`
-
<a name="%23xml-inheritance%23-0"></a>
### '#xml-inheritance#'/0 ###
`#xml-inheritance#() -> any()`
-
diff --git a/deps/edown/doc/overview.edoc b/deps/edown/doc/overview.edoc
index 5542cc5..4588efa 100644
--- a/deps/edown/doc/overview.edoc
+++ b/deps/edown/doc/overview.edoc
@@ -45,11 +45,11 @@ It is also possible to add the branch information specifically:
`{top_level_readme, {File, BaseHref, Branch}}', although this shouldn't be
necessary as long as edown can derive the branch name from git.
-Using Atlassian Stash as target
--------------------------------
+Using Atlassian Stash or Gitlab as target
+-----------------------------------------
-The option `{edown_target, github | stash}' can be used to control which
-is the intended host repository. This affects how links are rewritten in
+The option `{edown_target, github | stash | gitlab}' can be used to control
+which is the intended host repository. This affects how links are rewritten in
order to find related files and stay on the correct branch.
The default value is `github'.
diff --git a/deps/edown/src/edown_doclet.erl b/deps/edown/src/edown_doclet.erl
index cc3bc92..762d342 100644
--- a/deps/edown/src/edown_doclet.erl
+++ b/deps/edown/src/edown_doclet.erl
@@ -14,7 +14,7 @@
%% limitations under the License.
%%==============================================================================
%% @author Ulf Wiger <ulf@wiger.net>
-%% @copyright 2014 Ulf Wiger
+%% @copyright 2014-2015 Ulf Wiger
%% @end
%% =============================================================================
%% Modified 2012 by Beads Land-Trujillo: get_git_branch/0, redirect_href/3
@@ -22,7 +22,6 @@
%% @doc EDoc Doclet module for producing Markdown.
-
-module(edown_doclet).
-export([run/2]).
@@ -35,21 +34,17 @@
-define(DEFAULT_FILE_SUFFIX, ".md").
-define(INDEX_FILE, "README.md").
-define(OVERVIEW_FILE, "overview.edoc").
--define(PACKAGE_SUMMARY, "package-summary.md").
-define(OVERVIEW_SUMMARY, "overview-summary.md").
--define(PACKAGES_FRAME, "packages-frame.md").
--define(MODULES_FRAME, "modules-frame.md").
-define(STYLESHEET, "stylesheet.css").
-define(IMAGE, "erlang.png").
-define(NL, "\n").
-include_lib("xmerl/include/xmerl.hrl").
-%% Sources is the list of inputs in the order they were found. Packages
-%% and Modules are sorted lists of atoms without duplicates. (They
+%% Sources is the list of inputs in the order they were found.
+%% Modules are sorted lists of atoms without duplicates. (They
%% usually include the data from the edoc-info file in the target
-%% directory, if it exists.) Note that the "empty package" is never
-%% included in Packages!
+%% directory, if it exists.)
%% @spec (Command::doclet_gen() | doclet_toc(), edoc_context()) -> ok
%% @doc Main doclet entry point.
@@ -106,21 +101,14 @@
%% INHERIT-OPTIONS: stylesheet/1
run(#doclet_gen{}=Cmd, Ctxt) ->
- %% dbg:tracer(),
- %% dbg:tpl(?MODULE,x),
- %% dbg:tpl(edown_layout,x),
- %% dbg:tpl(edown_xmerl, x),
- %% dbg:p(all,[c]),
gen(Cmd#doclet_gen.sources,
Cmd#doclet_gen.app,
- Cmd#doclet_gen.packages,
- Cmd#doclet_gen.modules,
- Cmd#doclet_gen.filemap,
+ modules(Cmd),
Ctxt);
run(#doclet_toc{}=Cmd, Ctxt) ->
toc(Cmd#doclet_toc.paths, Ctxt).
-gen(Sources, App, Packages, Modules, FileMap, Ctxt) ->
+gen(Sources, App, Modules, Ctxt) ->
Dir = Ctxt#context.dir,
Env = Ctxt#context.env,
Options0 = Ctxt#context.opts,
@@ -131,16 +119,11 @@ gen(Sources, App, Packages, Modules, FileMap, Ctxt) ->
Title = title(App, Options),
%% CSS = stylesheet(Options),
{Modules1, Error} = sources(Sources, Dir, Modules, Env, Options),
- packages(Packages, Dir, FileMap, Env, Options),
- Overview = overview(Dir, Title, Env, Options),
- Data =
- Overview
- ++ lists:concat([packages_frame(Packages) || Packages =/= []])
- ++ lists:concat([modules_frame(Modules1) || Modules1 =/= []]),
-
- Text = xmerl:export_simple_content(Data, edown_xmerl),
- write_file(Text, Dir, right_suffix(?INDEX_FILE, Options), '', ''),
- edoc_lib:write_info_file(App, Packages, Modules1, Dir),
+ Data = overview(Dir, Title, Env, Options)
+ ++ lists:concat([modules_frame(Modules1) || Modules1 =/= []]),
+ Text = edown_lib:export(Data, Options),
+ write_file(Text, Dir, right_suffix(?INDEX_FILE, Options)),
+ write_info_file(App, Modules1, Dir),
copy_stylesheet(Dir, Options),
copy_image(Dir, Options),
make_top_level_README(Data, Options),
@@ -171,12 +154,11 @@ make_top_level_README(Data, Options) ->
Dir = filename:dirname(Path),
Filename = filename:basename(Path),
make_top_level_README(Data, Dir, Filename, BaseHRef,
- get_git_branch(), target(Options));
+ get_git_branch(), Options);
{Path, BaseHRef, Branch} ->
Dir = filename:dirname(Path),
Filename = filename:basename(Path),
- make_top_level_README(Data, Dir, Filename, BaseHRef, Branch,
- target(Options))
+ make_top_level_README(Data, Dir, Filename, BaseHRef, Branch, Options)
end.
target(Options) ->
@@ -186,7 +168,8 @@ target(Options) ->
%% Branch = get_git_branch(),
%% make_top_level_README(Data, Dir, F, BaseHRef, Branch).
-make_top_level_README(Data, Dir, F, BaseHRef, Branch, Target) ->
+make_top_level_README(Data, Dir, F, BaseHRef, Branch, Options) ->
+ Target = target(Options),
Exp = [xmerl_lib:expand_element(D) || D <- Data],
New = [xmerl_lib:mapxml(
fun(#xmlElement{name = a,
@@ -200,7 +183,7 @@ make_top_level_README(Data, Dir, F, BaseHRef, Branch, Target) ->
(Other) ->
Other
end, Exp1) || Exp1 <- Exp],
- Text = xmerl:export_simple_content(New, edown_xmerl),
+ Text = edown_lib:export(New, Options),
write_file(Text, Dir, F).
redirect_href(Attrs, Branch, BaseHRef, Target) ->
@@ -211,7 +194,7 @@ redirect_href(Attrs, Branch, BaseHRef, Target) ->
#xmlAttribute{value = "/" ++ _} ->
false;
#xmlAttribute{value = Href} = A ->
- case re:run(Href, ":", []) of
+ case re:run(Href, ":", [unicode]) of
{match, _} ->
false;
nomatch ->
@@ -232,7 +215,9 @@ redirect_href(Attrs, Branch, BaseHRef, Target) ->
href_redirect_parts(github, BaseHRef, Branch) ->
{BaseHRef ++ "/blob/" ++ Branch ++ "/", []};
href_redirect_parts(stash, BaseHRef, Branch) ->
- {BaseHRef ++ "/browse/", "?at=refs/heads/" ++ Branch}.
+ {BaseHRef ++ "/browse/", "?at=refs/heads/" ++ Branch};
+href_redirect_parts(gitlab, BaseHRef, Branch) ->
+ {BaseHRef ++ "/tree/" ++ Branch ++ "/", []}.
do_redirect(Href, Prefix, Args) ->
@@ -295,19 +280,24 @@ sources(Sources, Dir, Modules, Env, Options) ->
%% set if it was successful. Errors are just flagged at this stage,
%% allowing all source files to be processed even if some of them fail.
-source({M, P, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden,
+source({M, _, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden,
+ Error, Options) ->
+ %% Old style, remove package reference
+ source({M, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden,
+ Error, Options);
+source({M, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden,
Error, Options) ->
File = filename:join(Path, Name),
Enc = guess_encoding(File),
case catch {ok, edoc:get_doc(File, Env, Options)} of
{ok, {Module, Doc}} ->
- check_name(Module, M, P, File),
+ check_name(Module, M, File),
case ((not is_private(Doc)) orelse Private)
andalso ((not is_hidden(Doc)) orelse Hidden) of
true ->
Text = edoc:layout(Doc, Options),
- Name1 = packages_last(M) ++ Suffix,
- write_file(Text, Dir, Name1, Name, P, Enc),
+ Name1 = atom_to_list(M) ++ Suffix,
+ write_file(Text, Dir, Name1, Name, Enc),
{sets:add_element(Module, Set), Error};
false ->
{Set, Error}
@@ -327,22 +317,27 @@ guess_encoding(File) ->
end.
write_file(Text, Dir, F) ->
- write_file(Text, Dir, F, F, '', auto).
-
-write_file(Text, Dir, Name, P) ->
- write_file(Text, Dir, Name, Name, P, auto).
+ write_file(Text, Dir, F, F, auto).
-write_file(Text, Dir, LastName, Name, P) ->
- write_file(Text, Dir, LastName, Name, P, auto).
-
-write_file(Text, Dir, LastName, Name, P, Enc) ->
+write_file(Text, Dir, LastName, Name, Enc) ->
%% edoc_lib:write_file/5 (with encoding support) was added in OTP R16B
+ %% -- and removed in 18.0; we reuse the check to detect 18, since we don't
+ %% -- care about pre-R16
case lists:member({write_file,5}, edoc_lib:module_info(exports)) of
true ->
- edoc_lib:write_file(Text, Dir, LastName, P,
+ edoc_lib:write_file(Text, Dir, LastName, '',
[{encoding, encoding(Enc, Name)}]);
false ->
- edoc_lib:write_file(Text, Dir, LastName, P)
+ edoc_lib:write_file(Text, Dir, LastName,
+ [{encoding, encoding(Enc, Name)}])
+ end.
+
+write_info_file(App, Modules, Dir) ->
+ case erlang:function_exported(edoc_lib, write_info_file, 4) of
+ true ->
+ edoc_lib:write_info_file(App, [], Modules, Dir);
+ false ->
+ edoc_lib:write_info_file(App, Modules, Dir)
end.
encoding(auto, Name) ->
@@ -351,25 +346,9 @@ encoding(Enc, _) ->
Enc.
-check_name(M, M0, P0, File) ->
- case erlang:function_exported(packages, strip_last, 1) of
- true ->
- check_name_(M, M0, P0, File);
- false ->
- ok
- end.
-
-%% If running pre-R16B OTP, where packages are still "supported".
-packages_last(M) ->
- case erlang:function_exported(packages, last, 1) of
- true -> packages:last(M);
- false -> atom_to_list(M)
- end.
-
-check_name_(M, M0, P0, File) ->
- P = list_to_atom(packages:strip_last(M)),
- N = packages:last(M),
- N0 = packages:last(M0),
+check_name(M, M0, File) ->
+ N = M,
+ N0 = M0,
case N of
[$? | _] ->
%% A module name of the form '?...' is assumed to be caused
@@ -383,84 +362,24 @@ check_name_(M, M0, P0, File) ->
true ->
ok
end
- end,
- if P =/= P0 ->
- warning("file '~s' belongs to package '~s', not '~s'.",
- [File, P, P0]);
- true ->
- ok
end.
-
-%% Generating the summary files for packages.
-
-%% INHERIT-OPTIONS: read_file/4
-%% INHERIT-OPTIONS: edoc_lib:run_layout/2
-
-packages(Packages, Dir, FileMap, Env, Options) ->
- lists:foreach(fun (P) ->
- package(P, Dir, FileMap, Env, Options)
- end,
- Packages).
-
-package(P, Dir, FileMap, Env, Opts) ->
- Tags = case FileMap(P) of
- "" ->
- [];
- File ->
- read_file(File, package, Env, Opts)
- end,
- Data = edoc_data:package(P, Tags, Env, Opts),
- F = fun (M) ->
- M:package(Data, Opts)
- end,
- Text = edoc_lib:run_layout(F, Opts),
- write_file(Text, Dir, ?PACKAGE_SUMMARY, P).
-
-
-
-packages_frame(Ps) ->
- [{h2, [{class, "indextitle"}], ["Packages"]},
- {table, [{width, "100%"}, {border, 0},
- {summary, "list of packages"}],
- lists:concat(
- [[{tr, [{td, [], [{a, [{href, package_ref(P)},
- {class, "package"}],
- [atom_to_list(P)]}]}]}]
- || P <- Ps])}].
-
-
modules_frame(Ms) ->
[{h2, [{class, "indextitle"}], ["Modules"]},
{table, [{width, "100%"}, {border, 0},
- {summary, "list of modules"}],
+ {summary, "list of modules"}],
lists:concat(
- [[?NL,
- {tr, [{td, [],
- [{a, [{href, module_ref(M)},
- {class, "module"}],
- [atom_to_list(M)]}]}]}]
- || M <- Ms])}].
+ [[?NL,
+ {tr, [{td, [],
+ [{a, [{href, module_ref(M)},
+ {class, "module"}],
+ [atom_to_list(M)]}]}]}]
+ || M <- Ms])}].
module_ref(M) ->
- edoc_refs:relative_package_path(M, '') ++ ?DEFAULT_FILE_SUFFIX.
-
-package_ref(P) ->
- edoc_lib:join_uri(edoc_refs:relative_package_path(P, ''),
- ?PACKAGE_SUMMARY).
+ atom_to_list(M) ++ ?DEFAULT_FILE_SUFFIX.
-%% xhtml(Title, CSS, Content) ->
-%% xhtml_1(Title, CSS, {body, [{bgcolor, "white"}], Content}).
-
-%% xhtml_1(Title, CSS, Body) ->
-%% {html, [?NL,
-%% {head, [?NL, {title, [Title]}, ?NL] ++ CSS},
-%% ?NL,
-%% Body,
-%% ?NL]
-%% }.
-
%% NEW-OPTIONS: overview
%% INHERIT-OPTIONS: read_file/4
%% INHERIT-OPTIONS: edoc_lib:run_layout/2
@@ -476,8 +395,6 @@ overview(Dir, Title, Env, Opts) ->
M:overview(Data, Opts)
end,
_Markdown = edoc_lib:run_layout(F, Opts).
- %% edoc_lib:write_file(Text, Dir, ?OVERVIEW_SUMMARY).
-
copy_image(Dir, Options) ->
case proplists:get_value(image, Options) of
@@ -599,3 +516,8 @@ toc(_Paths, _Ctxt) ->
%% Dir = Ctxt#context.dir,
%% Env = Ctxt#context.env,
%% app_index_file(Paths, Dir, Env, Opts).
+
+modules({doclet_gen,_,_,_,Ms,_}) -> % pre-18
+ Ms;
+modules({doclet_gen,_,_,Ms}) -> % since 18
+ Ms.
diff --git a/deps/edown/src/edown_layout.erl b/deps/edown/src/edown_layout.erl
index 84f7246..5dfcd56 100644
--- a/deps/edown/src/edown_layout.erl
+++ b/deps/edown/src/edown_layout.erl
@@ -90,9 +90,7 @@
module(Element, Options) ->
XML = layout_module(Element, init_opts(Element, Options)),
- Export = proplists:get_value(xml_export, Options,
- ?DEFAULT_XML_EXPORT),
- xmerl:export_simple(XML, Export, []).
+ edown_lib:export(XML, Options).
% Put layout options in a data structure for easier access.
@@ -185,9 +183,7 @@ layout_module(#xmlElement{name = module, content = Es}=E, Opts) ->
Body = ([] % navigation("top")
++ [{h1, Title}]
++ doc_index(FullDesc, Functions, Types)
- ++ [{p,[]}]
- ++ ShortDesc
- ++ [{p,[]}]
+ ++ [{p, ShortDesc}]
++ copyright(Es)
++ deprecated(Es, "module")
++ version(Es)
@@ -219,8 +215,7 @@ layout_module(#xmlElement{name = module, content = Es}=E, Opts) ->
%% io:fwrite("not edown_doclet (~p)~n", [Name])
%% end,
%% xhtml(Title, stylesheet(Opts), Body).
- Res = to_simple(markdown(Title, stylesheet(Opts), Body)),
- Res.
+ to_simple(markdown(Title, stylesheet(Opts), Body)).
%% This function is a workaround for a bug in xmerl_lib:expand_content/1 that
%% causes it to lose track of the parents if #xmlElement{} records are
@@ -905,7 +900,9 @@ t_type([E = #xmlElement{name = record, content = Es}]) ->
t_type([E = #xmlElement{name = abstype, content = Es}]) ->
t_abstype(E, Es);
t_type([#xmlElement{name = union, content = Es}]) ->
- t_union(Es).
+ t_union(Es);
+t_type([#xmlElement{name = type} = K, #xmlElement{name = type} = V]) ->
+ t_map_field([K,V]).
t_var(E) ->
[get_attrval(name, E)].
@@ -1061,8 +1058,7 @@ type(E) ->
type(E, Ds) ->
Opts = [],
- xmerl:export_simple_content(t_utype_elem(E) ++ local_defs(Ds, Opts),
- ?HTML_EXPORT).
+ edown_lib:export(t_utype_elem(E) ++ local_defs(Ds, Opts), Opts).
package(E=#xmlElement{name = package, content = Es}, Options) ->
Opts = init_opts(E, Options),
@@ -1084,7 +1080,7 @@ package(E=#xmlElement{name = package, content = Es}, Options) ->
++ FullDesc),
%% XML = xhtml(Title, stylesheet(Opts), Body),
XML = markdown(Title, stylesheet(Opts), Body),
- xmerl:export_simple_content(XML, ?HTML_EXPORT).
+ edown_lib:export(XML, Options).
overview(E=#xmlElement{name = overview, content = Es}, Options) ->
Opts = init_opts(E, Options),
@@ -1266,9 +1262,10 @@ ot_name([E]) ->
get_first_sentence([#xmlElement{name = p, content = Es} | Tail]) ->
%% Descend into initial paragraph.
+ Tail1 = drop_empty_lines(Tail),
{First, Rest} = get_first_sentence_1(Es),
{First,
- [#xmlElement{name = p, content = Rest} || Rest =/= []] ++ Tail};
+ [#xmlElement{name = p, content = Rest} || Rest =/= []] ++ Tail1};
get_first_sentence(Es) ->
get_first_sentence_1(Es).
@@ -1288,7 +1285,8 @@ get_first_sentence_1([E = #xmlText{value = Txt} | Es], Acc) ->
if Rest == [] ->
Es;
true ->
- [#xmlText{value=Rest} | Es]
+ [#xmlText{value=trim_leading_lines(
+ normalize_text(Rest))} | Es]
end};
none ->
get_first_sentence_1(Es, [E | Acc])
@@ -1296,8 +1294,10 @@ get_first_sentence_1([E = #xmlText{value = Txt} | Es], Acc) ->
get_first_sentence_1([E | Es], Acc) ->
% Skip non-text segments - don't descend further
get_first_sentence_1(Es, [E | Acc]);
+get_first_sentence_1([], []) ->
+ {[], []};
get_first_sentence_1([], Acc) ->
- {lists:reverse(Acc), []}.
+ {{p, lists:reverse(Acc)}, []}.
end_of_sentence(Cs, Last) ->
end_of_sentence(Cs, Last, []).
@@ -1321,3 +1321,21 @@ end_of_sentence_1(C, Cs, true, As) ->
{value, lists:reverse([C | As]), Cs};
end_of_sentence_1(_, _, false, _) ->
none.
+
+drop_empty_lines([#xmlText{value = Txt}=H|T]) ->
+ case trim_leading_lines(normalize_text(Txt)) of
+ [] ->
+ drop_empty_lines(T);
+ Rest ->
+ [H#xmlText{value = Rest}|T]
+ end;
+drop_empty_lines([H|T]) when is_list(H) ->
+ drop_empty_lines(H ++ T);
+drop_empty_lines(L) ->
+ L.
+
+trim_leading_lines([H|T]) when H==$\n; H==$\t; H==$\s ->
+ trim_leading_lines(T);
+trim_leading_lines(Str) ->
+ Str.
+
diff --git a/deps/edown/src/edown_lib.erl b/deps/edown/src/edown_lib.erl
index 7f82996..2fd66f7 100644
--- a/deps/edown/src/edown_lib.erl
+++ b/deps/edown/src/edown_lib.erl
@@ -23,14 +23,18 @@
-module(edown_lib).
--export([export/1, redirect_uri/1, get_attrval/2]).
+-export([export/2, redirect_uri/1, get_attrval/2]).
-include_lib("xmerl/include/xmerl.hrl").
+-define(HTML_EXPORT, edown_xmerl).
+-define(DEFAULT_XML_EXPORT, ?HTML_EXPORT).
-export(Data) ->
- xmerl:export_simple_content(Data, edown_xmerl).
+export(Data, Options) ->
+ xmerl:export_simple(Data, export_module(Options)).
+export_module(Options) ->
+ proplists:get_value(xml_export, Options, ?DEFAULT_XML_EXPORT).
redirect_uri(#xmlElement{} = E) ->
redirect_uri(get_attrval(href, E), get_attrval(name, E), E);
diff --git a/deps/edown/src/edown_xmerl.erl b/deps/edown/src/edown_xmerl.erl
index c11e808..ee5a1bc 100644
--- a/deps/edown/src/edown_xmerl.erl
+++ b/deps/edown/src/edown_xmerl.erl
@@ -50,21 +50,23 @@ to_string(S) ->
unicode:characters_to_list([S]).
strip(Str) -> lstrip(rstrip(Str)).
-lstrip(Str) -> re:replace(Str,"^\\s","", [unicode]).
-rstrip(Str) -> re:replace(Str, "\\s\$", "", [unicode]).
+lstrip(Str) -> re:replace(Str,"^\\s","", [unicode,{return, list}]).
+rstrip(Str) -> re:replace(Str, "\\s\$", "", [unicode, {return, list}]).
% Strip double spaces at end of line -- markdown reads as hard return.
-brstrip(Str) -> re:replace(Str, "\\s+\\s\$", "", [global, multiline, unicode]).
+brstrip(Str) -> re:replace(Str, "\\s+\\s\$", "", [global, multiline, unicode,
+ {return, list}]).
%% The '#root#' tag is called when the entire structure has been
%% exported. It does not appear in the structure itself.
'#root#'(Data, Attrs, [], _E) ->
+ Data1 = replace_edown_p(Data),
case find_attribute(header, Attrs) of
{value, Hdr} ->
- [lists:flatten(io_lib:fwrite("HEADER: ~p~n", [Hdr])), Data];
+ [lists:flatten(io_lib:fwrite("HEADER: ~p~n", [Hdr])), Data1];
false ->
- Data
+ Data1
end.
%% Note that SGML does not have the <Tag/> empty-element form.
@@ -195,7 +197,7 @@ md_elem(Tag, Data, Attrs, Parents, E) ->
'div' -> Data;
ul -> Data;
ol -> Data;
- p -> ["\n", Data, "\n"];
+ p -> ["<edown_p>", Data, "<edown_p>"]; % no need to use closing tag
b -> ["__", no_nl(Data), "__"];
em -> ["_", no_nl(Data), "_"];
i -> ["_", no_nl(Data), "_"];
@@ -203,7 +205,7 @@ md_elem(Tag, Data, Attrs, Parents, E) ->
code ->
%% edoc_macros.erl hard-codes expansion of the {@type ...} macro
%% as a HTML href inside <code>...</code>
- case re:run(Data, "<a href=", []) of
+ case re:run(Data, "<a href=", [unicode]) of
{match,_} ->
%% ["<code>", no_nl(Data), "</code>"];
["<code>", no_nl(Data), "</code>"];
@@ -263,6 +265,22 @@ no_nl(S) ->
string:strip([C || C <- to_string(S),
C =/= $\n], both).
+replace_edown_p(Data) ->
+ Data1 = unicode:characters_to_list([Data]),
+ replace_edown_p(Data1, []).
+
+replace_edown_p("<edown_p>" ++ Data, Acc) ->
+ case lstrip(Data) of
+ "<edown_p>" ++ _ = Data1 ->
+ replace_edown_p(Data1, Acc);
+ Data1 ->
+ replace_edown_p(Data1, "\n\n" ++ lstrip(Acc))
+ end;
+replace_edown_p([H|T], Acc) ->
+ replace_edown_p(T, [H|Acc]);
+replace_edown_p([], Acc) ->
+ lists:reverse(Acc).
+
%% attr(#xmlAttribute{name = N, value = V}) ->
%% "(" ++ atom_to_list(N) ++ "=" ++ [a_val(V)] ++ ")".