Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #11 from akaspin/master

UTF-8 compatibility.
  • Loading branch information...
commit 1ce84d9eb216a403d913c77d2211ec970c38e788 2 parents c6f4e90 + aabb6ca
@daleharvey authored
View
2  .gitignore
@@ -5,3 +5,5 @@ deps
ebin
priv/www
!/priv/www/index.html
+/.settings
+/.project
View
BIN  erldocs 100755 → 100644
Binary file not shown
View
50 src/erldocs_core.erl
@@ -3,6 +3,14 @@
-export([mapreduce/4, pmapreduce/4, pmapreduce/5]).
-include_lib("kernel/include/file.hrl").
+-ifdef(DEBUG).
+-define(LOG(Str, Args), io:format(Str, Args)).
+-define(LOG(Str), io:format(Str)).
+-else.
+-define(LOG(_Str, _Args), ok).
+-define(LOG(_Str), ok).
+-endif.
+
%% @doc Copy static files
-spec copy_static_files(list()) -> ok.
copy_static_files(Conf) ->
@@ -61,7 +69,7 @@ build_file_map(Conf, AppName, File) ->
erlref ->
{modulesummary, [], Sum}
= lists:keyfind(modulesummary,1, Xml),
- Sum;
+ unicode:characters_to_list(Sum);
cref ->
{libsummary, [], Sum}
= lists:keyfind(libsummary, 1, Xml),
@@ -112,7 +120,9 @@ gen_docsrc(AppDir, SrcFiles, Dest) ->
Includes = filelib:wildcard(AppDir ++ "/include"),
lists:foldl(fun(File, Acc) ->
log("Generating XML - ~s~n", [bname(File, ".erl")]),
- case (catch docb_gen:module(File, [{includes, Includes}])) of
+ case (catch docb_gen:module(
+ File, [{includes, Includes},
+ {sort_functions,false}])) of
ok ->
[filename:join([Dest, bname(File, ".erl")]) ++ ".xml"|Acc];
Error ->
@@ -188,11 +198,20 @@ javascript_index(Conf, FIndex) ->
log("Creating erldocs_index.js ...~n"),
F = fun([Else, App, NMod, Sum]) ->
- [Else, App, NMod, string:substr(Sum, 1, 50)]
+ [Else, App, NMod, fmt("~ts", [string:substr(Sum, 1, 50)])]
end,
- Index = lists:sort(fun sort_index/2, lists:map(F, FIndex)),
- Js = fmt("var index = ~p;", [Index]),
+ Index =
+ lists:map(
+ fun([A,B,C,[]]) ->
+ fmt("['~s','~s','~s',[]]", [A,B,C]);
+ ([A,B,C,D]) ->
+ fmt("['~s','~s','~s','~s']", [A,B,C,D])
+ end,
+ lists:sort(fun sort_index/2, lists:map(F, FIndex))),
+
+ Js = re:replace(fmt("var index = [~s];", [string:join(Index, ",")]),
+ "\\n|\\r", "", [{return,list}]),
ok = file:write_file([dest(Conf), "/erldocs_index.js"], Js).
@@ -406,7 +425,7 @@ strip_whitespace(Else) ->
is_whitespace(X) when is_tuple(X); is_number(X) ->
true;
is_whitespace(X) ->
- nomatch == re:run(X, "^[ \n\t]*$"). %"
+ nomatch == re:run(X, "^[ \n\t]*$", [unicode]). %"
%% rather basic xml to string converter, takes xml of the form
%% {tag, [{listof, "attributes"}], ["list of children"]}
@@ -416,15 +435,15 @@ xml_to_str(Xml) ->
xml_to_html({Tag, Attr}) ->
%% primarily for cases such as <a name="">
- fmt("<~s ~s>", [Tag, atos(Attr)]);
+ fmt("<~ts ~ts>", [Tag, atos(Attr)]);
xml_to_html({Tag, Attr, []}) ->
- fmt("<~s ~s />", [Tag, atos(Attr)]);
+ fmt("<~ts ~ts />", [Tag, atos(Attr)]);
xml_to_html({Tag, [], []}) ->
- fmt("<~s />", [Tag]);
+ fmt("<~ts />", [Tag]);
xml_to_html({Tag, [], Child}) ->
- fmt("<~s>~s</~s>", [Tag, xml_to_html(Child), Tag]);
+ fmt("<~ts>~ts</~ts>", [Tag, xml_to_html(Child), Tag]);
xml_to_html({Tag, Attr, Child}) ->
- fmt("<~s ~s>~s</~s>", [Tag, atos(Attr), xml_to_html(Child), Tag]);
+ fmt("<~ts ~ts>~ts</~ts>", [Tag, atos(Attr), xml_to_html(Child), Tag]);
xml_to_html(List) when is_list(List) ->
case io_lib:char_list(List) of
true -> htmlchars(List);
@@ -452,8 +471,9 @@ htmlchars([Else | Rest], Acc) -> htmlchars(Rest, [Else | Acc]).
-spec read_xml(list(), list()) -> tuple().
read_xml(_Conf, XmlFile) ->
- Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]},
- {encoding, "latin1"}],
+%% Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]},
+%% {encoding, "utf-8"}],
+ Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]}],
{Xml, _} = xmerl_scan:file(XmlFile, Opts),
xmerl_lib:simplify_element(Xml).
@@ -463,9 +483,9 @@ fmt(Format, Args) ->
lists:flatten(io_lib:format(Format, Args)).
log(Str) ->
- io:format(Str).
+ ?LOG(Str).
log(Str, Args) ->
- io:format(Str, Args).
+ ?LOG(Str, Args).
%% @doc shorthand for lists:keyfind
-spec kf(term(), list()) -> term().
View
2  templates/erldocs.dtl
@@ -2,7 +2,7 @@
<html lang="en">
<head>
- <meta charset="latin1" />
+ <meta charset="utf-8" />
<title>{{ title }} - erldocs.com (Erlang Documentation)</title>
<link rel="search" type="application/opensearchdescription+xml"
title="erldocs" href="/search.xml">
Please sign in to comment.
Something went wrong with that request. Please try again.