Skip to content

Commit

Permalink
various fixes in formatting & URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Wiger committed Oct 26, 2010
1 parent c7f546e commit 16a3c54
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 20 deletions.
6 changes: 3 additions & 3 deletions doc/edown_doclet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -150,4 +150,4 @@ will be copied to the target directory.



_Generated by EDoc, Oct 25 2010, 17:44:35._
_Generated by EDoc, Oct 26 2010, 20:31:14._
8 changes: 4 additions & 4 deletions doc/edown_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ the source file. The default value is <code>true</code>.



<dd>Specifies an <a href="/Users/uwiger/ETC/git/xmerl/doc/index.html" 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.html#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/xmerl/doc/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/doc/xmerl.html#export_simple_content-2"><code>//xmerl/xmerl:export_simple_content/2</code></a> for details.
</dd>





__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).
<a name="overview-2"></a>


Expand Down Expand Up @@ -158,4 +158,4 @@ __See also:__ [edoc:layout/2](edoc.html#layout-2).



_Generated by EDoc, Oct 25 2010, 17:44:35._
_Generated by EDoc, Oct 26 2010, 20:31:14._
2 changes: 1 addition & 1 deletion doc/edown_lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ Github-flavored Markdown for EDoc - common support functions



_Generated by EDoc, Oct 25 2010, 17:44:35._
_Generated by EDoc, Oct 26 2010, 20:31:14._
2 changes: 1 addition & 1 deletion doc/edown_xmerl.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ __Authors:__ Ulf Wiger ([`[email protected]`](mailto:ulf.wiger@erla



_Generated by EDoc, Oct 25 2010, 17:44:35._
_Generated by EDoc, Oct 26 2010, 20:31:14._
3 changes: 2 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}.
19 changes: 14 additions & 5 deletions src/edown_doclet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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),
Expand All @@ -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
%%
Expand Down
29 changes: 26 additions & 3 deletions src/edown_layout.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
%% </dd>
%% </dl>
%%
%% @see edoc:layout/2
%% @see edown_doclet:layout/2
%% @see //edoc/edoc:layout/2

%% NEW-OPTIONS: xml_export, index_columns, stylesheet

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).
4 changes: 2 additions & 2 deletions src/edown_xmerl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 16a3c54

Please sign in to comment.