From 16a3c54450c6827908cab6de70af81ea25ea6045 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Tue, 26 Oct 2010 20:33:14 +0200 Subject: [PATCH] various fixes in formatting & URIs --- doc/edown_doclet.md | 6 +++--- doc/edown_layout.md | 8 ++++---- doc/edown_lib.md | 2 +- doc/edown_xmerl.md | 2 +- rebar.config | 3 ++- src/edown_doclet.erl | 19 ++++++++++++++----- src/edown_layout.erl | 29 ++++++++++++++++++++++++++--- src/edown_xmerl.erl | 4 ++-- 8 files changed, 53 insertions(+), 20 deletions(-) diff --git a/doc/edown_doclet.md b/doc/edown_doclet.md index 90a3acd..060d938 100644 --- a/doc/edown_doclet.md +++ b/doc/edown_doclet.md @@ -49,8 +49,8 @@ Main doclet entry point. -Also see [`edoc:layout/2`](edoc.html#layout-2) for layout-related options, and -[`edoc:get_doc/2`](edoc.html#get_doc-2) for options related to reading source +Also see [`//edoc/edoc:layout/2`](http://www.erlang.org/doc/man/edoc/doc/edoc.html#layout-2) for layout-related options, and +[`//edoc/edoc:get_doc/2`](http://www.erlang.org/doc/man/edoc/doc/edoc.html#get_doc-2) for options related to reading source files. Options: @@ -150,4 +150,4 @@ will be copied to the target directory. -_Generated by EDoc, Oct 25 2010, 17:44:35._ \ No newline at end of file +_Generated by EDoc, Oct 26 2010, 20:31:14._ \ No newline at end of file diff --git a/doc/edown_layout.md b/doc/edown_layout.md index 95f07a3..ff94e5a 100644 --- a/doc/edown_layout.md +++ b/doc/edown_layout.md @@ -112,15 +112,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:layout/2](edoc.html#layout-2). +__See also:__ [//edoc/edoc:layout/2](http://www.erlang.org/doc/man/edoc/doc/edoc.html#layout-2), [edown_doclet:layout/2](edown_doclet.md#layout-2). @@ -158,4 +158,4 @@ __See also:__ [edoc:layout/2](edoc.html#layout-2). -_Generated by EDoc, Oct 25 2010, 17:44:35._ \ No newline at end of file +_Generated by EDoc, Oct 26 2010, 20:31:14._ \ No newline at end of file diff --git a/doc/edown_lib.md b/doc/edown_lib.md index b6b4aa2..f6a60f5 100644 --- a/doc/edown_lib.md +++ b/doc/edown_lib.md @@ -43,4 +43,4 @@ Github-flavored Markdown for EDoc - common support functions -_Generated by EDoc, Oct 25 2010, 17:44:35._ \ No newline at end of file +_Generated by EDoc, Oct 26 2010, 20:31:14._ \ No newline at end of file diff --git a/doc/edown_xmerl.md b/doc/edown_xmerl.md index acdf640..ae8a055 100644 --- a/doc/edown_xmerl.md +++ b/doc/edown_xmerl.md @@ -74,4 +74,4 @@ __Authors:__ Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erla -_Generated by EDoc, Oct 25 2010, 17:44:35._ \ No newline at end of file +_Generated by EDoc, Oct 26 2010, 20:31:14._ \ No newline at end of file diff --git a/rebar.config b/rebar.config index 4225307..5230427 100644 --- a/rebar.config +++ b/rebar.config @@ -7,4 +7,5 @@ {clean_files, ["*~","*/*~","ebin/*.beam"]}. -{edoc_opts, [{doclet, edown_doclet}]}. +{edoc_opts, [{doclet, edown_doclet}, + {app_default,"http://www.erlang.org/doc/man"}]}. diff --git a/src/edown_doclet.erl b/src/edown_doclet.erl index 223abf0..958c0fc 100644 --- a/src/edown_doclet.erl +++ b/src/edown_doclet.erl @@ -52,8 +52,8 @@ %% @spec (Command::doclet_gen() | doclet_toc(), edoc_context()) -> ok %% @doc Main doclet entry point. %% -%% Also see {@link edoc:layout/2} for layout-related options, and -%% {@link edoc:get_doc/2} for options related to reading source +%% Also see {@link //edoc/edoc:layout/2} for layout-related options, and +%% {@link //edoc/edoc:get_doc/2} for options related to reading source %% files. %% %% Options: @@ -117,9 +117,9 @@ gen(Sources, App, Packages, Modules, FileMap, Ctxt) -> Dir = Ctxt#context.dir, Env = Ctxt#context.env, Options0 = Ctxt#context.opts, - Options = [{layout,edown_layout}, - {file_suffix,".md"} - | Options0], + Options = set_app_default([{layout,edown_layout}, + {file_suffix,".md"} + | Options0]), Title = title(App, Options), %% CSS = stylesheet(Options), {Modules1, Error} = sources(Sources, Dir, Modules, Env, Options), @@ -142,6 +142,15 @@ gen(Sources, App, Packages, Modules, FileMap, Ctxt) -> false -> ok end. + +set_app_default(Opts) -> + case lists:keyfind(app_default,1,Opts) of + false -> + [{app_default, "http://www.erlang.org/doc/man"}|Opts]; + _ -> + Opts + end. + %% Tried to display logo in a table on top of page, but not working. %% Presumably, this hits some limitation of GFM %% diff --git a/src/edown_layout.erl b/src/edown_layout.erl index 2a28831..23285fb 100644 --- a/src/edown_layout.erl +++ b/src/edown_layout.erl @@ -76,7 +76,8 @@ %% %% %% -%% @see edoc:layout/2 +%% @see edown_doclet:layout/2 +%% @see //edoc/edoc:layout/2 %% NEW-OPTIONS: xml_export, index_columns, stylesheet @@ -524,7 +525,29 @@ sees(Es) -> end. see(E=#xmlElement{content = Es}) -> - see(E, Es). + case get_attrval(name, E) of + "" -> + see(E, Es); + [_|_] = Str -> + see(redirect_uri(Str, E), Es) + end. + +redirect_uri("//" ++ _, E) -> + %% We don't handle this... yet. Presumably, the user does with some + %% of those options only Richard Carlsson knows are there. + E; +redirect_uri(Str, #xmlElement{attributes = As} = E) -> + case re:split(Str, ":", [{return,list}]) of + [_, _] -> + #xmlAttribute{value = URI} = A = + lists:keyfind(href, #xmlAttribute.name, As), + NewURI = re:replace(URI,".html",".md",[{return,list}]), + As1 = lists:keyreplace(href, #xmlAttribute.name, As, + A#xmlAttribute{value = NewURI}), + E#xmlElement{attributes = As1}; + _ -> + E + end. see(E, Es) -> case href(E) of @@ -887,5 +910,5 @@ overview(E=#xmlElement{name = overview, content = Es}, Options) -> %% ++ navigation("bottom") %% ++ timestamp()), %% XML = xhtml(Title, stylesheet(Opts), Body), - XML = markdown(Title, stylesheet(Opts), Body). + _XML = markdown(Title, stylesheet(Opts), Body). %% xmerl:export_simple_content(XML, ?HTML_EXPORT). diff --git a/src/edown_xmerl.erl b/src/edown_xmerl.erl index 0fcf914..825ef2d 100644 --- a/src/edown_xmerl.erl +++ b/src/edown_xmerl.erl @@ -139,8 +139,8 @@ elem(Tag, Data, Attrs, Parents, E) -> tt -> "`" ++ no_nl(Data) ++ "`"; code -> "`" ++ no_nl(Data) ++ "`"; dl -> Data; - dt -> html_elem(h3, Data, Attrs, Parents, E); - dd -> html_elem(p, Data, Attrs, Parents, E); + dt -> html_elem(dt, Data, Attrs, Parents, E); + dd -> html_elem(dd, Data, Attrs, Parents, E); h1 -> "\n\n#" ++ no_nl(Data) ++ "#\n"; h2 -> "\n\n##" ++ no_nl(Data) ++ "##\n"; h3 -> "\n\n###" ++ no_nl(Data) ++ "##\n";