anchor.diff:             , {ga,      kf(ga,Conf)}
              ],
       {ok, Data} = erldocs_dtl:render(Args),
  -    ok = file:write_file(jname(kf(dest,Conf), "index.html"), Data).
  -
  -xml_index (L) ->
  -    Sorted = lists:sort(fun sort_index/2, L),
  +    Path = jname(kf(dest,Conf), "index.html"),
  +    ok = file:write_file(Path, Data).
  +
  +index_to_xml (SortedIndex) ->
       lists:flatmap(
  -      fun (["app", App, _,  _Sum]) ->
  +      fun ({"app", App, _,  _Sum}) ->
                 [{a, [{name, App}]}, {h4, [], [App]}];
  -          (["mod", App, Mod, Sum]) ->
  +          ({"mod", App, Mod, Sum}) ->
                 Url = jname(App, Mod++".html"),
                 [{p,[], [{a, [{href, Url}], [Mod]}, {br,[],[]}, Sum]}];
  -          (_) ->
  +          ({"fun", _App, _MFA, _Sum}) ->
                 []
         end,
  -      Sorted).
  -
  -index_ordering ([Type, App, Mod, _Sum]) ->
  +      SortedIndex).
  +
  +
  +sort_index (Index) ->
  +    lists:sort(fun compare_index_items/2, Index).
  +
  +compare_index_items (Lhs, Rhs) ->
  +    index_ordering(Lhs) =< index_ordering(Rhs).
  +
  +index_ordering ({Type, App, Mod, _Sum}) ->
       [ string:to_lower(App)
  -    , case Type of
  -          "app" -> 1;
  -          "mod" -> 2;
  -          "fun" -> 3
  -      end
  +    , index_item(Type)
       , string:to_lower(Mod)
       ].
   
  -sort_index (A, B) ->
  -    index_ordering(A) =< index_ordering(B).
  +index_item ("app") -> 1;
  +index_item ("mod") -> 2;
  +index_item ("fun") -> 3.
  +
   
   js_strip (Str) ->
       [C || C <- Str, C /= $\n, C /= $\r, C /= $'].
   
  -javascript_index (Conf, FIndex) ->
  +javascript_index (Conf, SortedIndex) ->
       ?log("Creating erldocs_index.js ..."),
  -    Sorted = lists:sort(fun sort_index/2, FIndex),
  -
  -    Index =
  -        lists:map(
  -          fun ([A,B,C,D]) ->
  -                  [ ",['", js_strip(A)
  -                  , "','", js_strip(B)
  -                  , "','", js_strip(C)
  -                  , "','", js_strip(D), "']"
  -                  ]
  -          end,
  -          Sorted),
  -    IndexStr = iolists_tl(Index), %% Removes leading $,
  -
  +    IndexStr = iolists_tl(  %% Removes leading $,
  +                 [ [ ",['", js_strip(A)
  +                   , "','", js_strip(B)
  +                   , "','", js_strip(C)
  +                   , "','", js_strip(D), "']"
  +                   ]
  +                   || {A,B,C,D} <- SortedIndex ]
  +                ),
       %% io:format("bin ~s\n", [iolists_flatten(IndexStr)]),
       Data = ["var index = [", IndexStr, "];"],
       Path = jname(kf(dest,Conf), "erldocs_index.js"),
       ok = file:write_file(Path, Data).
   
  -shorten (Str) ->
  -    Lines = string:tokens(lists:flatten(Str), "\r\n"),
  -    Clean = string:join(lists:map(fun string:strip/1, Lines), " "),
  -    string:substr(Clean, 1, 50).
  -
   %% Note: handles both erlref and cref types
   render (App, Mod, Xml, Types, Conf) ->
       File = jname([kf(dest,Conf), App, Mod++".html"]),
  
positive.code:     AppDirs = [Path || Path <- kf(apps,Conf), filelib:is_dir(Path)],
      IncludePaths = lists:flatmap(fun includes/1, AppDirs),
  
      Fun = fun (AppDir, Acc) -> build_apps(Conf, IncludePaths, bname(AppDir), AppDir, Acc) end,
      Index = lists:foldl(Fun, [], AppDirs),
  
      case length(kf(apps,Conf)) == length(Index) of
          true  ->
              %% Only the "[application]" (inserted by build_apps/5) are present
              %% in Index, thus:
              ?log("No documentation was generated!"),
              false;
          false ->
              ok = module_index(Conf, Index),
              ok = javascript_index(Conf, Index),
              ok = copy_static_files(Conf),
              true
      end.
  
  build_apps (Conf, IncludePaths, AppName, AppDir, Index) ->
      ?log("Building ~s", [AppName]),
      Files = ensure_docsrc(Conf, IncludePaths, AppName, AppDir),
      Map = fun (File) -> build_file_map(Conf, AppName, bname(File,".xml"), File) end,
      [ ["app", AppName, AppName, "[application]"]
        | pmapreduce(Map, fun lists:append/2, [], Files)
        ++ Index
      ].
  
  build_file_map (Conf, AppName, Module, File) ->
  
negative.code:             throw({error_in_read_xml, XmlFile, Error})
      end.
  
  -spec kf (_, list()) -> _.
  kf (Key, Conf) ->
      {Key, Val} = lists:keyfind(Key, 1, Conf),
  