Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

UTF-8 compatibility. #11

Merged
merged 5 commits into from

3 participants

@akaspin

So. We live in 2011.

akaspin added some commits
@akaspin akaspin UTF-8 compatibility.
Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
00ce841
@akaspin akaspin no sort function
Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
f3fda83
@akaspin akaspin Fix javascript index
Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
669efb6
@akaspin akaspin better errors
Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
5c30023
@akaspin akaspin Fix better errors
Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
aabb6ca
@daleharvey
Owner

Hey akaspin

Sorry for not commenting on this pull request earlier, the patch looks great, there is a new erlang release due quite soon and I will test and merge this when updating for the new release.

Thanks
Dale

@daleharvey daleharvey merged commit 1ce84d9 into daleharvey:master
@keynslug

You should specify the 'global' option also surely. Otherwise the js code may be invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 8, 2011
  1. @akaspin

    UTF-8 compatibility.

    akaspin authored
    Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
  2. @akaspin

    no sort function

    akaspin authored
    Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
  3. @akaspin

    Fix javascript index

    akaspin authored
    Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
Commits on Jul 9, 2011
  1. @akaspin

    better errors

    akaspin authored
    Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
  2. @akaspin

    Fix better errors

    akaspin authored
    Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
This page is out of date. Refresh to see the latest.
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">
Something went wrong with that request. Please try again.