aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edoc/src/edoc_doclet.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2012-12-03 12:34:04 +0100
committerHans Bolinder <[email protected]>2013-01-02 10:15:17 +0100
commitb941448860fc2220695d04d8b8806509cb053b5a (patch)
tree3ec103a7bd6791eedac019d536649a3f459e0567 /lib/edoc/src/edoc_doclet.erl
parent300c5466a7c9cfe3ed22bba2a88ba21058406402 (diff)
downloadotp-b941448860fc2220695d04d8b8806509cb053b5a.tar.gz
otp-b941448860fc2220695d04d8b8806509cb053b5a.tar.bz2
otp-b941448860fc2220695d04d8b8806509cb053b5a.zip
[edoc] Introduce Unicode support for source files
Diffstat (limited to 'lib/edoc/src/edoc_doclet.erl')
-rw-r--r--lib/edoc/src/edoc_doclet.erl20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/edoc/src/edoc_doclet.erl b/lib/edoc/src/edoc_doclet.erl
index 385d20e9ae..d6561e10fc 100644
--- a/lib/edoc/src/edoc_doclet.erl
+++ b/lib/edoc/src/edoc_doclet.erl
@@ -193,7 +193,8 @@ source({M, P, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden,
true ->
Text = edoc:layout(Doc, Options),
Name1 = packages:last(M) ++ Suffix,
- edoc_lib:write_file(Text, Dir, Name1, P),
+ Encoding = [{encoding,encoding(Doc)}],
+ edoc_lib:write_file(Text, Dir, Name1, P, Encoding),
{sets:add_element(Module, Set), Error};
false ->
{Set, Error}
@@ -359,14 +360,19 @@ xhtml_1(Title, CSS, Body) ->
overview(Dir, Title, Env, Opts) ->
File = proplists:get_value(overview, Opts,
filename:join(Dir, ?OVERVIEW_FILE)),
+ Encoding = edoc_lib:read_encoding(File, [{in_comment_only, false}]),
Tags = read_file(File, overview, Env, Opts),
- Data = edoc_data:overview(Title, Tags, Env, Opts),
+ Data0 = edoc_data:overview(Title, Tags, Env, Opts),
+ EncodingAttribute = #xmlAttribute{name = encoding,
+ value = atom_to_list(Encoding)},
+ #xmlElement{attributes = As} = Data0,
+ Data = Data0#xmlElement{attributes = [EncodingAttribute | As]},
F = fun (M) ->
M:overview(Data, Opts)
end,
Text = edoc_lib:run_layout(F, Opts),
- edoc_lib:write_file(Text, Dir, ?OVERVIEW_SUMMARY).
-
+ EncOpts = [{encoding,Encoding}],
+ edoc_lib:write_file(Text, Dir, ?OVERVIEW_SUMMARY, '', EncOpts).
copy_image(Dir) ->
case code:priv_dir(?EDOC_APP) of
@@ -441,6 +447,12 @@ is_hidden(E) ->
_ -> false
end.
+encoding(E) ->
+ case get_attrval(encoding, E) of
+ "latin1" -> latin1;
+ _ -> utf8
+ end.
+
get_attrval(Name, #xmlElement{attributes = As}) ->
case get_attr(Name, As) of
[#xmlAttribute{value = V}] ->