--- edoc_lib.erl.orig	2006-06-27 09:04:37.000000000 -0400
+++ edoc_lib.erl	2006-06-27 08:29:03.000000000 -0400
@@ -618,12 +618,18 @@
 	false -> Dir
     end.
 
-%% @spec (Text::deep_string(), Dir::edoc:filename(),
+%% @spec (Text, Dir::edoc:filename(),
 %%        Name::edoc:filename()) -> ok
+%%        Text = ignore | deep_string()
 %%
 %% @doc Write the given `Text' to the file named by `Name' in directory
 %% `Dir'. If the target directory does not exist, it will be created.
+%% If Text is 'ignore' no file is written.  The 'ignore' option can
+%% be returned by a custom layout's callback if there is no need to 
+%% create a certain file
 
+write_file(ignore, _Dir, _Name) ->
+    ok;
 write_file(Text, Dir, Name) ->
     write_file(Text, Dir, Name, '').
 
--- edoc_doclet.erl.orig	2006-06-27 09:09:10.000000000 -0400
+++ edoc_doclet.erl	2006-06-27 09:01:19.000000000 -0400
@@ -130,15 +130,18 @@
     Env = Ctxt#context.env,
     Options = Ctxt#context.opts,
     Title = title(App, Options),
-    CSS = stylesheet(Options),
-    {Modules1, Error} = sources(Sources, Dir, Modules, Env, Options),
-    modules_frame(Dir, Modules1, Title, CSS),
-    packages(Packages, Dir, FileMap, Env, Options),
-    packages_frame(Dir, Packages, Title, CSS),
-    overview(Dir, Title, Env, Options),
-    index_file(Dir, length(Packages) > 1, Title),
+    Opts = case App of
+           ?NO_APP -> Options;
+           _       -> [{application, App} | Options]
+           end,
+    {Modules1, Error} = sources(Sources, Dir, Modules, Env, Opts),
+    menu_frame(module, Dir, Modules1, Title, Opts),
+    packages(Packages, Dir, FileMap, Env, Opts),
+    menu_frame(package, Dir, Packages, Title, Opts),
+    overview(Dir, Title, Env, Opts),
+    index_file(Dir, length(Packages) > 1, Title, Opts),
     edoc_lib:write_info_file(App, Packages, Modules1, Dir),
-    copy_stylesheet(Dir, Options),
+    copy_stylesheet(Dir, Opts),
     %% handle postponed error during processing of source files
     case Error of
 	true -> exit(error);
@@ -256,8 +259,42 @@
 
 
 %% Creating an index file, with some frames optional.
+index_file(Dir, Packages, Title, Opts) ->
+    F = fun(M) ->
+        Exports = proplists:get_value(exports, M:module_info()),
+        case lists:member({index_file,2}, Exports) of
+        true ->
+            M:index_file(Packages, Title);
+        false ->
+            edoc_index_file(Packages, Title)
+        end
+    end,
+    Text = edoc_lib:run_layout(F, Opts),
+    edoc_lib:write_file(Text, Dir, ?INDEX_FILE).
 
-index_file(Dir, Packages, Title) ->
+menu_frame(FrameType, Dir, Items, Title, Opts) ->
+    F = fun(M) ->
+        Exports = proplists:get_value(exports, M:module_info()),
+        case {lists:member({menu_frame,4}, Exports), FrameType} of
+        {true, _} ->
+            M:menu_frame(FrameType, Items, Title, Opts);
+        {false, application} ->
+            application_frame(Items, Title, Opts);
+        {false, module} ->
+            modules_frame(Items, Title, Opts);
+        {false, package} ->
+            packages_frame(Items, Title, Opts)
+        end
+    end,
+    Text = edoc_lib:run_layout(F, Opts),
+    File = case FrameType of 
+           package     -> ?PACKAGES_FRAME;
+           module      -> ?MODULES_FRAME;
+           application -> ?MODULES_FRAME
+           end,
+    edoc_lib:write_file(Text, Dir, File).
+    
+edoc_index_file(Packages, Title) ->
     Frame1 = {frame, [{src,?PACKAGES_FRAME},
 		      {name,"packagesFrame"},{title,""}],
 	      []},
@@ -291,10 +328,9 @@
 		      ?NL]},
 		    ?NL]},
     XML = xhtml_1(Title, [], Frameset),
-    Text = xmerl:export_simple([XML], xmerl_html, []),
-    edoc_lib:write_file(Text, Dir, ?INDEX_FILE).
+    xmerl:export_simple([XML], xmerl_html, []).
 
-packages_frame(Dir, Ps, Title, CSS) ->
+packages_frame(Ps, Title, Options) ->
     Body = [?NL,
 	    {h2, ["Packages"]},
 	    ?NL,
@@ -304,24 +340,32 @@
 			       [atom_to_list(P)]}]}]}
 	      || P <- Ps]},
 	    ?NL],
+    CSS = stylesheet(Options),
     XML = xhtml(Title, CSS, Body),
-    Text = xmerl:export_simple([XML], xmerl_html, []),
-    edoc_lib:write_file(Text, Dir, ?PACKAGES_FRAME).
+    xmerl:export_simple([XML], xmerl_html, []).
 
-modules_frame(Dir, Ms, Title, CSS) ->
-    Body = [?NL,
-	    {h2, ["Modules"]},
-	    ?NL,
-	    {table, [{width, "100%"}, {border, 0}],
+modules_frame(Ms, Title, Options) ->
+    ModuleRows =
 	     [{tr, [{td, [],
 		     [{a, [{href, module_ref(M)},
 			   {target,"overviewFrame"}],
 		       [atom_to_list(M)]}]}]}
-	      || M <- Ms]},
+          || M <- Ms],
+    Rows =
+       [{tr, [{td, [],
+             [{a, [{href, ?OVERVIEW_SUMMARY},
+                   {target,"overviewFrame"}],
+                   ["overview"]}]}]} | ModuleRows],
+    Body = [?NL,
+	    {h2, ["Modules"]},
+	    ?NL,
+	    {table, [{width, "100%"}, {border, 0}],
+            Rows
+        },
 	    ?NL],
+    CSS = stylesheet(Options),
     XML = xhtml(Title, CSS, Body),
-    Text = xmerl:export_simple([XML], xmerl_html, []),
-    edoc_lib:write_file(Text, Dir, ?MODULES_FRAME).
+    xmerl:export_simple([XML], xmerl_html, []).
 
 module_ref(M) ->
     edoc_refs:relative_package_path(M, '') ++ ?DEFAULT_FILE_SUFFIX.
@@ -471,16 +515,15 @@
 app_index_file(Paths, Dir, Env, Options) ->
     Title = proplists:get_value(title, Options,"Overview"),
 %    Priv = proplists:get_bool(private, Options),
-    CSS = stylesheet(Options),
     Apps1 = [{filename:dirname(A),filename:basename(A)} || A <- Paths],
-    index_file(Dir, false, Title),
-    application_frame(Dir, Apps1, Title, CSS),
-    modules_frame(Dir, [], Title, CSS),
+    index_file(Dir, false, Title, Options),
+    menu_frame(application, Dir, Apps1, Title, Options),
+    menu_frame(module, Dir, [], Title, Options),
     overview(Dir, Title, Env, Options),
 %    edoc_lib:write_info_file(Prod, [], Modules1, Dir),
     copy_stylesheet(Dir, Options).
 
-application_frame(Dir, Apps, Title, CSS) ->
+application_frame(Apps, Title, Options) ->
     Body = [?NL,
 	    {h2, ["Applications"]},
 	    ?NL,
@@ -490,9 +533,9 @@
 			       [App]}]}]}
 	      || {Path,App} <- Apps]},
 	    ?NL],
+    CSS = stylesheet(Options),
     XML = xhtml(Title, CSS, Body),
-    Text = xmerl:export_simple([XML], xmerl_html, []),
-    edoc_lib:write_file(Text, Dir, ?MODULES_FRAME).
+    xmerl:export_simple([XML], xmerl_html, []).
 
 app_ref(Path,M) ->
     filename:join([Path,M,?EDOC_DIR,?INDEX_FILE]).
