diff options
Diffstat (limited to 'lib/docbuilder/src')
29 files changed, 0 insertions, 5064 deletions
diff --git a/lib/docbuilder/src/Makefile b/lib/docbuilder/src/Makefile deleted file mode 100644 index e8a07a54e8..0000000000 --- a/lib/docbuilder/src/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -# ``The contents of this file are subject to the Erlang Public License, -# Version 1.1, (the "License"); you may not use this file except in -# compliance with the License. You should have received a copy of the -# Erlang Public License along with this software. If not, it can be -# retrieved via the world wide web at http://www.erlang.org/. -# -# Software distributed under the License is distributed on an "AS IS" -# basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -# the License for the specific language governing rights and limitations -# under the License. -# -# The Initial Developer of the Original Code is Ericsson Utvecklings AB. -# Portions created by Ericsson are Copyright 1999-2000, Ericsson -# Utvecklings AB. All Rights Reserved.'' -# -# $Id$ -# - -include $(ERL_TOP)/make/target.mk -include $(ERL_TOP)/make/$(TARGET)/otp.mk - -# ---------------------------------------------------- -# Application version -# ---------------------------------------------------- -include ../vsn.mk -VSN=$(DOCB_VSN) - -# ---------------------------------------------------- -# Release directory specification -# ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/docbuilder-$(VSN) - -# ---------------------------------------------------- -# Common Macros -# ---------------------------------------------------- - -MODULES= \ - docb_edoc_xml_cb \ - docb_gen \ - docb_html \ - docb_html_layout \ - docb_html_ref \ - docb_html_util \ - docb_html_util_iso \ - docb_main \ - docb_pretty_format \ - docb_tr_application2html \ - docb_tr_appref2html \ - docb_tr_chapter2html \ - docb_tr_cite2html \ - docb_tr_comref2html \ - docb_tr_cref2html \ - docb_tr_erlref2html \ - docb_tr_fileref2html \ - docb_tr_first2html \ - docb_tr_index2html \ - docb_tr_part2html \ - docb_tr_refs2kwic \ - docb_tr_report2html \ - docb_tr_term2html \ - docb_transform \ - docb_util \ - docb_xmerl_tree_cb \ - docb_xmerl_xml_cb \ - docb_xml_check - -HRL_FILES= \ - docb_util.hrl - -ERL_FILES= $(MODULES:%=%.erl) - -TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) - -APP_FILE= docbuilder.app -APPUP_FILE= docbuilder.appup -APP_SRC= $(APP_FILE).src -APPUP_SRC= $(APPUP_FILE).src -APP_TARGET= $(EBIN)/$(APP_FILE) -APPUP_TARGET= $(EBIN)/$(APPUP_FILE) - -# ---------------------------------------------------- -# FLAGS -# ---------------------------------------------------- -ERL_FLAGS += -XMERL = ../../xmerl -ERL_COMPILE_FLAGS += -I$(XMERL)/include - -# ---------------------------------------------------- -# Targets -# ---------------------------------------------------- - -debug opt: $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET) - -clean: - rm -f $(TARGET_FILES) $(APP_TARGET) - rm -f errs core *~ - -$(APP_TARGET): $(APP_SRC) ../vsn.mk - sed -e 's;%VSN%;$(VSN);' $< > $@ -$(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk - sed -e 's;%VSN%;$(VSN);' $< > $@ - -docs: - -# ---------------------------------------------------- -# Release Target -# ---------------------------------------------------- -include $(ERL_TOP)/make/otp_release_targets.mk - -release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/src - $(INSTALL_DATA) $(ERL_FILES) $(HRL_FILES) $(RELSYSDIR)/src - $(INSTALL_DIR) $(RELSYSDIR)/ebin - $(INSTALL_DATA) $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET) $(RELSYSDIR)/ebin - -release_docs_spec: - - - - - diff --git a/lib/docbuilder/src/docb_gen.erl b/lib/docbuilder/src/docb_gen.erl deleted file mode 100644 index 75494314f1..0000000000 --- a/lib/docbuilder/src/docb_gen.erl +++ /dev/null @@ -1,142 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_gen). - --export([module/1, module/2, users_guide/1, users_guide/2]). --deprecated([{module,1,next_major_release}, - {module,2,next_major_release}, - {users_guide,1,next_major_release}, - {users_guide,2,next_major_release}]). - --record(args, {suffix=".xml", - layout=docb_edoc_xml_cb, - def=[], - includes=[], - preprocess=false, - sort_functions=true}). - -%% module(File) -> ok | {error, Reason} -%% module(File, Opts) -> ok | {error, Reason} -%% File = string(), file name with or without ".erl" extension -%% Opts -- see code -%% Reason = badfile | {badopt, Term} -module(File0) -> - module(File0, []). -module(File0, RawOpts) -> - File = case filename:extension(File0) of - ".erl" -> File0; - _ -> File0++".erl" - end, - case filelib:is_regular(File) of - true -> - case parse(RawOpts, #args{}) of - {ok, Args} -> - Opts = [{def, Args#args.def}, - {includes, Args#args.includes}, - {preprocess, Args#args.preprocess}, - {sort_functions, Args#args.sort_functions}, - - {app_default, "OTPROOT"}, - {file_suffix, Args#args.suffix}, - {dir, "."}, - {layout, Args#args.layout}], - edoc:file(File, Opts); - Error -> - Error - end; - false -> - {error, badfile} - end. - -%% users_guide(File) -> ok | {error, Reason} -%% users_guide(File, Opts) -> ok | {error, Reason} -%% File = string() -%% Opts -- see code -%% Reason = badfile | {badopt, Opt} -users_guide(File) -> - users_guide(File, []). -users_guide(File, RawOpts) -> - case filelib:is_regular(File) of - true -> - case parse(RawOpts, #args{}) of - {ok, Args} -> - Opts = [{def, Args#args.def}, - {app_default, "OTPROOT"}, - {file_suffix, Args#args.suffix}, - {layout, Args#args.layout}], - - Env = edoc_lib:get_doc_env(Opts), - - {ok, Tags} = - edoc_extract:file(File, overview, Env, Opts), - Data = - edoc_data:overview("Overview", Tags, Env, Opts), - F = fun(M) -> M:overview(Data, Opts) end, - Text = edoc_lib:run_layout(F, Opts), - - OutFile = "chapter" ++ Args#args.suffix, - edoc_lib:write_file(Text, ".", OutFile); - Error -> - Error - end; - false -> - {error, badfile} - end. - -parse([{output,xml} | RawOpts], Args) -> - parse(RawOpts, Args); % default, no update of record necessary -parse([{output,sgml} | RawOpts], Args) -> - parse(RawOpts, Args#args{suffix=".sgml", layout=docb_edoc_sgml_cb}); -parse([{def,Defs} | RawOpts], Args) -> - case parse_defs(Defs) of - true -> - Args2 = Args#args{def=Args#args.def++Defs}, - parse(RawOpts, Args2); - false -> - {error, {badopt, {def,Defs}}} - end; -parse([{includes,Dirs} | RawOpts], Args) -> - case parse_includes(Dirs) of - true -> - Args2 = Args#args{includes=Args#args.includes++Dirs}, - parse(RawOpts, Args2); - false -> - {error, {badopt, {includes,Dirs}}} - end; -parse([{preprocess,Bool} | RawOpts], Args) when Bool==true; - Bool==false -> - parse(RawOpts, Args#args{preprocess=Bool}); -parse([{sort_functions,Bool} | RawOpts], Args) when Bool==true; - Bool==false -> - parse(RawOpts, Args#args{sort_functions=Bool}); -parse([], Args) -> - {ok, Args}; -parse([Opt | _RawOpts], _Args) -> - {error, {badopt, Opt}}. - -parse_defs(Defs) -> - lists:all(fun({Key,Val}) when is_atom(Key), is_list(Val) -> true; - (_) -> false - end, - Defs). - -parse_includes(Dirs) -> - lists:all(fun(Dir) when is_list(Dir) -> true; - (_) -> false - end, - Dirs). diff --git a/lib/docbuilder/src/docb_html.erl b/lib/docbuilder/src/docb_html.erl deleted file mode 100644 index bdfc5ea876..0000000000 --- a/lib/docbuilder/src/docb_html.erl +++ /dev/null @@ -1,393 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_html). - --export([rule/2, rule/3]). - -rule([p, item, list|_], {_, _, _}) -> - {"", "<br />\n"}; -rule([p, item, taglist|_], {_, _, _}) -> - {"", "<br />\n"}; -rule([p|_], _) -> - {"\n<p>", "\n</p>"}; - -rule([pre|_], _) -> - {"\n<div class=\"example\"><pre>\n", "\n</pre></div>\n"}; - -rule([input|_], _) -> - {"<strong>", "</strong>"}; - -rule([quote|_], _) -> - {"\n<blockquote>\n", "\n</blockquote>\n"}; - -rule([i|_], _) -> - {"<em>", "</em>"}; - -rule([b|_], _) -> - {"<strong>", "</strong>"}; - -rule([c|_], _) -> - {"<span class=\"code\">", "</span>"}; - -rule([em|_], _) -> - {"<strong>", "</strong>"}; - -rule([sub|_], _) -> - {"<sub>", "</sub>"}; - -rule([sup|_], _) -> - {"<sup>", "</sup>"}; - -rule([termdef|_], _) -> - {drop, ""}; - -rule([citedef|_], _) -> - {drop, ""}; - -rule([br|_], _) -> - {"<br />\n", ""}; - -rule([digression|_], _) -> - {"<table>\n" - " <tr>\n" - " <td width=\"23\"></td>\n" - " <td>\n" - " <font size=\"-1\">\n", - " </font>\n" - " </td>\n" - " </tr>\n" - "</table>\n"}; - -rule([list, item, list|_], {_, ["ORDERED"], _}) -> - {"\n<ol>\n", "\n</ol>\n"}; -rule([list, item, taglist|_], {_, ["ORDERED"], _}) -> - {"\n<ol>\n", "\n</ol>\n"}; -rule([list|_], {_, ["ORDERED"], _}) -> - {"\n<ol>\n", "\n</ol>\n"}; -rule([list, item, list|_], {_, ["BULLETED"], _}) -> - {"\n<ul>\n", "\n</ul>\n"}; -rule([list, item, taglist|_], {_, ["BULLETED"], _}) -> - {"\n<ul>\n", "\n</ul>\n"}; -rule([list|_], {_, ["BULLETED"], _}) -> - {"\n<ul>\n", "\n</ul>\n"}; - -rule([taglist, item, taglist|_], _) -> - {"\n<dl>\n", "\n</dl>\n"}; -rule([taglist, item, list|_], _) -> - {"\n<dl>\n", "\n</dl>\n"}; -rule([taglist|_], _) -> - {"\n<dl>\n", "\n</dl>\n"}; - -rule([tag|_], _) -> - {"\n<dt>\n", "\n</dt>\n"}; - -rule([item, list|_], _) -> - {"\n<li>\n", "\n</li>\n\n"}; -rule([item, taglist|_], _) -> - {"\n<dd>\n", "\n</dd>\n"}; - -rule([image|_], {_, [File], _}) -> - File2 = - case filename:extension(File) of - [] -> File ++ ".gif"; - _ -> File - end, - {["\n<center>\n", "<img alt=\"", File2, "\" src=\"", File2, - "\"/><br/>\n"], - "\n</center>\n"}; - -rule([icaption|_], _) -> - {"<em>", "</em>\n"}; - -rule([url|_], {_, [HREF], _}) -> - URI = docb_html_util:make_uri(HREF), - {io_lib:format("<a target=\"_top\" href=\"~s\">", [URI]), "</a>"}; - -rule([marker|_], {_, [ID], _}) -> - %% remove all chars before first # including the # - {ok, NewID, _} = regexp:sub(ID, "^[^#]*#", ""), - %% replace "/" with "-" because "/" xhtml does not - %% allow "/" in the name attribute of element <a> - %% so we have to do the same as for marker i.e - %% Function/Arity is translated to an anchor in xhtml - %% like this : <a name="Function-Arity"/> - NewID2 = [case X of $/ -> $-;_->X end||X <- NewID], - {drop, ["<a name=\"", NewID2, "\"><!-- Empty --></a>"]}; - -rule([table|_], {_, ["", ""], Ts}) -> - {newargs, - "\n<center>\n" - "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n", - reorder_table(Ts), - "\n</table>\n" - "</center>\n"}; -rule([table|_], {_, [Width, ""], Ts}) -> - {newargs, - ["\n<center>\n" - "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\" ", - "width=\"", Width, "%\">\n"], - reorder_table(Ts), - "\n</table>\n" - "</center>\n"}; - -%% The clauses above are for the report DTD. This one is for the other -%% DTDs. -rule([table|_], {_, ["LEFT"], Ts}) -> - {newargs, - "\n" - "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n", - reorder_table(Ts), - "\n</table>\n"}; - -rule([table|_], {_, _, Ts}) -> - {newargs, - "\n<center>\n" - "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n", - reorder_table(Ts), - "\n</table>\n" - "</center>\n"}; - -rule([row|_], _) -> - {" <tr>\n", "\n </tr>\n"}; - -rule([cell|_], {_, ["", ""], _}) -> - {" <td>\n", "\n </td>\n"}; -rule([cell|_], {_, [Align, ""], _}) -> - {[" <td align=\"", string:to_lower(Align), "\">\n"], "\n </td>\n"}; -rule([cell|_], {_, ["", VAlign], _}) -> - {[" <td valign=\"", string:to_lower(VAlign), "\">\n"], "\n </td>\n"}; -rule([cell|_], {_, [Align, VAlign], _}) -> - {[" <td align=\"", string:to_lower(Align), "\" valign=\"", string:to_lower(VAlign), "\">\n"], - "\n </td>\n"}; - -rule([tcaption|_], _) -> - {" <caption align=\"bottom\"><em>", "</em></caption>\n"}; - -rule([codeinclude|_], {_, [File, Tag, _Type], _}) -> -%% Type can be "ERL", "C" or "NONE" - {ok,Data} = docb_html_util:code_include(File, Tag), - {drop, ["\n<div class=\"example\"><pre>\n", Data, - "\n</pre></div>\n"]}; - -rule([erleval|_], {_, [Expr], _}) -> - docb_html_util:erl_eval(Expr); - -rule([pcdata, pre|_], {_, _, Data}) -> - %% Do not remove leading spaces. - {drop, docb_html_util:pcdata_to_html(Data, false)}; - -rule([pcdata|_], {_, _, Data}) -> - {drop, docb_html_util:pcdata_to_html(Data)}. - -rule([seealso|_], {_, [Marker], _}, Opts) -> - Href = - case docb_util:html_snippet(seealso, Marker, Opts) of - "" -> - %% DocBuilder default behavior: - %% Marker is of format "Path#Fragment", both optional. - %% Translated to <A HREF="Path.html#Fragment"> - case string:chr(Marker, $#) of - 0 -> % No Fragment - Marker++".html"; - 1 -> % No Path - %% replace "/" with "-" because "/" xhtml does not - %% allow "/" in the name attribute of element <a> - %% so we have to do the same as for marker i.e - %% Function/Arity is translated to an anchor in xhtml - %% like this : <a name="Function-Arity"/> - [case X of $/ -> $-;_->X end||X <- Marker]; - _ -> - Marker1 = [case X of $/ -> $-;_->X end||X <- Marker], - case string:tokens(Marker1, "#") of - [Path] -> % # at end, remove it - Path++".html"; - [Path | Frag0] -> - Path++".html#"++ - docb_util:join(Frag0, "#") - end - end; - Href0 -> - %% User defined behavior, use result as-is - Href0 - end, - {{["<a href=\"", Href, "\">"], "</a>"}, Opts}; - -rule([warning|_], _, Opts) -> - docb_html_util:copy_pics("warning.gif", "warning.gif", Opts), - {{"\n<div class=\"warning\">\n" - "<div class=\"label\">Warning</div>\n" - "<div class=\"content\">\n", - "\n</div>" - "\n</div>\n"}, Opts}; - -rule([note|_], _, Opts) -> - docb_html_util:copy_pics("note.gif", "note.gif", Opts), - {{"\n<div class=\"note\">\n" - "<div class=\"label\">Note</div>\n" - "<div class=\"content\">", - "\n</div>" - "\n</div>\n"}, Opts}; - -rule([path|_], {_, [UNIX, Windows], [{pcdata, _, Text}]}, Opts) -> - UnixPart = - docb_util:an_option({ptype,"unix"}, Opts) and (UNIX/=""), - WinPart = - docb_util:an_option({ptype,"windows"}, Opts) and (Windows/=""), - if - UnixPart, WinPart -> - {{drop, [docb_html_util:pcdata_to_html(Text), - " <font size=\"-2\">(<code>UNIX: ", - docb_html_util:attribute_cdata_to_html(UNIX), - ", ", - "Windows: ", - docb_html_util:attribute_cdata_to_html(Windows), - "</code>)</font>"]}, - Opts}; - UnixPart -> - {{drop, [docb_html_util:pcdata_to_html(Text), - " <font size=\"-1\">(<code>UNIX: ", - docb_html_util:attribute_cdata_to_html(UNIX), - "</code>)</font>"]}, - Opts}; - WinPart -> - {{drop, [docb_html_util:pcdata_to_html(Text), - " <font size=\"-1\">(<code>Windows: ", - docb_html_util:attribute_cdata_to_html(Windows), - "</code>)</font>"]}, - Opts}; - true -> - {{drop, docb_html_util:pcdata_to_html(Text)}, Opts} - end; - -rule([term|_], {_, [ID], _}, Opts) -> - case docb_util:an_option(dict, Opts) of - false -> - case docb_util:lookup_option({defs, term}, Opts) of - false -> - {{drop, ["<em><strong>", - ID, - "</strong></em> "]}, Opts}; - TermList -> - case lists:keyfind(ID, 1, TermList) of - false -> - {{drop, ["<em><strong>", ID, - "</strong></em> "]}, - Opts}; - {ID, Name, _Description, _Resp} -> - {{drop, ["<em><strong>", Name, - "</strong></em> "]}, - Opts}; - {ID, Name, _Description} -> - {{drop, [ "<em><strong>", Name, - "</strong></em> "]}, - Opts} - end - end; - true -> - case docb_util:lookup_option({defs, term}, Opts) of - false -> - {{drop, ["<em><strong>", ID, - "</strong></em> "]}, Opts}; - TermList -> - PartApplication = - docb_util:lookup_option(part_application, Opts), - case lists:keyfind(ID, 1, TermList) of - false -> - {{drop, ["<a href=\"", PartApplication, - "_term.html#", ID, "\">", ID, - "</a> "]}, Opts}; - {ID, Name, _Description, _Resp} -> - {{drop, ["<a href=\"", PartApplication, - "_term.html#", ID, "\">", Name, - "</a> "]}, Opts}; - {ID, Name, _Description} -> - {{drop, ["<a href=\"", PartApplication, - "_term.html#", ID, "\">", Name, - "</a> "]}, Opts} - end - end - end; - -rule([cite|_], {_, [ID], _}, Opts) -> - case docb_util:an_option(dict, Opts) of - false -> - case docb_util:lookup_option({defs, cite}, Opts) of - false -> - {{drop, ["<em><strong>", ID, "</strong></em> "]}, - Opts}; - CiteList -> - case lists:keyfind(ID, 1, CiteList) of - false -> - {{drop, - ["<em><strong>", ID, "</strong></em> "]}, - Opts}; - {ID, Name, _Description, _Resp} -> - {{drop, ["<em><strong>", Name, - "</strong></em> "]}, - Opts}; - {ID, Name, _Description} -> - {{drop, ["<em><strong>", Name, - "</strong></em> "]}, - Opts} - end - end; - true -> - case docb_util:lookup_option({defs, cite}, Opts) of - false -> - {{drop, ["<em><strong>", ID, "</strong></em> "]}, - Opts}; - CiteList -> - PartApp = - docb_util:lookup_option(part_application, Opts), - case lists:keyfind(ID, 1, CiteList) of - false -> - {{drop, ["<a href=\"", PartApp, - "_cite.html#", ID, "\">", ID, - "</a> "]}, - Opts}; - {ID, Name, _Description, _Resp} -> - {{drop, ["<a href=\"", PartApp, - "_cite.html#", ID, "\">", Name, - "</a> "]}, - Opts}; - {ID, Name, _Description} -> - {{drop, ["<a href=\"", PartApp, - "_cite.html#", ID, "\">", Name, - "</a> "]}, - Opts} - end - end - end; - -rule([code|_], {_, [Type], [{pcdata, _, Code}]}, Opts) -> - case lists:member(Type, ["ERL","C","NONE"]) of - true -> - {{drop, ["\n<div class=\"example\"><pre>\n", docb_html_util:element_cdata_to_html(Code), - "\n</pre></div>\n"]}, Opts}; - false -> - exit({error,"unknown type of <code>"}) - end. - -reorder_table(TableContent) -> - reorder_table(TableContent, [], []). -reorder_table([], Caption, NewTableContent) -> - Caption ++ lists:reverse(NewTableContent); -reorder_table([{tcaption,_,_} = Caption | TableContent], _, NewTableContent) -> - reorder_table(TableContent, [Caption], NewTableContent); -reorder_table([Row | TableContent], Caption, NewTableContent) -> - reorder_table(TableContent, Caption, [Row | NewTableContent]). diff --git a/lib/docbuilder/src/docb_html_layout.erl b/lib/docbuilder/src/docb_html_layout.erl deleted file mode 100644 index dca80ac58e..0000000000 --- a/lib/docbuilder/src/docb_html_layout.erl +++ /dev/null @@ -1,380 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_html_layout). - --export([report_top/2, report_bot/1, - first_top/2, first_bot/1, - ref_top/2, ref_bot/1, - chapter_top/2, chapter_bot/1, - application_toc_top/3, application_toc_top/4, - part_toc_top/3, part_toc_top/4, part_toc_bot/0, - index_top/1, index_bot/0]). - -%% Report - -report_top(Data, Opts) -> - [Title, Prepared, _Responsible, DocNo, _Approved, _Checked, _Date, - Vsn0, _File] = Data, - html_header(Title, Opts) ++ - docb_util:html_snippet(top, Opts) ++ -"<center> -<h1>" ++ Title ++ "</h1> -<big> - " ++ DocNo ++ version(Opts, Vsn0) ++ "<br /> - " ++ Prepared ++ "<br /> -</big> -</center> -". - -report_bot(Opts) -> - docb_util:html_snippet(bottom, Opts) ++ -"</body> -</html> -". - -%% First - -first_top(Data, Opts) -> - [Title, _Prepared, _Responsible, DocNo, _Approved, _Checked, _Date, - Vsn0, _File] = Data, - html_header(Title, Opts) ++ - docb_util:html_snippet(top, Opts) ++ -"<center> -<h1>" ++ Title ++ "</h1> -<big>" ++ DocNo ++ version(Opts, Vsn0) ++ "<br /> -</big> -</center> -". - -first_bot(Opts) -> - report_bot(Opts). - -%% Reference - -ref_top(Data, Opts) -> - [Title, _Prepared, _Responsible, _DocNo, _Approved, _Checked, - _Date, _Rev, _File] = Data, - ref_html_header(Title, Opts) ++ -"<!-- refpage -->\n" ++ - docb_util:html_snippet(top, Opts) ++ -"<center> -<h1>" ++ Title ++ "</h1> -</center>". - -ref_bot(Opts) -> - docb_util:html_snippet(bottom, Opts) ++ -"</body> -</html> -". - -%% Chapter - -chapter_top(Data, Opts) -> - [Title, _Prepared, _Responsible, _DocNo, _Approved, _Checked, - _Date, _Rev, _File] = Data, - html_header(Title, Opts) ++ - docb_util:html_snippet(top, Opts). - -chapter_bot(Opts) -> - report_bot(Opts). - -%% Application ToC - -application_toc_top(Data, DocName, Opts) -> - [Title, _Prepared, _Responsible, DocNo, _Approved, _Checked, - _Date, Vsn0, _File] = Data, - html_header(Title, []) ++ -"<center> -<strong>" ++ Title ++ "</strong> -<p> -<small> - " ++ DocNo ++ version(Opts, Vsn0) ++ " -</small> -</p> -<p> -<small> - <a target=\"document\" href=\"" ++ DocName ++ "_cite.html\">Bibliography</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_term.html\">Glossary</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_index.html\">Index</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_first.html\">Cover</a>" ++ top_index(Opts) ++ -"</small> -</p> -</center> -<p> -<small> -<strong>Table of Contents</strong> -</small> -</p> -". - -application_toc_top(Data, DocName, Opts, HRefTexts) -> - [Title, _Prepared, _Responsible, DocNo, _Approved, _Checked, - _Date, Vsn0, _File] = Data, - html_header(Title, []) ++ -"<center> -<small> -" ++ - docb_util:join( - lists:map( - fun({HRef, Text}) -> - "<a target=\"_top\" href=\"" ++ HRef ++ "\">" ++ - Text ++ "</a>" - end, - HRefTexts), " | ") ++ top_index(Opts) ++ -"</small> -<p> -<strong>" ++ Title ++ "</strong> -</p> -<p> -<small>" ++ DocNo ++ version(Opts, Vsn0) ++ "<br /> -</small> -</p> -<p> -<small> - <a target=\"document\" href=\"" ++ DocName ++ "_cite.html\">Bibliography</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_term.html\">Glossary</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_index.html\">Index</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_first.html\">Cover</a> -</small> -</p> -</center> -<p> -<small> -<strong>Table of Contents</strong> -</small> -</p> -". - -%% Part ToC - -part_toc_top(Data, DocName, Opts) -> - [Title, _Prepared, _Responsible, DocNo, _Approved, _Checked, - _Date, Vsn0, _File] = Data, - html_header(Title, []) ++ -"<center> -<p> -<strong>" ++ Title ++ "</strong> -</p> -<p> -<small>" ++ DocNo ++ version(Opts, Vsn0) ++ "<br /> -</small> -</p> -<p> -<small> - <a target=\"document\" href=\"" ++ DocName ++ "_cite.html\">Bibliography</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_term.html\">Glossary</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_first.html\">Cover</a>" ++ - top_index(Opts) ++ -"</small> -</p> -</center> -<p> -<small> -<strong>Table of Contents</strong> -</small> -</p> -". - -part_toc_top(Data, DocName, Opts, HRefTexts) -> - [Title, _Prepared, _Responsible, DocNo, _Approved, _Checked, - _Date, Vsn0, _File] = Data, - html_header(Title, []) ++ -"<center> -<p> -<small> -" ++ - docb_util:join( - lists:map( - fun({HRef, Text}) -> - "<a target=\"_top\" href=\"" ++ HRef ++ "\">" ++ - Text ++ "</a>" - end, - HRefTexts), " | ") ++ top_index(Opts) ++ -"</small> -</p> -<p> -<strong>" ++ Title ++ "</strong> -</p> -<p> -<small> - " ++ DocNo ++ version(Opts, Vsn0) ++ "<br /> -</small> -</p> -<p> -<small> - <a target=\"document\" href=\"" ++ DocName ++ "_cite.html\">Bibliography</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_term.html\">Glossary</a> | - <a target=\"document\" href=\"" ++ DocName ++ "_first.html\">Cover</a> -</small> -</p> -</center> -<p> -<small> -<strong>Table of Contents</strong> -</small> -</p> -". - -part_toc_bot() -> -"</body > -</html> -". - -%% Index - -index_top(_Data) -> - ref_html_header("INDEX", []) ++ -"<h1>INDEX</h1> -<p><em>Emphasized</em> index entries refer to <em>modules</em> -and <code>Courier</code> ditos to <code>functions</code>.\n</p>\n". - -index_bot() -> - part_toc_bot(). - -%% Internal functions - -html_header(Title, Opts) -> - Vsn = docb_util:version(), -%%"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> -"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> -<!-- This document was generated using DocBuilder-" ++ Vsn ++ " --> -<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"> -<head> - <title>" ++ Title ++ "</title> - <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/> - " ++ docb_util:html_snippet(head, Opts) ++ " - <style type=\"text/css\"> -<!-- - body { font-family: Verdana, Arial, Helvetica, sans-serif } - span.bold_code { font-family: courier;font-weight: bold} - span.code { font-family: courier;font-weight: normal} - -.note, .warning { - border: solid black 1px; - margin: 1em 3em; -} - -.note .label { - background: #30d42a; - color: white; - font-weight: bold; - padding: 5px 10px; -} -.note .content { - background: #eafeea; - color: black; - line-height: 120%; - font-size: 90%; - padding: 5px 10px; -} -.warning .label { - background: #C00; - color: white; - font-weight: bold; - padding: 5px 10px; -} -.warning .content { - background: #FFF0F0; - color: black; - line-height: 120%; - font-size: 90%; - padding: 5px 10px; -} - - .example { background-color:#eeeeff } - pre { font-family: courier; font-weight: normal } - .REFBODY { margin-left: 13mm } - .REFTYPES { margin-left: 8mm } ---> - </style> -</head> -<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#FF00FF\" alink=\"#FF0000\"> -". - -ref_html_header(Title, Opts) -> - Vsn = docb_util:version(), -%%"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> -"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> -<!-- This document was generated using DocBuilder-" ++ Vsn ++ " --> -<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"> -<head> - <title>" ++ Title ++ "</title> - <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/> - " ++ docb_util:html_snippet(head, Opts) ++ " - <style type=\"text/css\"> -<!-- - body { font-family: Verdana, Arial, Helvetica, sans-serif } - span.bold_code { font-family: courier;font-weight: bold} - span.code { font-family: courier;font-weight: normal} - -.note, .warning { - border: solid black 1px; - margin: 1em 3em; -} - -.note .label { - background: #30d42a; - color: white; - font-weight: bold; - padding: 5px 10px; -} -.note .content { - background: #eafeea; - color: black; - line-height: 120%; - font-size: 90%; - padding: 5px 10px; -} -.warning .label { - background: #C00; - color: white; - font-weight: bold; - padding: 5px 10px; -} -.warning .content { - background: #FFF0F0; - color: black; - line-height: 120%; - font-size: 90%; - padding: 5px 10px; -} - - .example { background-color:#eeeeff } - pre { font-family: courier; font-weight: normal } - .REFBODY { margin-left: 13mm } - .REFTYPES { margin-left: 8mm } ---> - </style> -</head> -<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#FF00FF\" alink=\"#FF0000\"> -". - -version(Opts, Vsn0) -> - case docb_util:lookup_option(vsn, Opts, Vsn0) of - "" -> ""; - Vsn -> " Version " ++ Vsn - end. - -top_index(Opts) -> - case docb_util:lookup_option(top, Opts) of - false -> ""; - TIFile -> - " | <a target=\"_top\" href=\"" ++ TIFile ++ "\">Top</a>" - end. diff --git a/lib/docbuilder/src/docb_html_ref.erl b/lib/docbuilder/src/docb_html_ref.erl deleted file mode 100644 index c5c166f1ae..0000000000 --- a/lib/docbuilder/src/docb_html_ref.erl +++ /dev/null @@ -1,79 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_html_ref). - --export([rule/2, rule/3]). - -rule([description|_],_) -> - {"\n<h3>DESCRIPTION</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([funcs|_],_) -> - {"\n<h3>EXPORTS</h3>\n",""}; - -rule([func|_],_) -> - {"\n<p>",""}; - -rule([name, func, funcs, RefType|_], {_,_,[{pcdata,[],Name0}]}) -> - Name1 = docb_html_util:make_anchor_name_short(Name0, RefType), - {"<a name=\"" ++ Name1 ++ "\"><span class=\"bold_code\">", - "</span></a><br/>\n"}; - -rule([fsummary|_],_) -> - {drop, "\n</p>\n"}; - -rule([type|_], _) -> - {"\n<div class=\"REFBODY\"><p>Types:</p>\n <div class=\"REFTYPES\">\n<p>\n", - "\n </p> </div>\n</div>\n"}; - -rule([v|_], _) -> - {"<span class=\"bold_code\">","</span><br/>\n"}; - -rule([d|_], _) -> - {"\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([desc|_], _) -> - {"\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([authors|_], _) -> - {"\n<h3>AUTHORS</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([aname|_], _) -> - {"", " - "}; - -rule([section|_], {1,_,_}) -> - {"", ""}; -rule([section|_], {_N,_,_}) -> - {"", "\n</div>\n"}; - -rule([title|_], _) -> - {"\n<h3>", "</h3>\n<div class=\"REFBODY\">\n"}; - -rule(TagHistory, TagBody) -> - docb_html:rule(TagHistory, TagBody). - -rule([email|_], _, Opts) -> - case docb_util:html_snippet(email, Opts) of - "" -> - {{"","<br/>\n"}, Opts}; - Email -> - {{drop, Email++"<br/>\n"}, Opts} - end; - -rule(TagHistory, TagBody, Opts) -> - docb_html:rule(TagHistory, TagBody, Opts). - diff --git a/lib/docbuilder/src/docb_html_util.erl b/lib/docbuilder/src/docb_html_util.erl deleted file mode 100644 index 02ce8b52a7..0000000000 --- a/lib/docbuilder/src/docb_html_util.erl +++ /dev/null @@ -1,542 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_html_util). - --export([attribute_cdata_to_html/1, - element_cdata_to_html/1, - pcdata_to_html/1, pcdata_to_html/2]). --export([copy_pics/3]). --export([extract_header_data/2, all_header_data/1]). --export([make_uri/1, - make_anchor_href/1, make_anchor_href_short/3, - make_anchor_name_short/2, - make_funcdef_short/2]). --export([erl_include/2, code_include/2, erl_eval/1]). --export([number/3, count_sections/1]). --export([format_toc/1]). --export([html_latin1_sort_order/1]). - -%%--Handle CDATA and PCDATA--------------------------------------------- - -%% NB: Functions for transforming sgmls/XMerL data output to html. -%% Do not use these for included text files (cf code_include and -%% erl_include). - -attribute_cdata_to_html(Data) -> - data2html(Data, false). - -element_cdata_to_html(Data) -> - data2html(Data, false). - -pcdata_to_html(Data) -> - data2html(Data, true). - -pcdata_to_html(Data, RmSp) -> - data2html(Data, RmSp). - -%% PCDATA, CDATA: Replace entities, and optionally delete -%% leading and multiple spaces. CDATA never contains entities to -%% replace. - -%% data2html(Cs, RmSpace) -data2html([246| Cs], RmSp) -> - [$&, $#, $2, $4, $6, $;| data2html(Cs, RmSp)]; -data2html([$>| Cs], RmSp) -> - [$&, $#, $6, $2, $;| data2html(Cs, RmSp)]; -data2html([$<| Cs], RmSp) -> - [$&, $#, $6, $0, $;| data2html(Cs, RmSp)]; -data2html([$&| Cs], RmSp) -> - [$&, $#, $3, $8, $;| data2html(Cs, RmSp)]; -data2html([$\"| Cs], RmSp) -> - [$&, $#, $3, $4, $;| data2html(Cs, RmSp)]; -data2html([$\n| Cs], RmSp) -> - data2html(Cs, RmSp); -data2html([$\\, $n| Cs], false) -> - [$\n| data2html(Cs, false)]; -data2html([$\\, $n| Cs], true) -> - [$\n| data2html(delete_leading_space(Cs), true)]; -data2html([$ , $ | Cs], true) -> % delete multiple space - [$ | data2html(delete_leading_space(Cs), true)]; -data2html([$\\, $|| Cs0], RmSp) -> - {Ent, Cs1} = collect_entity(Cs0), - [entity_to_html(Ent)| data2html(Cs1, RmSp)]; -data2html([$\\, $0, $1, $2| Cs], RmSp) -> - data2html(Cs, RmSp); -data2html([$\\, $\\, $n| Cs], RmSp) -> - [$\\, $n| data2html(Cs, RmSp)]; -data2html([$\\, O1, O2, O3| Cs], RmSp) - when O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 -> - case octal2dec(O1, O2, O3) of - 173 -> % soft hyphen - data2html(Cs, RmSp); - C when C > 31, C < 256 -> - Ent = io_lib:format("&#~w;", [C]), - [Ent| data2html(Cs, RmSp)]; - C -> - [C| data2html(Cs, RmSp)] - end; -data2html([$\\, $\\| Cs], RmSp) -> - [$\\| data2html(Cs, RmSp)]; -data2html([C| Cs], RmSp) -> - [C| data2html(Cs, RmSp)]; -data2html([], _) -> - []. - -delete_leading_space([$ | Cs]) -> - delete_leading_space(Cs); -delete_leading_space(Cs) -> - Cs. - -collect_entity(Data) -> - collect_entity(Data, []). - -collect_entity([$\\, $|| Cs], Rs) -> - {lists:reverse(Rs), Cs}; -collect_entity([C| Cs], Rs) -> - collect_entity(Cs, [C| Rs]); -collect_entity([], Rs) -> - {[], lists:reverse(Rs)}. - -entity_to_html("&") -> "&"; -entity_to_html("\"") -> """; -entity_to_html("<") -> "<"; -entity_to_html(">") -> ">"; -entity_to_html([$\\, O1, O2, O3]) - when O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 -> - case octal2dec(O1, O2, O3) of - 173 -> % soft hyphen - ""; - Value -> - io_lib:format("&#~w;", [Value]) - end; -entity_to_html(Other) -> - docb_html_util_iso:entity_to_html(Other). - -octal2dec(O1, O2, O3) -> - (O1*8+O2)*8+O3-73*$0. - -%%--Copy images--------------------------------------------------------- - -copy_pics(Src, Dest, Opts) -> - Dir = code:lib_dir(docbuilder), - InFile = filename:join([Dir, "etc", Src]), - OutFile = docb_util:outfile(Dest, "", Opts), - case filelib:last_modified(OutFile) of - 0 -> % File doesn't exist - file:copy(InFile, OutFile); - - OutMod2 -> - InMod1s = calendar:datetime_to_gregorian_seconds( - filelib:last_modified(InFile)), - OutMod2s = calendar:datetime_to_gregorian_seconds(OutMod2), - if - InMod1s > OutMod2s -> % InFile is newer than OutFile - file:copy(InFile, OutFile); - true -> - ok - end - end. - -%%--Resolve header data------------------------------------------------- - -extract_header_data(Key, {header, [], List}) -> - case lists:keyfind(Key, 1, List) of - {Key, [], []} -> - ""; - {Key, [], [{pcdata, [], Value}]} -> - pcdata_to_html(Value); - false -> - "" - end. - -all_header_data(Header) -> - all_header_data(Header, - [title, prepared, responsible, docno, approved, - checked, date, rev, file]). - -all_header_data(_Header, []) -> - []; -all_header_data(Header, [Key| Rest]) -> - [extract_header_data(Key, Header) | all_header_data(Header, Rest)]. - -%%--Resolve hypertext references---------------------------------------- - -%% URI regular expression (RFC 2396): -%% "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" -%% We split it in five parts: -%% scheme: "^(([^:/?#]+):)?" (includes trailing `:') -%% authority: "^(//([^/?#]*))?" (includes leading `//') -%% path: "^([^?#]*)" -%% query: "^(\\?([^#]*))?" (includes leading `?') -%% fragment: "^(#(.*))?" (includes leading `#') - -make_uri(Cs) -> - lists:flatmap( - fun({path, S}) -> - case regexp:match(S, "\.xml?\$") of - {match, _, _} -> - {ok, NS, _} = regexp:sub(S, "\.xml?\$", ".html"), - NS; - _ -> - S - end; - ({_, S}) -> - S - end, - split_uri(Cs)). - -split_uri(URI) -> - split_uri(URI, [{scheme, "^(([^:/?#]+):)?"}, - {authority, "^(//([^/?#]*))?"}, - {path, "^([^?#]*)"}, - {'query', "^(\\?([^#]*))?"}, - {fragment, "^(#(.*))?"}]). - -split_uri("", [{Tag, _R}| T]) -> - [{Tag, ""}| split_uri("", T)]; -split_uri(Cs0, [{Tag, R}| T]) -> - {match, 1, N} = regexp:match(Cs0, R), - Cs1 = string:substr(Cs0, 1, N), - Cs2 = strip_and_escape_uri_component(Tag, Cs1), - [{Tag, Cs2}| split_uri(string:substr(Cs0, N+1), T)]; -split_uri(_, []) -> - []. - -strip_and_escape_uri_component(authority, "//" ++ Cs) -> - "//" ++ escape_uri(string:strip(Cs)); -strip_and_escape_uri_component(path, Cs) -> - escape_uri(string:strip(Cs)); -strip_and_escape_uri_component('query', "?" ++ Cs) -> - "?" ++ escape_uri(string:strip(Cs)); -strip_and_escape_uri_component(fragment, "#" ++ Cs) -> - "#" ++ escape_uri(string:strip(Cs)); -strip_and_escape_uri_component(_, "") -> - ""; -strip_and_escape_uri_component(_, Cs) -> - escape_uri(string:strip(Cs)). - -escape_uri([C|Cs]) when C =< 32; - C == $<; C == $<; C == $#; C == $%; C == $"; - C == $?; - C == ${; C == $}; C ==$|; C == $\\; C == $^; - C == $[; C == $]; C ==$'; - C >= 127 -> - [$%, mk_hex(C div 16), mk_hex(C rem 16)| escape_uri(Cs)]; -escape_uri([C|Cs]) -> - [C|escape_uri(Cs)]; -escape_uri([]) -> - []. - -mk_hex(C) when C<10 -> - C + $0; -mk_hex(C) -> - C - 10 + $a. - -make_anchor_href(HRef) -> - case regexp:split(HRef, "#") of - {ok, [HRef]} -> - %% No `#' in HRef, i.e. only path - make_anchor_href(HRef, ""); - {ok, [Path, Fragment]} -> - make_anchor_href(Path, Fragment) - end. - -make_anchor_href(Path0, Frag0) -> - Frag1 = string:strip(Frag0), - Path1 = case Path0 of - "" -> - ""; - _ -> - case regexp:match(Path0, "\.xml?\$") of - nomatch -> - Path0 ++ ".html"; - _ -> - {ok, NewPath, _} = regexp:sub(Path0, - "\.xml?\$", - ".html"), - NewPath - end - end, - case Frag1 of - "" -> - attribute_cdata_to_html(Path1); - _ -> - attribute_cdata_to_html(Path1) ++ - "#" ++ - attribute_cdata_to_html([case Ch of $/ -> $-; _ -> Ch end|| - Ch <-Frag1]) - end. - -make_anchor_href_short(Path, Frag, RefType) -> - ShortFrag = make_funcdef_short(Frag, RefType,"-"), - make_anchor_href(Path, ShortFrag). - -make_anchor_name_short(FuncName0, RefType) -> - FuncName1 = make_funcdef_short(FuncName0, RefType,"-"), - attribute_cdata_to_html(FuncName1). - -make_funcdef_short(FuncDef0, RefType) -> - make_funcdef_short(FuncDef0, RefType, "/"). - -make_funcdef_short(FuncDef0, RefType,Delimiter) -> - FuncDef1 = docb_util:trim(FuncDef0), - Any0 = case lists:member(RefType, [cref, erlref]) of - true -> - case catch docb_util:fknidx(FuncDef1, Delimiter) of - {'EXIT', _} -> - false; - Any1 -> - Any1 - end; - false -> - false - end, - case Any0 of - false -> - case string:tokens(FuncDef1, " ") of - [Any2| _] -> - Any2; - _ -> - FuncDef1 - end; - _ -> - Any0 - end. - -%%--Include tags-------------------------------------------------------- - -%% Only used in report DTD -erl_include(File, Tag) -> - case docb_main:include_file(File, Tag) of - {ok, Cs} -> - {drop, "\n<pre>\n" ++ text_to_html(Cs) ++ "\n</pre>\n"}; - error -> - {drop, ""} - end. - -code_include(File, Tag) -> - case docb_main:include(File, Tag, Tag) of - {ok, Cs} -> - {ok,text_to_html(Cs)}; - error -> - {error, {codeinclude,File}} - end. - -erl_eval(Expr) -> - Cs = docb_main:eval_str(Expr), - {drop, "\n<pre>\n" ++ text_to_html(Cs) ++ "\n</pre>\n"}. - -%% Only replaces certain characters. Spaces and new lines etc are kept. -%% Used for plain text (e.g. inclusions of code). -text_to_html([$>| Cs]) -> - [$&, $#, $6, $2, $;| text_to_html(Cs)]; -text_to_html([$<| Cs]) -> - [$&, $#, $6, $0, $;| text_to_html(Cs)]; -text_to_html([$&| Cs]) -> - [$&, $#, $3, $8, $;| text_to_html(Cs)]; -text_to_html([$\"| Cs]) -> - [$&, $#, $3, $4, $;| text_to_html(Cs)]; -text_to_html([C| Cs]) -> - [C| text_to_html(Cs)]; -text_to_html([]) -> - []. - -%%--Number sections----------------------------------------------------- - -number({Tag, Attrs, More}, none, File) -> - {Tag, Attrs, do_number(More, [1], File)}; -number({Tag, Attrs, More}, Prefix, File) -> - {Tag, Attrs, do_number(More, [list_to_integer(Prefix)], File)}. - -do_number([], _, _) -> - []; -do_number([{header, Attrs, More}| Rest], NN, File) -> - [{header, Attrs, More}| do_number(Rest, NN, File)]; -do_number([{section, Attrs, More}| Rest], [N| NN], File) -> - [{section, Attrs, do_number(More, [1, N| NN], File)}| - do_number(Rest, [N+1| NN], File)]; -do_number([{title, _, [{pcdata, _, Title}]}| More], [N| NN], File) -> - Format = make_format(length(NN)), - Number = lists:flatten(io_lib:format(Format, lists:reverse(NN))), - [{marker, [{"ID", "CDATA", Number}], []}, - {title, [{"NUMBER", "CDATA", Number}, - {"FILE", "CDATA", File}], - [{pcdata, [], Title}]}| do_number(More, [N| NN], File)]; -do_number([{pcdata, Attrs, More}| Rest], NN, File) -> - [{pcdata, Attrs, More}| do_number(Rest, NN, File)]; -do_number([{Tag, Attrs, More}| Rest], NN, File) -> - [{Tag, Attrs, do_number(More, NN, File)}|do_number(Rest, NN, File)]. - -make_format(1) -> - "~w"; -make_format(N) -> - "~w." ++ make_format(N-1). - -count_sections([section| Rest]) -> - 1 + count_sections(Rest); -count_sections([_| Rest]) -> - count_sections(Rest); -count_sections([]) -> - 0. - -%%--Make a ToC---------------------------------------------------------- - -format_toc(Toc) -> - [format_toc1(T) || T <- Toc]. - -format_toc1({Number, Title}) -> - [Number, " <a href = \"#", Number, "\">", Title, "</a><br/>\n"]. - -%%--Convert HTML ISO Latin 1 characters to ordinary characters---------- - -%% To be used for sorting. Cs must be flat. -html_latin1_sort_order(Cs) -> - hlso(Cs). - -hlso([]) -> - []; -hlso([$&, $#, C2, C1, C0, $;| Cs]) - when $0 =< C2, C2 =< $9, $0 =< C1, C1 =< $9, $0 =< C0, C0 =< $9 -> - C = ((C2-$0)*10 + (C1-$0))*10 + C0-$0, - hlso0(C, Cs); -hlso([$&, $#, C1, C0, $;| Cs]) - when $0 =< C1, C1 =< $9, $0 =< C0, C0 =< $9 -> - C = (C1-$0)*10 + C0-$0, - hlso0(C, Cs); -hlso([C| Cs]) -> - [C| hlso(Cs)]. - -hlso0(C, Cs) when 0 =< C, C =< 159 -> - [C| hlso(Cs)]; -hlso0(160, Cs) -> %% no-break space - hlso(Cs); % Remove it. -hlso0(161, Cs) -> %% inverted exclamation mark - [$? |hlso(Cs)]; -hlso0(162, Cs) -> %% cent sign - [$$|hlso(Cs)]; -hlso0(163, Cs) -> %% pound sterling sign - [$$|hlso(Cs)]; -hlso0(164, Cs) -> %% general currency sign - [$$|hlso(Cs)]; -hlso0(165, Cs) -> %% yen sign - [$$|hlso(Cs)]; -hlso0(166, Cs) -> %% broken (vertical) bar - [$| |hlso(Cs)]; -hlso0(167, Cs) -> %% section sign - [$$|hlso(Cs)]; -hlso0(168, Cs) -> %% umlaut (dieresis) - [$: |hlso(Cs)]; -hlso0(169, Cs) -> %% copyright sign - [$c |hlso(Cs)]; -hlso0(170, Cs) -> %% ordinal indicator, feminine - [$f |hlso(Cs)]; -hlso0(171, Cs) -> %% angle quotation mark, left - [$" |hlso(Cs)]; -hlso0(172, Cs) -> %% not sign - [$- |hlso(Cs)]; -hlso0(173, Cs) -> %% soft hyphen - [$- |hlso(Cs)]; -hlso0(174, Cs) -> %% registered sign - [$r |hlso(Cs)]; -hlso0(175, Cs) -> %% macron - [$- |hlso(Cs)]; -hlso0(176, Cs) -> %% degree sign - [$d |hlso(Cs)]; -hlso0(177, Cs) -> %% plus-or-minus sign - [$+ |hlso(Cs)]; -hlso0(178, Cs) -> %% superscript two - [$2 |hlso(Cs)]; -hlso0(179, Cs) -> %% superscript three - [$3 |hlso(Cs)]; -hlso0(180, Cs) -> %% acute accent - [$' |hlso(Cs)]; -hlso0(181, Cs) -> %% micro sign - [$' |hlso(Cs)]; -hlso0(182, Cs) -> %% pilcrow (paragraph sign) - [$$|hlso(Cs)]; -hlso0(183, Cs) -> %% middle dot - [$. |hlso(Cs)]; -hlso0(184, Cs) -> %% cedilla - [$c |hlso(Cs)]; -hlso0(185, Cs) -> %% superscript one - [$1 |hlso(Cs)]; -hlso0(186, Cs) -> %% ordinal indicator, masculine - [$m |hlso(Cs)]; -hlso0(187, Cs) -> %% angle quotation mark, right - [$" |hlso(Cs)]; -hlso0(188, Cs) -> %% fraction one-quarter - [$4 |hlso(Cs)]; -hlso0(189, Cs) -> %% fraction one-half - [$2 |hlso(Cs)]; -hlso0(190, Cs) -> %% fraction three-quarters - [$3 |hlso(Cs)]; -hlso0(191, Cs) -> %% inverted question mark - [$? |hlso(Cs)]; - -hlso0(C, Cs) when 192 =< C, C =< 198 -> %% capital A - [$A |hlso(Cs)]; -hlso0(199, Cs) -> %% capital C, cedilla - [$C |hlso(Cs)]; -hlso0(C, Cs) when 200 =< C, C =< 203 -> %% capital E - [$E |hlso(Cs)]; -hlso0(C, Cs) when 204 =< C, C =< 207 -> %% capital I - [$I |hlso(Cs)]; -hlso0(208, Cs) -> %% capital Eth, Icelandic - [$D |hlso(Cs)]; -hlso0(209, Cs) -> %% capital N, tilde - [$N |hlso(Cs)]; -hlso0(C, Cs) when 210 =< C, C =< 214 -> %% capital O - [$O |hlso(Cs)]; -hlso0(215, Cs) -> %% multiply sign - [$x |hlso(Cs)]; -hlso0(216, Cs) -> %% capital O, slash - [$O |hlso(Cs)]; -hlso0(C, Cs) when 217 =< C, C =< 220 -> %% capital U - [$U |hlso(Cs)]; -hlso0(221, Cs) -> %% capital Y, acute accent - [$Y |hlso(Cs)]; -hlso0(222, Cs) -> %% capital THORN, Icelandic - [$T |hlso(Cs)]; -hlso0(223, Cs) -> %% small sharp s, German (sz - [$s |hlso(Cs)]; -hlso0(C, Cs) when 224 =< C, C =< 230-> %% small a - [$a |hlso(Cs)]; -hlso0(231, Cs) -> %% small c, cedilla - [$c |hlso(Cs)]; -hlso0(C, Cs) when 232 =< C, C =< 235 -> %% small e - [$e |hlso(Cs)]; -hlso0(C, Cs) when 236 =< C, C =< 239 -> %% small i - [$i |hlso(Cs)]; -hlso0(240, Cs) -> %% small eth, Icelandic - [$d |hlso(Cs)]; -hlso0(241, Cs) -> %% small n, tilde - [$n |hlso(Cs)]; -hlso0(C, Cs) when 242 =< C, C =< 246 -> %% small o - [$o |hlso(Cs)]; -hlso0(247, Cs) -> %% divide sign - [$/ |hlso(Cs)]; -hlso0(248, Cs) -> %% small o, slash - [$o |hlso(Cs)]; -hlso0(C, Cs) when 249 =< C, C =< 252 -> %% small u - [$u |hlso(Cs)]; -hlso0(253, Cs) -> %% small y, acute accent - [$y |hlso(Cs)]; -hlso0(254, Cs) -> %% small thorn, Icelandic - [$t |hlso(Cs)]; -hlso0(255, Cs) -> %% small y, dieresis or umlaut - [$y |hlso(Cs)]. diff --git a/lib/docbuilder/src/docb_html_util_iso.erl b/lib/docbuilder/src/docb_html_util_iso.erl deleted file mode 100644 index c836805cd2..0000000000 --- a/lib/docbuilder/src/docb_html_util_iso.erl +++ /dev/null @@ -1,204 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_html_util_iso). --export([entity_to_html/1]). - -%% Encodes ISOtech, ISOnum and ISOgrk3. -%% -%% All entities are of the form "[abcdef]". -%% -entity_to_html(Entity) when is_list(Entity), hd(Entity) =/= $[ -> - Entity; -entity_to_html(Entity) -> - case (catch enc(Entity)) of - {'EXIT', _} -> - Entity; - Enc -> - "<font face=symbol>" ++ Enc ++ "</font>" - end. - -enc("[Delta ]") -> "D"; -%% enc("[Dot ]") -> "�"; -%% enc("[DotDot]") -> "�"; -enc("[Gamma ]") -> "G"; -enc("[Lambda]") -> "L"; -enc("[Omega ]") -> "W"; -enc("[Phi ]") -> "F"; -enc("[Pi ]") -> "P"; -enc("[Prime ]") -> "²"; -enc("[Psi ]") -> "Y"; -enc("[Sigma ]") -> "S"; -enc("[Theta ]") -> "Q"; -enc("[Upsi ]") -> "¡"; -%% enc("[Verbar]") -> "�"; -enc("[Xi ]") -> "X"; - -enc("[aleph ]") -> "À"; -enc("[alpha ]") -> "a"; -enc("[amp ]") -> "&"; -enc("[and ]") -> "Ù"; -enc("[ang ]") -> "Ð"; -%% enc("[ang90 ]") -> "�"; -%% enc("[angsph]") -> "�"; -%% enc("[angst ]") -> "�"; -enc("[ap ]") -> "»"; - -%% enc("[becaus]") -> "�"; -%% enc("[bernou]") -> "�"; -enc("[bepsi ]") -> "'"; -enc("[beta ]") -> "b"; -enc("[bottom]") -> "^"; -enc("[bull ]") -> "·"; - -enc("[cap ]") -> "Ç"; -enc("[chi ]") -> "c"; -enc("[clubs ]") -> "§"; -%% enc("[compfn]") -> "�"; -enc("[cong ]") -> "@"; -enc("[copy ]") -> "Ó"; -%% enc("[conint]") -> "�"; -enc("[cup ]") -> "È"; - -enc("[dArr ]") -> "ß"; -enc("[darr ]") -> "¯"; -enc("[deg ]") -> "°"; -enc("[delta ]") -> "d"; -enc("[diam ]") -> "à"; -enc("[diams ]") -> "¨"; -enc("[divide]") -> "¸"; - -enc("[empty ]") -> "Æ"; -%% enc("[epsi ]") -> "�"; -%% enc("[epsis ]") -> "�"; -enc("[epsiv ]") -> "e"; -enc("[equiv ]") -> "º"; -enc("[eta ]") -> "h"; -enc("[exist ]") -> "$"; - -enc("[fnof ]") -> "¦"; -enc("[forall]") -> """; - -enc("[gamma ]") -> "g"; -%% enc("[gammad]") -> "�"; -enc("[ge ]") -> "³"; -enc("[gt ]") -> ">"; - -%% enc("[hamilt]") -> "�"; -enc("[hArr ]") -> "Û"; -enc("[harr ]") -> "«"; -enc("[hearts]") -> "©"; -enc("[horbar]") -> "¾"; - -enc("[iff ]") -> "Û"; -enc("[image ]") -> "Á"; -enc("[infin ]") -> "¥"; -enc("[int ]") -> "ò"; -enc("[iota ]") -> "i"; -enc("[isin ]") -> "Î"; - -enc("[kappa ]") -> "k"; -%%enc("[kappav]") -> "�"; - -enc("[lArr ]") -> "Ü"; -%% enc("[lagran]") -> "�"; -enc("[lambda]") -> "l"; -enc("[lang ]") -> "á"; -enc("[larr ]") -> "¬"; -enc("[le ]") -> "£"; -%% enc("[lowast]") -> "�"; -enc("[lowbar]") -> "_"; -enc("[lt ]") -> "<"; - -enc("[middot]") -> "×"; -enc("[minus ]") -> "-"; -%% enc("[mnplus]") -> "�"; -enc("[mu ]") -> "m"; - -enc("[nabla ]") -> "Ñ"; -enc("[ne ]") -> "¹"; -enc("[ni ]") -> "'"; -enc("[nsub ]") -> "Ë"; -enc("[not ]") -> "Ø"; -enc("[notin ]") -> "Ï"; -enc("[nu ]") -> "n"; - -enc("[omega ]") -> "w"; -enc("[or ]") -> "Ú"; -%% enc("[order ]") -> "�"; -enc("[oplus ]") -> "Å"; -enc("[otimes]") -> "Ä"; - -%% enc("[par ]") -> "�"; -enc("[part ]") -> "¶"; -%% enc("[permil]") -> "�"; -enc("[perp ]") -> "^"; % bottom -enc("[phis ]") -> "f"; -enc("[phiv ]") -> "j"; -%% enc("[phmmat]") -> "�"; -enc("[pi ]") -> "p"; -enc("[piv ]") -> "v"; -enc("[plus ]") -> "+"; -enc("[plusmn]") -> "±"; -enc("[prime ]") -> "¢"; -enc("[prod ]") -> "Õ"; -enc("[prop ]") -> "µ"; -enc("[psi ]") -> "y"; - -enc("[radic ]") -> "Ö"; -enc("[rang ]") -> "ñ"; -enc("[rArr ]") -> "Þ"; -enc("[rarr ]") -> "®"; -enc("[real ]") -> "Â"; -enc("[reg ]") -> "Ò"; -enc("[rho ]") -> "r"; -%% enc("[rhov ]") -> "�"; - -enc("[sigma ]") -> "s"; -enc("[sigmav]") -> "V"; -enc("[sim ]") -> "~"; -%% enc("[sime ]") -> "�"; -%% enc("[square]") -> "�"; -enc("[sol ]") -> "¤"; -enc("[spades]") -> "ª"; -enc("[sub ]") -> "Ì"; -enc("[sube ]") -> "Í"; -enc("[sup ]") -> "É"; -enc("[supe ]") -> "Ê"; -enc("[sum ]") -> "å"; - -enc("[tau ]") -> "t"; -enc("[tdot ]") -> "¼"; -enc("[there4]") -> "\"; -enc("[thetas]") -> "q"; -enc("[thetav]") -> "J"; -enc("[times ]") -> "´"; -%% enc("[tprime]") -> "�"; -enc("[trade ]") -> "Ô"; - -enc("[uArr ]") -> "Ý"; -enc("[uarr ]") -> "­"; -enc("[upsi ]") -> "u"; - -enc("[verbar]") -> "½"; - -%% enc("[wedgeq]") -> "�"; -enc("[weierp]") -> "Ã"; - -enc("[xi ]") -> "x"; - -enc("[zeta ]") -> "z". diff --git a/lib/docbuilder/src/docb_main.erl b/lib/docbuilder/src/docb_main.erl deleted file mode 100644 index c20cfc8e67..0000000000 --- a/lib/docbuilder/src/docb_main.erl +++ /dev/null @@ -1,657 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_main). - --export([process/2, - parse/2, parse1/2, - pp/2, - insert_after/3, - transform/5, pp/5, - include_file/2, include/3, - eval_str/1, - validate_html/1 - ]). --export([do_parse_sgmls/1]). - -%%---------------------------------------------------------------------- - -%% process(File, Opts) -> errors | ok -%% Parses the source file File and transforms the result to html, -%% latex and/or man page format. -process(File, Opts) -> - - SrcType = docb_util:lookup_option(src_type, Opts), - - File1 = - case SrcType of - ".xml" -> - FileTmp = File ++ ".tmpconv", - os:cmd("sed -e 's/xi:include[ \t]*href/include file/g' -e 's/xmlns:xi=\"http:\\/\\/www.w3.org\\/2001\\/XInclude\"//g' < " ++ - File ++ ".xml > " ++ FileTmp ++ ".xml"), - FileTmp; - ".sgml" -> - File - end, - - case parse1(File1, Opts) of - errors -> - delete_tmp_file(SrcType, File1), - errors; - {ok, Tree} -> - From = element(1, Tree), - Tos0 = - lists:foldl( - fun(latex, Acc) -> [latex|Acc]; - (html, Acc) -> [html|Acc]; - ({man, _Section}, Acc) -> [man|Acc]; - (_, Acc) -> Acc - end, [], Opts), - - %% If no target format is specified, assume HTML: - Tos = if - Tos0 =:= [] -> [html]; - true -> Tos0 - end, - - Result = [transform(From, To, Opts, File, Tree)||To <- Tos], - case lists:member(transformation_error,Result) of - true -> - delete_tmp_file(SrcType, File1), - errors; - _ -> - delete_tmp_file(SrcType, File1), - ok - end - - end. - - -delete_tmp_file(".xml", File) -> - file:delete(File ++ ".xml"); -delete_tmp_file(_, _) -> - ok. - -%%---------------------------------------------------------------------- - -%% parse(File, Opts) -> {ok, Tree} | errors -%% Parses the source file File, resulting in a tree structure. -parse(File, Opts) -> - case docb_util:lookup_option(src_type, Opts) of - ".xml" -> - parse_xml(File++".xml", Opts); - ".sgml" -> - parse_sgml(File, Opts) - end. - -%% parse1(File, Opts) -> {ok, Tree} | errors -%% Like parse/2, but in the SGML case also prints the parse errors -%% (in File.html.sgmls_errs) information to stdout. -parse1(File, Opts) -> - parse(File, [{print_parse_errs, true}|Opts]). - - -validate_html(InFile) -> - ScanOpts = [{validation,true}, {fetch_fun, fun fetch_dtd/2}], - case xmerl_scan:file(InFile, ScanOpts) of - {_XMLTuple,[]} -> % ok - {InFile,ok}; - {'EXIT',Reason} -> - {InFile,Reason} - end. - -fetch_dtd({public,_,"http://www.w3.org/TR/xhtml1/DTD/"++ Rest},GlobalState) -> - Filename = filename:join(docb_util:dtd_dir(),Rest), - {ok,{file,Filename},GlobalState}; -fetch_dtd({public,_,Str},GlobalState) -> - {ok,{file,filename:join(docb_util:dtd_dir(),Str)},GlobalState}. - - - -parse_xml(InFile, Opts) -> - DtdDir = docb_util:dtd_dir(), - ScanOpts = [{validation,true}, {fetch_path, [DtdDir]}], - PrintP = docb_util:lookup_option(print_parse_errs, Opts), - case catch xmerl_scan:file(InFile, ScanOpts) of - {'EXIT', Error} when PrintP -> - docb_util:message(error, - "XML validation error:~n~p", [Error]), - errors; - {'EXIT', _Error} -> - errors; - {error, Reason} -> % probably file error - docb_util:message(error, "XML scan error: ~p", [Reason]), - errors; - {Doc, []} -> - case catch xmerl:export([Doc], docb_xmerl_tree_cb) of - [Tree] -> - verify(Tree), - {ok, Tree}; - {'EXIT', Error} -> - docb_util:message(error, - "XML export error:~n~p", [Error]), - errors - end - end. - -parse_sgml(InFile, Opts) -> - - Pfx = tmp_file_prefix(InFile, Opts), - OutFile = Pfx ++ "sgmls_output", - ErrFile = Pfx ++ "sgmls_errs", - - EntVals = lists:usort(docb_util:lookup_options(ent, Opts)), - Ents = lists:flatten([" -ent " ++ Val || Val <- EntVals]), - Cmd = docb_util:old_docb_dir() ++ "/bin/docb_sgmls_run " ++ - Ents ++ " " ++ InFile ++ ".sgml " ++ OutFile ++ " " ++ ErrFile, - - case os:cmd(Cmd) of - [] -> - PrintP = docb_util:lookup_option(print_parse_errs, Opts), - case filelib:file_size(ErrFile) of - 0 -> % implies no errors - parse_sgmls(InFile, OutFile); - _ when PrintP -> - cat(ErrFile), - errors; - _ -> - errors - end; - Msg -> - docb_util:message(error, "~p", [Msg]), - errors - end. - -tmp_file_prefix(File, Opts) -> - lists:concat( - [File, "." | lists:foldl( - fun(latex, Acc) -> ["latex."|Acc]; - (html, Acc) -> ["html."|Acc]; - ({man, Section}, Acc) -> ["man", Section, "."|Acc]; - (_, Acc) -> Acc - end, [], Opts)]). - -parse_sgmls(InFile, SgmlsFile) -> - case file:open(SgmlsFile, [read]) of - {ok, Fd} -> - Res = case (catch do_parse_sgmls(Fd)) of - {ok, Tree} -> - {ok, Tree}; - {'EXIT', Reason} -> - docb_util:message( - error, - "Cannot parse sgmls output file " - "~s, obtained from parsing ~s, " - "reason: ~w", - [SgmlsFile, InFile, Reason]), - errors; - {error, Reason} -> - docb_util:message( - error, - "Cannot parse sgmls output file " - "~s, obtained from parsing ~s, " - "reason: ~w", - [SgmlsFile, InFile, Reason]), - errors - end, - file:close(Fd), - case Res of - {ok, Tree0} -> - verify(Tree0), - {ok, Tree0}; - _Other -> - errors - end; - {error, Reason} -> - docb_util:message(error, - "Cannot open sgmls output file ~s, " - "obtained from parsing ~s, reason: ~w", - [SgmlsFile, InFile, Reason]), - errors - end. - -do_parse_sgmls(Fd) -> - do_parse_sgmls(Fd, []). - -do_parse_sgmls(Fd, Attrs) -> - case get_line(Fd) of - {attrs, A} -> - do_parse_sgmls(Fd, [A|Attrs]); - {startTag, Tag} -> - {ok, {Tag, Attrs, get_args(Fd)}}; - Other -> - {error, Other} - end. - -get_args(Fd) -> - case get_line(Fd) of - {startTag, Tag} -> - H = {Tag, [], get_args(Fd)}, - [H|get_args(Fd)]; - {dataTag, Str} -> - [{pcdata, [], Str}|get_args(Fd)]; - {attrs, A} -> - get_args_attr(Fd, [A]); - close -> - []; - ok -> - [] - end. - -get_args_attr(Fd, Attrs) -> - case get_line(Fd) of - {startTag, Tag} -> - H = {Tag, lists:reverse(Attrs), get_args(Fd)}, - [H|get_args(Fd)]; - {dataTag, Str} -> - [{pcdata, lists:reverse(Attrs), Str}|get_args(Fd)]; - {attrs, A} -> - get_args_attr(Fd, [A|Attrs]); - close -> - []; - ok -> - [] - end. - -get_line(Fd) -> - Str = io:get_line(Fd, ''), - case Str of - [$(|T] -> - {startTag, tag_name(T)}; - [$-|T] -> - {dataTag, T}; - [$)|_T] -> - close; - [$A|T] -> - {attrs, attrs(remove_nl(T))}; - [$?|_T] -> - get_line(Fd); - [$C|_] -> - ok - end. - -remove_nl([$\n|_]) -> []; -remove_nl([H|T]) -> [H|remove_nl(T)]; -remove_nl([]) -> []. - -%% attrs -%% splits a string like -%% AAAAA BBBBB ...... -%% into {"AAA", "BBB", Rest} - -attrs(T) -> - {X, T1} = get_item(T), - {Y, T2} = get_item(T1), - T3 = skip_blanks(T2), - {X, Y, T3}. - -get_item(T) -> get_item(skip_blanks(T), []). - -get_item([$ |T], L) -> {lists:reverse(L), [$ |T]}; -get_item([H|T], L) -> get_item(T, [H|L]); -get_item([], L) -> {lists:reverse(L), []}. - -skip_blanks([$ |T]) -> skip_blanks(T); -skip_blanks(T) -> T. - -tag_name(Str) -> tag_name(Str, []). - -tag_name([H|T], L) when $A =< H, H =< $Z -> - tag_name(T, [H-$A+$a|L]); -tag_name([$\n], L) -> - list_to_atom(lists:reverse(L)); -tag_name([H|T], L) -> - tag_name(T, [H|L]). - -cat(File) -> - case file:open(File, [read]) of - {ok, Fd} -> - cat1(Fd), - file:close(Fd); - Other -> - Other - end. - -cat1(Fd) -> - case io:get_line(Fd, '') of - eof -> - eof; - Str -> - io:format("~s", [Str]), - cat1(Fd) - end. - -%%---------------------------------------------------------------------- - -verify(Tree) -> verify(Tree, [], 1). - -verify({pcdata, Optional, _}, Path, Level) -> - verify_optional(Optional, Path, Level); -verify({Tag, Optional, Args}, Path, Level) when is_list(Args) -> - verify_optional(Optional, Path, Level) - andalso verify_list(Args, [Tag|Path], Level); -verify(Other, Path, Level) -> - verify_error(Other, Path, Level). - -verify_error(X, Path, Level) -> - docb_util:message(error, "Invalid object found at: ~p level:~w~n~s", - [Path, Level, docb_pretty_format:term(X)]), - false. - -verify_list([H|T], Path, Level) -> - verify(H, Path, Level) andalso verify_list(T, Path, Level + 1); -verify_list([], _, _) -> - true. - -verify_optional([{_, _, _}|T], Path, Level) -> - verify_optional(T, Path, Level); -verify_optional([], _Path, _Level) -> - true; -verify_optional(X, Path, Level) -> - verify_error(X, Path, Level). - -%%---------------------------------------------------------------------- - -%% pp(File, Opts) -> {ok, OutFile} | errors -%% Parses the source file and, if successful, prints the resulting tree -%% structure to a file with the extension ".pp". -pp(File, Opts) -> - case parse(File, Opts) of - {ok, Tree} -> - OutFile = File ++ ".pp", - dump(OutFile, Tree), - {ok, OutFile}; - errors -> - errors - end. - -dump(File, Struct) -> - {ok, Stream} = file:open(File, [write]), - io:format("Info: Dump on ~p ...", [File]), - io:format(Stream, "~n~s~n", [docb_pretty_format:term(Struct)]), - io:format(" done.\n"), - file:close(Stream). - -%%---------------------------------------------------------------------- - -%% insert_after(Tag, Tree, Obj) -> Tree | {'EXIT', Reason} -%% Insert an element in a tree structure -insert_after(Tag, Tree, Obj) -> - edit(Tag, Tree, {insert_after, Obj}). - -%% edit Op = delete, insert_before, insert_after -edit(Tag, Tree, Op) -> - case catch edit1(Tag, Tree, Op) of - error -> - docb_util:message(error, "Cannot do ~p to ~w", [Op, Tag]), - Tree; - Other -> - Other - end. - -edit1(Tag, {Tag, _O, _A}, _Op) -> - throw(error); -edit1(Tag, {Tag1, O, A}, Op) -> - {Tag1, O, edit1_list(Tag, A, Op)}; -edit1(_, _, _) -> - throw(error). - -edit1_list(Tag, [{pcdata, Str}|T], Op) -> - [{pcdata, Str}|edit1_list(Tag, T, Op)]; -edit1_list(Tag, [{Tag, O, A}|T], {insert_after, Obj}) -> - [{Tag, O, A}, Obj|T]; -edit1_list(Tag, [H|T], Op) -> - [H|edit1_list(Tag, T, Op)]; -edit1_list(_Tag, [], _Op) -> - []. - -%%______________________________________________________________________ - -%% transform(From, To, Opts, File, Tree) -> void() -%% Actual transformation of tree structure to desired format. -transform(From, To, Opts, File, Tree) -> - Filter = if - To =:= html; To =:= kwic -> - list_to_atom("docb_tr_" ++ atom_to_list(From) ++ - [$2|atom_to_list(To)]); - true -> - list_to_atom("sgml_tr_" ++ atom_to_list(From) ++ - [$2|atom_to_list(To)]) - end, - - case catch Filter:transform(File, Tree, Opts) of - - %% R5C - {'EXIT', {undef, [{Filter, transform, [File, Tree, Opts],_}|_]}}-> - %% No transformation defined - finish_transform(Tree, File, Opts, Filter); - - {'EXIT', {undef, {Filter, transform, [File, Tree, Opts],_}}} -> - %% No transformation defined - finish_transform(Tree, File, Opts, Filter); - - {'EXIT', What} -> - docb_util:message(error, - "Transformation trouble in ~P", [What, 9]), - transformation_error; - - {error, Reason} -> - docb_util:message(error, Reason), - transformation_error; - - {Tree1, Opts1} -> - %% transformation returning both new parse and new options - finish_transform(Tree1, File, Opts1, Filter); - - Tree1 -> - %% transformation returning only new parse - finish_transform(Tree1, File, Opts, Filter) - end. - -finish_transform(Tree, File, Opts, Filter) -> - {Str, NewOpts} = pp(Tree, [], 1, Filter, Opts), - Extension = - case catch Filter:extension(NewOpts) of - {'EXIT', _} -> - Filter:extension(); - Others -> - Others - end, - {ok, Out} = - file:open(docb_util:outfile(File, Extension, NewOpts), [write]), - put_chars(Out, Str), - file:close(Out). - -put_chars(Out, Str) -> put_chars(Out, Str, 0). - -put_chars(Out, [$\n|Cs], _Pos) -> - io:put_chars(Out, [$\n]), - put_chars(Out, Cs, 0); - -put_chars(Out, [$\011|Cs], Pos) -> % tab - TabbedPos = 8*((Pos div 8)+1), - Nblanks = TabbedPos - Pos, - io:put_chars(Out, lists:duplicate(Nblanks, $ )), - put_chars(Out, Cs, Pos+Nblanks); - -put_chars(Out, [C|Cs], Pos) when is_integer(C) -> - io:put_chars(Out, [C]), - put_chars(Out, Cs, Pos+1); - -put_chars(Out, [L|Cs], Pos) when is_list(L) -> - put_chars(Out, Cs, put_chars(Out, L, Pos)); - -put_chars(_Out, [], Pos) -> - Pos. - -pp({Tag, Optional, Args}, TagPath, Level, Filter, Opts) -> - TagPath1 = [Tag|TagPath], - Optional1 = reduce_optional(Optional), - - %% First try Filter:rule/3. It returns {Return, NewOpts} - %% where Return is as from rule/2: - Rule_3_result = - case catch Filter:rule(TagPath1, {Level,Optional1,Args},Opts) of - %% R5C - {'EXIT', {undef, [{_, rule, _, _}|_]}} -> % No rule/3 defined - failed; - - {'EXIT', {undef, {_, rule, _, _}}} -> % No rule/3 defined - failed; - %% R5C - {'EXIT', {function_clause, [{_, rule, _, _}|_]}} -> % No MATCHING rule/3 - failed; - - {'EXIT', {function_clause, {_, rule, _, _}}} -> % No MATCHING rule/3 - failed; - - {'EXIT', What} -> - docb_util:message(error, - "Serious Error: ~P", [What, 9]); - Others -> - Others - end, - handle_rule_call_result({r3, Rule_3_result}, Filter, TagPath1, Tag, - Level, Optional1, Args, Opts). - -handle_rule_call_result({r3, failed}, Filter, TagPath1, Tag, Level, Optional1, - Args, Opts) -> - %% Hmmm, try Filter:rule/2 - Rule_2_result = (catch Filter:rule(TagPath1, {Level, Optional1, Args})), - handle_rule_call_result({r2, Rule_2_result}, Filter, TagPath1, Tag, - Level, Optional1, Args, Opts); -handle_rule_call_result({r3, {Result, NewOpts}}, Filter, TagPath1, Tag, Level, - Optional1, Args, _Opts) -> - handle_rule_call_result({r2, Result}, Filter, TagPath1, Tag, Level, - Optional1, Args, NewOpts); -handle_rule_call_result({_, {func, F}}, _Filter, _TagPath1, _Tag, _Level, - _Optional1, Args, Opts) -> - {F(Args), Opts}; -handle_rule_call_result({_, {'EXIT', Why}}, _Filter, TagPath1, _Tag, Level, - Optional1, Args, Opts) -> - report_error(TagPath1, Why, {Level, Optional1, Args}), - {[], Opts}; -handle_rule_call_result({_, {drop, Str}}, _Filter, _TagPath1, _Tag, _Level, - _Optional1, _Args, Opts) -> - {[Str], Opts}; -handle_rule_call_result({_, {newargs, NewArgs}}, Filter, TagPath1, _Tag, _Level, - _Optional1, _Args, Opts) -> - {List, NewOpts} = pp_list(NewArgs, TagPath1, 1, Filter, Opts), - {[List], NewOpts}; -handle_rule_call_result({_, {newargs, Before, NewArgs, After}}, Filter, TagPath1, _Tag, _Level, - _Optional1, _Args, Opts) -> - {List, NewOpts} = pp_list(NewArgs, TagPath1, 1, Filter, Opts), - {[Before, List, After], NewOpts}; -handle_rule_call_result({_, {Before, After}}, Filter, TagPath1, _Tag, _Level, - _Optional1, Args, Opts) when is_list(Before) -> - {List, NewOpts} = pp_list(Args, TagPath1, 1, Filter, Opts), - {[Before, List, After], NewOpts}. - -pp_list([H|T], TagPath, Level, Rules, Opts) -> - {Hpp, Hopts} = pp(H, TagPath, Level, Rules, Opts), - {Tpp, Tops} = pp_list(T, TagPath, Level + 1, Rules, Hopts), - {[Hpp|Tpp], Tops}; -pp_list([], _, _, _, Opts) -> - {[], Opts}. - -reduce_optional([{_, _, H}|T]) -> [H|reduce_optional(T)]; -reduce_optional([]) -> []. - -report_error(Arg1, Cause, Arg2) -> - [Tag|_] = Arg1, - docb_util:message(error, - "Formatting trouble in ~p: ~p", [Tag, Cause]), - docb_util:message(error, "Failure in rule(~p, ~p)", [Arg1, Arg2]). - -%%---------------------------------------------------------------------- - -%% include_file(File, Tag) -> {ok, String} | error -include_file(File, Tag) -> - include(File, "%S" ++ Tag, "%E" ++ Tag). - -%% include(File, StartTag, StopTag) -> {ok, String} | error -include(File, "", "") -> - case file:open(File, [read]) of - {ok, Fd} -> - String = include_all(Fd), - file:close(Fd), - {ok, String}; - _ -> - docb_util:message(error, - "Include file ~s not found", [File]), - error - end; -include(File, StartTag, StopTag) -> - case file:open(File, [read]) of - {ok, Fd} -> - String = extract(File, Fd, StartTag, StopTag, searching), - file:close(Fd), - {ok, lists:flatten(String)}; - _ -> - docb_util:message(error, - "Include file ~s not found", [File]), - error - end. - -include_all(Fd) -> - case io:get_line(Fd, '') of - eof -> - []; - ListOfChars -> - ListOfChars ++ include_all(Fd) - end. - -extract(File, Fd, StartTag, StopTag, State) -> - Line=io:get_line(Fd, ''), - extract(File, Fd, StartTag, StopTag, State, Line). - -extract(File, _, _, _, _, eof) -> - docb_util:message(error, - "Premature end of file in include file ~p", - [File]), - []; -extract(File, Fd, StartTag, StopTag, searching, Line) -> - case regexp:match(Line, "^" ++ StartTag) of - {match, _Start, _Length} -> - extract(File, Fd, StartTag, StopTag, copying); - nomatch -> - extract(File, Fd, StartTag, StopTag, searching); - {error, _Error} -> - docb_util:message(error, "Bad syntax in ~s", [File]), - [] - end; -extract(File, Fd, StartTag, StopTag, copying, Line) -> - case regexp:match(Line, "^" ++ StopTag) of - {match, _Start, _Length} -> - []; - nomatch -> - [Line|extract(File, Fd, StartTag, StopTag, copying)]; - {error, _Error} -> - docb_util:message(error, "Bad syntax in ~s", [File]), - [] - end. - -%%---------------------------------------------------------------------- - -eval_str(Str) -> - case lib:eval_str(Str) of - {error, Report} -> - docb_util:message(error, - "ErlEval failed: ~s (~s)", [Str, Report]); - {ok, S} -> - io_lib:format("~p~n", [S]) - end. diff --git a/lib/docbuilder/src/docb_pretty_format.erl b/lib/docbuilder/src/docb_pretty_format.erl deleted file mode 100644 index 25dcd8987b..0000000000 --- a/lib/docbuilder/src/docb_pretty_format.erl +++ /dev/null @@ -1,177 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_pretty_format). - --export([term/1]). - -%% pretty_format:term(Term) -> PNF list of characters -%% -%% Note: this is usually used in expressions like: -%% io:format('~s\n', [pretty_format:term(Term)]). -%% -%% Uses the following simple heuristics: -%% -%% 1) Simple tuples are printed across the page. -%% (Simple means *all* the elements are "flat") -%% 2) The complex tuple {Arg1, Arg2, Arg3,....} is printed thus: -%% {Arg1, -%% Arg2, -%% Arg3, -%% ...} -%% 3) Lists are treated as for tuples. -%% 4) Lists of printable characters are treated as strings. -%% -%% This method seems to work reasonable well for {Tag, ...} type -%% data structures. -term(Term) -> - element(2, term(Term, 0)). - -%% pretty_format:term(Term, Indent} -> {Indent', Chars} -%% Format <Term> -- use <Indent> to indent the *next* line. -%% Note: Indent' is a new indentaion level (sometimes printing <Term> -%% the next line to need an "extra" indent!). -term([], Indent) -> - {Indent, [$[,$]]}; -term(L, Indent) when is_list(L) -> - case is_string(L) of - true -> - {Indent, io_lib:write_string(L)}; - false -> - case complex_list(L) of - true -> - write_complex_list(L, Indent); - false -> - write_simple_list(L, Indent) - end - end; -term(T, Indent) when is_tuple(T) -> - case complex_tuple(T) of - true -> - write_complex_tuple(T, Indent); - false -> - write_simple_tuple(T, Indent) - end; -term(A, Indent) -> - {Indent, io_lib:write(A)}. - -%% write_simple_list([H|T], Indent) -> {Indent', Chars} -write_simple_list([H|T], Indent) -> - {_, S1} = term(H, Indent), - {_, S2} = write_simple_list_tail(T, Indent), - {Indent, [$[,S1|S2]}. - -write_simple_list_tail([H|T], Indent) -> - {_, S1} = term(H, Indent), - {_, S2} = write_simple_list_tail(T, Indent), - {Indent, [$,,S1| S2]}; -write_simple_list_tail([], Indent) -> - {Indent, "]"}; -write_simple_list_tail(Other, Indent) -> - {_, S} = term(Other, Indent), - {Indent, [$|,S,$]]}. - -%% write_complex_list([H|T], Indent) -> {Indent', Chars} -write_complex_list([H|T], Indent) -> - {I1, S1} = term(H, Indent+1), - {_, S2} = write_complex_list_tail(T, I1), - {Indent, [$[,S1|S2]}. - -write_complex_list_tail([H|T], Indent) -> - {I1, S1} = term(H, Indent), - {_, S2} = write_complex_list_tail(T, I1), - {Indent, [$,,nl_indent(Indent),S1,S2]}; -write_complex_list_tail([], Indent) -> - {Indent, "]"}; -write_complex_list_tail(Other, Indent) -> - {_, S} = term(Other, Indent), - {Indent, [$|,S,$]]}. - -%% complex_list(List) -> true | false -%% Returns true if the list is complex otherwise false. -complex_list([]) -> - false; -complex_list([H|T]) when is_list(H) -> - case is_string(H) of - true -> - complex_list(T); - false -> - true - end; -complex_list([H|_]) when is_tuple(H) -> true; -complex_list(_) -> false. - -%% complex_tuple(Tuple) -> true | false -%% Returns true if the tuple is complex otherwise false. -complex_tuple(T) -> - complex_list(tuple_to_list(T)). - -%% write_simple_tuple(Tuple, Indent} -> {Indent', Chars} -write_simple_tuple({}, Indent) -> - {Indent, "{}"}; -write_simple_tuple(Tuple, Indent) -> - {_, S} = write_simple_tuple_args(tuple_to_list(Tuple), Indent), - {Indent, [${, S, $}]}. - -write_simple_tuple_args([X], Indent) -> - term(X, Indent); -write_simple_tuple_args([H|T], Indent) -> - {_, SH} = term(H, Indent), - {_, ST} = write_simple_tuple_args(T, Indent), - {Indent, [SH, $,, ST]}. - -%% write_complex_tuple(Tuple, Indent} -> {Indent', Chars} -write_complex_tuple(Tuple, Indent) -> - [H|T] = tuple_to_list(Tuple), - {I1, SH} = term(H, Indent+2), - {_, ST} = write_complex_tuple_args(T, I1), - {Indent, [${, SH, ST, $}]}. - -write_complex_tuple_args([X], Indent) -> - {_, S} = term(X, Indent), - {Indent, [$,, nl_indent(Indent), S]}; -write_complex_tuple_args([H|T], Indent) -> - {I1, SH} = term(H, Indent), - {_, ST} = write_complex_tuple_args(T, I1), - {Indent, [$,, nl_indent(Indent) , SH, ST]}; -write_complex_tuple_args([], Indent) -> - {Indent, []}. - -%% utilities - -nl_indent(I) when I >= 0 -> - ["\n"|indent(I)]; -nl_indent(_I) -> - [$ ]. - -indent(I) when I >= 8 -> - [$\t|indent(I-8)]; -indent(I) when I > 0 -> - [$ |indent(I-1)]; -indent(_) -> - []. - -is_string([9|T]) -> - is_string(T); -is_string([10|T]) -> - is_string(T); -is_string([H|T]) when H >31, H < 127 -> - is_string(T); -is_string([]) -> - true; -is_string(_) -> - false. diff --git a/lib/docbuilder/src/docb_tr_application2html.erl b/lib/docbuilder/src/docb_tr_application2html.erl deleted file mode 100644 index d8cb214d0a..0000000000 --- a/lib/docbuilder/src/docb_tr_application2html.erl +++ /dev/null @@ -1,286 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_application2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(File, {application, _Attrs, [Header|Rest]}, Opts0) -> - - %% Extract header data - Title = docb_html_util:extract_header_data(title, Header), - - case docb_util:an_option(kwicindex_only, Opts0) of - false -> - - %% Create the framing HTML document - OutFile = docb_util:outfile(File++"_frame", ".html", Opts0), - case file:open(OutFile, [write]) of - {ok, Fd} -> - io:format(Fd, -"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" -\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\"> -<!-- This document was generated using DocBuilder-" ++ docb_util:version() ++ " --> -<html> -<head> - <title>~s</title> - " ++ docb_util:html_snippet(head, Opts0) ++ " -</head> -<frameset cols=\"150, *\"> - <frame src=\"~s\" name=\"toc\"> - <frame src=\"~s\" name=\"document\"> - <noframes> - <body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" - vlink=\"#FF00FF\" alink=\"#FF0000\"> - <p>This documentation requires a browser that can handle frames</p> - </body> - </noframes> -</frameset> -</html> -", - [Title, - File++".html", File++"_first.html"]), - file:close(Fd) - end, - - %% Create the front HTML document - docb_main:transform(first, html, Opts0, File ++ "_first", - {first, [], [Header|Rest]}); - - true -> - ok - end, - - %% Extract files to include - Files = case Rest of - [{description, _, _}|NewRest] -> - lists:map(fun({include, [{_, _, F}], _}) ->filename:rootname(F) end, - NewRest); - [{include, _, _}|_NewRest] -> - lists:map(fun({include, [{_, _, F}], _}) -> filename:rootname(F) end, - Rest) - end, - - %% Concat all reference manuals into a *big* parse tree - ConcatTree = concat_files(Files, Opts0), - - %% Create the kwic index src file to be put in outdir - docb_main:transform(refs, kwic, Opts0, File, {refs,[],ConcatTree}), - - case docb_util:an_option(kwicindex_only, Opts0) of - false -> - - %% Create an index - docb_main:transform(index, html, Opts0, File ++ "_index", - {index, [], [Header|ConcatTree]}), - %% Create a cite dictionary - docb_main:transform(cite, html, Opts0, File ++ "_cite", - {cite, [], [Header|ConcatTree]}), - - %% Create a term dictionary - docb_main:transform(term, html, Opts0, File ++ "_term", - {term, [], [Header|ConcatTree]}), - - %% Transform each reference page - case docb_util:an_option(framework_only, Opts0) of - true -> - ok; - false -> - transform_refs(Files, - [dict,{part_application,File}|Opts0]) - end; - true -> - ok - end, - - %% Find all fascicules to be put in the top menu of the table of - %% contents - Ext = docb_util:lookup_option(src_type, Opts0), - Opts2 = - case filelib:is_regular("fascicules"++Ext) of - true -> - case docb_main:parse1("fascicules", Opts0) of - {ok, Parse} -> - FascData = get_fasc_data(Parse), - case lists:keyfind(File, 1, FascData) of - {_, _, "YES", _} -> - OrigFile = - docb_util:outfile(File++"_frame", - ".html", Opts0), - EntryFile = - docb_util:outfile("index", - ".html",Opts0), - docb_util:message(info, - "Copying ~s to ~s", - [OrigFile,EntryFile]), - file:copy(OrigFile, EntryFile); - _ -> - ok - end, - [{fascdata, FascData}| Opts0]; - errors -> - %% Do not bother - docb_util:message( - warning, - "fascicules~s could not be parsed," - " no index.html created", - [Ext]), - Opts0 - end; - false -> - %% do not bother - docb_util:message(warning, - "fascicules~s not found, " - "no index.html created", - [Ext]), - Opts0 - end, - - %% Create ToC parse tree - {{toc, [{"FILE", "CDATA", File}], [Header|make_toc(ConcatTree)]}, - Opts2}. - -concat_files(Files, Opts) -> - concat_files(Files, [], Opts). - -concat_files([File|Rest], Body, Opts) -> - case docb_main:parse1(File, Opts) of - {ok, Parse} -> - NewParse=expand([Parse], File), - %% Remove the reference manual header - [{Ref, [], [_Hdr| NewBody]}] = NewParse, - RefParse = [{Ref, [], NewBody}], - Body ++ concat_files(Rest, RefParse, Opts); - errors -> - errors - end; -concat_files([], Body, _Opts) -> - Body. - -expand([], _) -> - []; -expand([{pcdata, Attrs, More}|Rest], File) -> - [{pcdata, Attrs, More}|expand(Rest, File)]; -expand([{name, Attrs, More}|Rest], File) -> - [{name, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest, File)]; -expand([{module, Attrs, More}|Rest], File) -> - [{module, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest,File)]; -expand([{file, Attrs, More}|Rest], File) -> - [{file, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest, File)]; -expand([{app, Attrs, More}|Rest], File) -> - [{app, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest, File)]; -expand([{lib, Attrs, More}|Rest], File) -> - [{lib, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest, File)]; -expand([{com, Attrs, More}|Rest], File) -> - [{com, [{"FILE", "CDATA", File}|Attrs], More}|expand(Rest, File)]; -expand([{Tag, Attrs, More}|Rest], File) -> - [{Tag, Attrs, expand(More, File)}|expand(Rest, File)]. - -transform_refs([], _) -> - ok; -transform_refs([File|Rest], Opts) -> - Ext = docb_util:lookup_option(src_type, Opts), - docb_util:message(info, "Processing \"~s~s\"", [File, Ext]), - docb_main:process(File, Opts), - transform_refs(Rest, Opts). - -make_toc([]) -> - []; -make_toc([{pcdata, _Attrs, _More}|Rest]) -> - make_toc(Rest); -make_toc([{module, Attrs, More}|Rest]) -> - [{module, Attrs, More}|make_toc(Rest)]; -make_toc([{file, Attrs, More}|Rest]) -> - [{file, Attrs, More}|make_toc(Rest)]; -make_toc([{app, Attrs, More}|Rest]) -> - [{app, Attrs, More}|make_toc(Rest)]; -make_toc([{lib, Attrs, More}|Rest]) -> - [{lib, Attrs, More}|make_toc(Rest)]; -make_toc([{com, Attrs, More}|Rest]) -> - [{com, Attrs, More}|make_toc(Rest)]; -make_toc([{_Tag, _Attrs, More}|Rest]) -> - make_toc(More) ++ make_toc(Rest). - -rule([module|_], {_, [File], _}) -> - {"<small><a target=\"document\" href=\"" ++ - docb_html_util:make_anchor_href(File) ++ "\">", - "</a></small><br/>\n"}; - -rule([file|_], {_, [File], _}) -> - {"<small><a target=\"document\" href=\"" ++ - docb_html_util:make_anchor_href(File) ++ "\">", - "</a></small><br/>\n"}; - -rule([app|_], {_, [File], _}) -> - {"<small><a target=\"document\" href=\"" ++ - docb_html_util:make_anchor_href(File) ++ "\">", - "</a></small><br/>\n"}; - -rule([lib|_], {_, [File], _}) -> - {"<small><a target=\"document\" href=\"" ++ - docb_html_util:make_anchor_href(File) ++ "\">", - "</a></small><br/>\n"}; - -rule([com|_], {_, [File], _}) -> - {"<small><a target=\"document\" href=\"" ++ - docb_html_util:make_anchor_href(File) ++ "\">", - "</a></small><br/>\n"}; - -rule([pcdata|_], {_, _, Data}) -> - {drop, docb_html_util:pcdata_to_html(Data)}; - -rule(_, _) -> - {drop, ""}. - -rule([toc|_], {_Depth, [File], [Header|_]}, Opts) -> - case docb_util:lookup_option(fascdata, Opts) of - false -> - {{docb_html_layout:application_toc_top( - docb_html_util:all_header_data(Header), - File, Opts), - docb_html_layout:part_toc_bot()}, Opts}; - FascData -> - HRefTexts = - lists:map( - fun({_File, HRef, _Entry, PCText}) -> - {HRef, docb_html_util:pcdata_to_html(PCText)} - end, - FascData), - {{docb_html_layout:application_toc_top( - docb_html_util:all_header_data(Header), - File, Opts, HRefTexts) ++ "\n", - docb_html_layout:part_toc_bot()}, Opts} - end. - -%% Returns: [{File, HRef, Entry, Text}]. -get_fasc_data({fascicules, _, Fascs}) -> - lists:map( - fun({fascicule, Atts, Trees}) -> - AVals = get_avals(Atts), - PCText = get_pc_text(Trees), - list_to_tuple(lists:append([AVals, [PCText]])) - end, - Fascs). - -get_avals(Atts) -> - [element(3, Tuple) || Tuple <- Atts]. - -get_pc_text([{pcdata, _, Text}]) -> - Text. diff --git a/lib/docbuilder/src/docb_tr_appref2html.erl b/lib/docbuilder/src/docb_tr_appref2html.erl deleted file mode 100644 index 6b4cc0f815..0000000000 --- a/lib/docbuilder/src/docb_tr_appref2html.erl +++ /dev/null @@ -1,48 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_appref2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -%% Transform the parse tree. Header data is stored in an extra -%% argument to make life easier later on. -transform(_File, {appref,_,[Header|Rest]}, _Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - {appref, Data, [{header,[],[]}|Rest]}. - -rule([header|_],_) -> - {drop, ""}; - -rule([app|_],_) -> - {"\n<h3>APPLICATION</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([appsummary|_],_) -> - {"\n<h3>APPLICATION SUMMARY</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule(TagHistory, TagBody) -> - docb_html_ref:rule(TagHistory,TagBody). - -rule([appref|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:ref_top(Data, Opts), - docb_html_layout:ref_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html_ref:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_chapter2html.erl b/lib/docbuilder/src/docb_tr_chapter2html.erl deleted file mode 100644 index 185cdc7cc3..0000000000 --- a/lib/docbuilder/src/docb_tr_chapter2html.erl +++ /dev/null @@ -1,59 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_chapter2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(File, {chapter,_,[Header|Rest]}, Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - Tree = {chapter, Data, [{header,[],[]}|Rest]}, - ChapterLevel = - case docb_util:lookup_option(number, Opts) of - false -> none; - Value -> Value - end, - docb_html_util:number(Tree, ChapterLevel, File). - -rule([header|_], _) -> - {drop, ""}; - -rule([toc|_], {_,_,ToC}) -> - {drop, - "\n<h3>Table of Contents</h3>\n" ++ - docb_html_util:format_toc(ToC) ++ "\n"}; - -rule([section|_], _) -> - {"", ""}; - -rule([title|Rest], {_,[Number,_File], [{pcdata,_,Title}]}) -> - N = integer_to_list(docb_html_util:count_sections(Rest)+1), - {drop,"\n<h" ++ N ++ ">" ++ Number ++ " " ++ - docb_html_util:pcdata_to_html(Title) ++ "</h" ++ N ++ ">\n"}; - -rule(TagHistory, TagBody) -> - docb_html:rule(TagHistory, TagBody). - -rule([chapter|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:chapter_top(Data, Opts), - docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_cite2html.erl b/lib/docbuilder/src/docb_tr_cite2html.erl deleted file mode 100644 index 77f1c4e636..0000000000 --- a/lib/docbuilder/src/docb_tr_cite2html.erl +++ /dev/null @@ -1,134 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_cite2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, Tree, Opts) -> - purge(Tree, Opts). - -purge({Tag, Attrs, [Header|Body]}, Opts) -> - CiteList = case docb_util:lookup_option({defs,cite}, Opts) of - false -> []; - Value -> Value - end, - B1 = purge_body(Body, CiteList), - B2 = lists:ukeysort(2, B1), - {Tag, Attrs, [Header|B2]}. - -purge_body([], _) -> - []; -purge_body([{pcdata,_Attrs,_More}|Rest], CiteList) -> - purge_body(Rest, CiteList); -purge_body([{cite,[{"ID","CDATA",ID}],More}|Rest], CiteList) -> - case lists:keyfind(ID, 1, CiteList) of - false -> - [{cite, [{"NAME","CDATA",ID}, {"ID","CDATA",ID}], More}| - purge_body(Rest, CiteList)]; - {ID, Name, _Description, _Responsible} -> - [{cite, [{"NAME","CDATA",Name}, {"ID","CDATA",ID}], More}| - purge_body(Rest, CiteList)]; - {ID, Name, _Description} -> - [{cite, [{"NAME","CDATA",Name}, {"ID","CDATA",ID}], More}| - purge_body(Rest, CiteList)] - end; -purge_body([{_Tag,_Attrs,More}|Rest], CiteList) -> - purge_body(More, CiteList) ++ purge_body(Rest, CiteList). - -rule([header|_], _) -> - {drop, ""}; -rule(_, _) -> - {drop, ""}. - -rule([cite|_], {_,[],[Header]}, Opts) -> - HeaderData = docb_html_util:all_header_data(Header), - {{docb_html_layout:chapter_top(HeaderData, Opts) ++ - "\n<center><h1>Bibliography</h1></center>\n", - docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([cite|_], {_,[],[Header|_]}, Opts) -> - HeaderData = docb_html_util:all_header_data(Header), - {{docb_html_layout:chapter_top(HeaderData, Opts) ++ - "\n<center><h1>Bibliography</h1></center>\n<dl>\n", - "\n</dl>\n" ++ docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([cite|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:chapter_top(Data, Opts) ++ - "\n<center><h1>Bibliography</h1></center>\n<dl>\n", - "\n</dl>\n" ++ docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([cite|T], {A, B, [{citedef,C, - [{ctitle, [], [{pcdata,[],CTitle}]}, - {cauthor, [], [{pcdata,[],CAuthor}]}, - {chowpublished, [], - [{pcdata,[],Chowpublished}]}]}]}, Opts) -> - CiteDef = CTitle ++ " " ++ CAuthor ++ " " ++ Chowpublished, - rule([cite|T], {A,B,[{citedef,C,[{pcdata,[],CiteDef}]}]}, Opts); - -rule([cite|_], {_,[Name,ID], [{citedef,[],[{pcdata,[],Def}]}]}, Opts) -> - CiteList = - case docb_util:lookup_option({defs,cite}, Opts) of - false -> []; - Value -> Value - end, - case lists:keyfind(ID, 1, CiteList) of - false -> - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Def) ++ "\n</dd>\n"}, Opts}; - {ID, Name, Description, _Responsible} -> - docb_util:message(warning, - "Global cite ~s overriding local", [ID]), - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, - Opts}; - {ID, Name, Description} -> - docb_util:message(warning, - "Global cite ~s overriding local", [ID]), - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts} - end; - -rule([cite|_], {_,[Name,ID],_}, Opts) -> - CiteList = - case docb_util:lookup_option({defs,cite}, Opts) of - false -> []; - Value -> Value - end, - case lists:keyfind(ID, 1, CiteList) of - false -> - docb_util:message(error, - "The cite ~s has no definition", [ID]), - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++ - "??" ++ "\n</dd>\n"}, Opts}; - {ID, Name, Description, _Responsible} -> - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, - Opts}; - {ID, Name, Description} -> - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts} - end. diff --git a/lib/docbuilder/src/docb_tr_comref2html.erl b/lib/docbuilder/src/docb_tr_comref2html.erl deleted file mode 100644 index 25207dccb4..0000000000 --- a/lib/docbuilder/src/docb_tr_comref2html.erl +++ /dev/null @@ -1,46 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_comref2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, {comref,_,[Header|Rest]}, _Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - {comref, Data, [{header,[],[]}|Rest]}. - -rule([header|_],_) -> - {drop,""}; - -rule([com|_],_) -> - {"\n<h3>COMMAND</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([comsummary|_],_) -> - {"\n<h3>COMMAND SUMMARY</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule(TagHistory, TagBody) -> - docb_html_ref:rule(TagHistory, TagBody). - -rule([comref|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:ref_top(Data, Opts), - docb_html_layout:ref_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html_ref:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_cref2html.erl b/lib/docbuilder/src/docb_tr_cref2html.erl deleted file mode 100644 index 06748b8c57..0000000000 --- a/lib/docbuilder/src/docb_tr_cref2html.erl +++ /dev/null @@ -1,61 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_cref2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, {cref,_,[Header|Rest]}, _Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - {cref, Data, [{header,[],[]}|Rest]}. - -rule([header|_],_) -> - {drop, ""}; - -rule([ret|_],_) -> - {"",""}; - -rule([nametext|_],_) -> - {" ",""}; - -rule([name|_], {_,_,[_Ret,{nametext,[],[{pcdata,[],Name}]}]}) -> - FName = lists:flatten(docb_html_util:pcdata_to_html(Name)), - TName = docb_util:trim(FName), - CAnchor = docb_util:fknidx(TName, "/"), - {"<A NAME=\"" ++ CAnchor ++ "\"><STRONG><CODE>", - "</CODE></STRONG></A><BR>\n"}; -rule([name|T], {I,As,[Ret,{pcdata,[],Name}]}) -> % For SGML DTD - rule([name|T], {I,As,[Ret,{nametext,[],[{pcdata,[],Name}]}]}); - -rule([lib|_],_) -> - {"\n<H3>C LIBRARY</H3>\n<DIV CLASS=REFBODY>\n","\n</DIV>\n"}; - -rule([libsummary|_],_) -> - {"\n<H3>C LIBRARY SUMMARY</H3>\n<DIV CLASS=REFBODY>\n","\n</DIV>\n"}; - -rule(TagHistory, TagBody) -> - docb_html_ref:rule(TagHistory, TagBody). - -rule([cref|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:ref_top(Data, Opts), - docb_html_layout:ref_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html_ref:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_erlref2html.erl b/lib/docbuilder/src/docb_tr_erlref2html.erl deleted file mode 100644 index b264c46bce..0000000000 --- a/lib/docbuilder/src/docb_tr_erlref2html.erl +++ /dev/null @@ -1,46 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_erlref2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, {erlref,_,[Header|Rest]}, _Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - {erlref, Data, [{header,[],[]}|Rest]}. - -rule([header|_],_) -> - {drop, ""}; - -rule([module|_],_) -> - {"\n<h3>MODULE</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([modulesummary|_],_) -> - {"\n<h3>MODULE SUMMARY</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule(TagHistory, TagBody) -> - docb_html_ref:rule(TagHistory, TagBody). - -rule([erlref|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:ref_top(Data, Opts), - docb_html_layout:ref_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html_ref:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_fileref2html.erl b/lib/docbuilder/src/docb_tr_fileref2html.erl deleted file mode 100644 index 60280543a8..0000000000 --- a/lib/docbuilder/src/docb_tr_fileref2html.erl +++ /dev/null @@ -1,46 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_fileref2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, {fileref,_,[Header|Rest]}, _Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - {fileref, Data, [{header,[],[]}|Rest]}. - -rule([header|_],_) -> - {drop, ""}; - -rule([file|_],_) -> - {"\n<h3>FILE</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule([filesummary|_],_) -> - {"\n<h3>FILE SUMMARY</h3>\n<div class=\"REFBODY\">\n","\n</div>\n"}; - -rule(TagHistory, TagBody) -> - docb_html_ref:rule(TagHistory, TagBody). - -rule([fileref|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:ref_top(Data, Opts), - docb_html_layout:ref_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html_ref:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_first2html.erl b/lib/docbuilder/src/docb_tr_first2html.erl deleted file mode 100644 index e9ecbe73cb..0000000000 --- a/lib/docbuilder/src/docb_tr_first2html.erl +++ /dev/null @@ -1,46 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_first2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, Tree, _Opts) -> - Tree. - -rule([header|_], _) -> - {drop, ""}; - -rule([description|_], _) -> - {"", ""}; - -rule([include|_], _) -> - {drop, ""}; - -rule(TagHistory, TagBody) -> - docb_html:rule(TagHistory, TagBody). - -rule([first|_], {_,[],[Header|_]}, Opts) -> - HeaderData = docb_html_util:all_header_data(Header), - {{docb_html_layout:first_top(HeaderData, Opts), - docb_html_layout:first_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_index2html.erl b/lib/docbuilder/src/docb_tr_index2html.erl deleted file mode 100644 index 312342add2..0000000000 --- a/lib/docbuilder/src/docb_tr_index2html.erl +++ /dev/null @@ -1,195 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_index2html). - --export([extension/0, transform/3, rule/2]). - -extension() -> - ".html". - -transform(_File0, {index, Attrs, [Header| Trees0]}, _Opts) -> - Trees1 = prune_flat(Trees0, false), - %% - %% Now each element of Trees1 is a tree with tag `name' and - %% attribute `File', and with one `pcdata' subtree containing the - %% name `Func' of the function. We extract `File' and `Func', and - %% create new trees. - %% - %% `File' is attribute CDATA (from an <include file=...>), and - %% `Func' is PCDATA. - %% - FileFuncs = - [{File, RefType, Func} || - {name, [{_, _, File}, {_, _, RefType}|_], - [{pcdata, [], Func}]} - <- Trees1], - Trees2 = new_trees(FileFuncs), - {index, Attrs, [Header| Trees2]}. - -%% Remove all elements except those with tag equal to `name'. -%% Within `name' remove all elements except those equal to `pcdata'. -%% Add attribute `filetype' to `name'. -%% -%% Refs: appref, comref, cref, erlref, fileref -prune_flat([{appref, _Attrs, More}| Rest], _) -> - RefType = appref, - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([{comref, _Attrs, More}| Rest], _) -> - RefType = comref, - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([{cref, _Attrs, More}| Rest], _) -> - RefType = cref, - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([{erlref, _Attrs, More}| Rest], _) -> - RefType = erlref, - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([{fileref, _Attrs, More}| Rest], _) -> - RefType = fileref, - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([{name, [Attr0|Attrs0], More}| Rest], RefType) -> - Attrs = [Attr0, {"FILETYPE", "CDATA", RefType} | - Attrs0], - [{name, Attrs, keep_pcdata(More)}| prune_flat(Rest, RefType)]; -prune_flat([{pcdata, _, _}| Rest], RefType) -> % special case - prune_flat(Rest, RefType); -prune_flat([{_Tag, _Attrs, More}| Rest], RefType) -> - lists:append(prune_flat(More, RefType), prune_flat(Rest, RefType)); -prune_flat([], _) -> - []. - -keep_pcdata(Trees) -> - [T || T = {pcdata, _, _} <- Trees]. - -new_trees(FileFuncs) -> - Files0 = [{File, RefType} || {File, RefType, _} <- FileFuncs], - Files1 = lists:usort(Files0), - FileEntries = [{reffile, File, RefType, - [Fu || {Fi, _, Fu} <- FileFuncs, Fi == File]} - || {File, RefType} <- Files1], - FuncEntries = [{func, Func, RefType, [File]} - || {File, RefType, Func} <- FileFuncs], - Entries = FileEntries ++ FuncEntries, - SortedEntries = sort_entries(Entries), - %% - %% We create a tree according to the following "dtd": - %% - %% element index (reffile | funcdef)* - %% element reffile (funcdef2)* - %% attribute reffile filename CDATA - %% attribute reffile filetype CDATA - %% element funcdef2 PCDATA - %% attribute funcdef2 filename CDATA - %% attribute funcdef2 filetype CDATA - %% element funcdef PCDATA - %% attribute funcdef filename CDATA - %% attribute funcdef filetype CDATA - %% - %% For example: - %% <index> - %% <reffile filename="mymod" filetype="erlref"> - %% <funcdef2 filename="mymod" filetype="erlref">myfunca(A)</> - %% <funcdef2 filename="mymod" filetype="erlref">myfuncb(A, B)</> - %% </> - %% <funcdef filename="mymod" filetype="erlref">myfunca(A)</> - %% <funcdef filename="mymod" filetype="erlref">myfuncb(A, B)</> - %% </> - lists:flatmap( - fun({reffile, File, RefType, Funcs}) -> - %% A reffile tree - [{reffile, [{"FILENAME", "CDATA", File}, - {"FILETYPE", "CDATA", RefType}], - [{funcdef2, [{"FILENAME", "CDATA", File}, - {"FILETYPE", "CDATA", RefType}], - [{pcdata, [], Func}]} || Func <- Funcs]}]; - ({func, Func, RefType, [File]}) -> - %% A func tree - [{funcdef, [{"FILENAME", "CDATA", File}, - {"FILETYPE", "CDATA", RefType}], - [{pcdata, [], Func}]}] - end, SortedEntries). - -%% Sorting of entries -%% -%% The sorting is based on how names of files and functions are -%% presented (in a browser). -%% Requires conversion to "function/2" etc. -%% -sort_entries(Entries) -> - ExpEntries = - lists:map( - fun({reffile, File, RefType, Funcs}) -> - HFile = filename_sort_order(File), - HFuncs = [{funcdef_sort_order(Fu, RefType), Fu} || Fu <- Funcs], - {reffile, HFile, File, RefType, lists:sort(HFuncs)}; - ({func, Func, RefType, [File]}) -> - HFunc = funcdef_sort_order(Func, RefType), - HFile = filename_sort_order(File), - {func, HFunc, Func, RefType, [{HFile, File}]} - end, Entries), - SortedExpEntries = lists:keysort(2, ExpEntries), - lists:map( - fun({Tag, _HName, Name, RefType, Vals}) -> - NVals = lists:map(fun({_HVal, Val}) -> Val end, Vals), - {Tag, Name, RefType, NVals} - end, SortedExpEntries). - -rule([index| _], _) -> - {docb_html_layout:index_top("") ++ - "<dl>\n", - "</dl>\n" ++ docb_html_layout:index_bot()}; - -rule([header| _], _) -> - {drop, ""}; - -rule([reffile| _], {_, [File, _RefType|_], _}) -> - CFile = docb_html_util:attribute_cdata_to_html(File), - {"<dt><em>" ++ CFile ++ "</em></dt>\n", ""}; - -rule([funcdef2| _], {_, [File, RefType|_], [{pcdata, [], FuncDef}]}) -> - FFuncDef = lists:flatten(docb_html_util:pcdata_to_html(FuncDef)), - TFuncDef = docb_util:trim(FFuncDef), - ShortFuncDef = docb_html_util:make_funcdef_short(TFuncDef, RefType), - HRef = - docb_html_util:make_anchor_href_short(File, TFuncDef, RefType), - {drop, - "<dd><a href=\"" ++ HRef ++ "\"><code>" ++ - ShortFuncDef ++ "</code></a></dd>\n"}; - -rule([funcdef| _], {_, [File, RefType|_], [{pcdata, [], FuncDef}]}) -> - FFuncDef = lists:flatten(docb_html_util:pcdata_to_html(FuncDef)), - TFuncDef = docb_util:trim(FFuncDef), - ShortFuncDef = docb_html_util:make_funcdef_short(TFuncDef, RefType), - HRef = - docb_html_util:make_anchor_href_short(File, TFuncDef, RefType), - CFile = docb_html_util:attribute_cdata_to_html(File), - {drop, - "<dt><code>" ++ ShortFuncDef ++ "</code></dt>\n" - "<dd><a href=\"" ++ HRef ++ "\"><em>" ++ - CFile ++ "</em></a></dd>\n"}; - -rule(_, _) -> - {drop, ""}. - -filename_sort_order(File) -> - docb_html_util:html_latin1_sort_order( - lists:flatten( - docb_html_util:attribute_cdata_to_html(string:strip(File)))). - -funcdef_sort_order(FuncDef, RefType) -> - docb_html_util:html_latin1_sort_order( - docb_html_util:make_anchor_name_short(FuncDef, RefType)). diff --git a/lib/docbuilder/src/docb_tr_part2html.erl b/lib/docbuilder/src/docb_tr_part2html.erl deleted file mode 100644 index 30befe8432..0000000000 --- a/lib/docbuilder/src/docb_tr_part2html.erl +++ /dev/null @@ -1,237 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_part2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(File, {part, _Attrs, [Header| Rest]}, Opts0) -> - - %% Extract header data - Title = docb_html_util:extract_header_data(title, Header), - - %% Create the framing HTML document - OutFile = docb_util:outfile(File ++ "_frame", ".html", Opts0), - case file:open(OutFile, [write]) of - {ok, Frame} -> - io:format(Frame, -"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\"> -<!-- This document was generated using DocBuilder-" ++ docb_util:version() ++ " --> -<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"> -<head> - <title>~s</title> - " ++ docb_util:html_snippet(head, Opts0) ++ " -</head> -<frameset cols=\"200, *\"> - <frame src=\"~s\" name=\"toc\"/> - <frame src=\"~s\" name=\"document\"/> - <noframes> - <body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" - vlink=\"#FF00FF\" alink=\"#FF0000\"> - <p>This documentation requires a browser that can handle frames</p> - </body> - </noframes> -</frameset> -</html> -", - [Title, File ++ ".html", File ++ "_first.html"]), - file:close(Frame) - end, - - %% Create the front HTML document - docb_main:transform(first, html, Opts0, File ++ "_first", - {first, [], [Header| Rest]}), - - %% Extract files to include - Files = - case Rest of - [{description, _, _}| NewRest] -> - lists:map(fun({include, [{_, _, F}], _}) -> filename:rootname(F) end, - NewRest); - [{include, _, _}| _NewRest] -> - lists:map(fun({include, [{_, _, F}], _}) -> filename:rootname(F) end, Rest) - end, - - %% Concat all chapters into a *big* parse tree - %% Also transform them to HTML - TransformP = not docb_util:an_option(framework_only, Opts0), - TOpts = [dict, {part_application,File}], - ConcatTree = concat_files(Files, Opts0, TransformP, TOpts), - - %% Create a cites dictionary - docb_main:transform(cite, html, Opts0, File ++ "_cite", - {cite, [], [Header| ConcatTree]}), - - %% Create a terms dictionary - docb_main:transform(term, html, Opts0, File ++ "_term", - {term, [], [Header| ConcatTree]}), - - %% Find all fascicules to be put in the top menu of the table of - %% contents - Ext = docb_util:lookup_option(src_type, Opts0), - Opts2 = - case filelib:is_regular("fascicules"++Ext) of - true -> - case docb_main:parse1("fascicules", Opts0) of - {ok, Parse} -> - FascData = get_fasc_data(Parse), - case lists:keyfind(File, 1, FascData) of - {_, _, "YES", _} -> - OrigFile = - docb_util:outfile(File++"_frame", - ".html", Opts0), - EntryFile = - docb_util:outfile("index", - ".html", Opts0), - docb_util:message(info, - "Copying ~s to ~s", - [OrigFile,EntryFile]), - file:copy(OrigFile, EntryFile); - _ -> - ok - end, - [{fascdata, FascData}| Opts0]; - errors -> - %% do not bother - docb_util:message( - warning, - "fascicules~s could not be parsed," - " no index.html created~n", [Ext]), - Opts0 - end; - _ -> - %% do not bother - docb_util:message(warning, - "fascicules~s not found, " - "no index.html created~n", - [Ext]), - Opts0 - end, - - %% Create ToC parse tree - {{toc, [{"FILE", "CDATA", File}], [Header| ConcatTree]}, Opts2}. - -concat_files(Files, Opts, TransformP, TOpts) -> - Ext = docb_util:lookup_option(src_type, Opts), - concat_files(Files, [], 1, Opts, TransformP, TOpts, Ext). - -concat_files([File | Rest], Body, ChLevel, Opts, TP, TOpts, Ext) -> - case docb_main:parse1(File, Opts) of - {ok, Parse} -> - {TopTag, Attrs, [Header = {header, _, HeaderContents} | More]} = Parse, - {title,_,Title} = lists:keyfind(title,1,HeaderContents), - NewMore = [{section, [], [{title, [], Title}| More]}], - NewParse = {TopTag, Attrs, [Header| NewMore]}, - if - TP -> - docb_util:message(info, - "Processing \"~s~s\"", - [File, Ext]), - Opts2 = - [html, {number,integer_to_list(ChLevel)}] ++ - TOpts ++ Opts, - docb_main:transform(TopTag, html, Opts2, File, - NewParse); - true -> ignore - end, - NumberTree = - docb_html_util:number(NewParse, - integer_to_list(ChLevel), File), - {_, [], [_| NewBody]} = NumberTree, - Body ++ concat_files(Rest, NewBody, ChLevel+1, Opts, - TP, TOpts, Ext); - errors -> - throw({error,"Parse error when building chapter "++File}) - end; -concat_files([], Body, _ChLevel, _Opts, _TP, _TOpts, _Ext) -> - Body. - -rule([section| _], _) -> - {"", ""}; - -rule(_, _) -> - {drop, ""}. - -rule([toc| _], {_Depth, [File], [Header| _]}, Opts) -> - case docb_util:lookup_option(fascdata, Opts) of - false -> - {{docb_html_layout:part_toc_top( - docb_html_util:all_header_data(Header), File, Opts), - docb_html_layout:part_toc_bot()}, Opts}; - FascData -> - HRefTexts = - lists:map( - fun({_File, HRef, _Entry, PCText}) -> - {HRef, docb_html_util:pcdata_to_html(PCText)} - end, - FascData), - {{docb_html_layout:part_toc_top( - docb_html_util:all_header_data(Header), - File, Opts, HRefTexts), - docb_html_layout:part_toc_bot()}, Opts} - end; - -rule([title| Rest], {_, [Number, File], [{pcdata, _, Title}]}, Opts) -> - N = docb_html_util:count_sections(Rest), - OutFile = docb_html_util:make_anchor_href(File), - if - N == 1 -> - {{drop, - "<hr/>\n<small>" ++ - Number ++ - " <a target=\"document\" href=\"" ++ OutFile ++ "#" ++ - Number ++ "\">" ++ - docb_html_util:pcdata_to_html(Title) ++ - "</a></small><br/>\n"}, - Opts}; - N < 3 -> - {{drop, - "<small>" ++ - Number ++ - " <a target=\"document\" href=\"" ++ OutFile ++ "#" ++ - Number ++ "\">" ++ - docb_html_util:pcdata_to_html(Title) ++ - "</a></small><br/>\n"}, - Opts}; - true -> - {{drop, ""}, Opts} - end. - -%% Parsed fascicules: -%% {fascicules,[], -%% [{fascicule, [{"FILE","CDATA","refman"}, -%% {"HREF","CDATA","refman_frame.html"}, -%% {"ENTRY","TOKEN","YES"}], -%% [{pcdata, [], "" Reference Manual\\n \n"}]}, -%% Returns: [{File, HRef, Entry, Text}]. -get_fasc_data({fascicules, _, Fascs}) -> - lists:map( - fun({fascicule, Atts, Trees}) -> - AVals = get_avals(Atts), - PCText = get_pc_text(Trees), - list_to_tuple(lists:append([AVals, [PCText]])) end, - Fascs). - -get_avals(Atts) -> - [element(3, Tuple) || Tuple <- Atts]. - -get_pc_text([{pcdata, _, Text}]) -> - Text. diff --git a/lib/docbuilder/src/docb_tr_refs2kwic.erl b/lib/docbuilder/src/docb_tr_refs2kwic.erl deleted file mode 100644 index dc60c329fc..0000000000 --- a/lib/docbuilder/src/docb_tr_refs2kwic.erl +++ /dev/null @@ -1,156 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_refs2kwic). - --export([extension/0, transform/3, rule/2]). - -%% Output parts of a parsetree that contains a series of reference -%% manual pages. The tags considered are: module, file, app, com and lib -%% (and their corresponding *summary tags), and name, fsummary, c, em, -%% ret and pcdata. - -extension() -> - ".kwc". - -transform(File, Tree, Opts) -> - {refs, [], Trees} = Tree, - FileTree = {srcfile, [], [{pcdata, [], File}]}, - AppName = docb_util:lookup_option(name, Opts, "unknown"), - AppTree = {appname, [], [{pcdata, [], AppName}]}, - Vsn = docb_util:lookup_option(vsn, Opts, "unknown"), - VsnTree = {appvsn, [], [{pcdata, [], Vsn}]}, - NewTree = {refs, [], [FileTree, AppTree, VsnTree| Trees]}, - {NewTree, Opts}. - -rule([refs|_],_) -> - {"%% Automatically generated. Do not edit.\n", ""}; - -rule([srcfile| _], _) -> - {"{srcfile, \"", "\"}.\n"}; - -rule([appname| _], _) -> - {"{appname, \"", "\"}.\n"}; - -rule([appvsn| _], _) -> - {"{appvsn, \"", "\"}.\n"}; - -rule([erlref|_ ], _) -> - {"", ""}; - -rule([fileref|_ ], _) -> - {"", ""}; - -rule([appref|_ ], _) -> - {"", ""}; - -rule([comref|_ ], _) -> - {"", ""}; - -rule([cref|_ ], _) -> - {"", ""}; - -rule([module| _], {_, [File], _}) -> - {drop, "{module, \"" ++ File ++ "\"}.\n"}; - -rule([file|_], {_, [File], _}) -> - {drop, "{file, \"" ++ File ++ "\"}.\n"}; - -rule([app|_], {_, [File], _}) -> - {drop, "{app, \"" ++ File ++ "\"}.\n"}; - -rule([com|_], {_, [File], _}) -> - {drop, "{com, \"" ++ File ++ "\"}.\n"}; - -rule([lib|_], {_, [File], _}) -> - {drop, "{lib, \"" ++ File ++ "\"}.\n"}; - -rule([modulesummary|_], _) -> - {"{modulesummary, \"", "\"}.\n"}; - -rule([filesummary|_], _) -> - {"{filesummary, \"", "\"}.\n"}; - -rule([appsummary|_], _) -> - {"{appsummary, \"", "\"}.\n"}; - -rule([comsummary|_], _) -> - {"{comsummary, \"", "\"}.\n"}; - -rule([libsummary|_], _) -> - {"{libsummary, \"", "\"}.\n"}; - -rule([funcs|_ ], _) -> - {"", ""}; - -rule([func|_ ], _) -> - {"", ""}; - -rule([name,func,funcs,cref|_], {_,[_File], [_Ret,{pcdata,[],Name}]}) -> - FName = lists:flatten(docb_html_util:pcdata_to_html(Name)), - TName = docb_util:trim(FName), - case catch docb_util:fknidx(TName, "/") of - {'EXIT',_} -> - {drop, ["{name, \"", escq(TName), "\"}.\n"]}; - FuncName -> - {drop, ["{name, \"", escq(FuncName), "\"}.\n"]} - end; - -rule([name,func,funcs,erlref|_], {_,[_File], [{pcdata,[],Name}]}) -> - FName = lists:flatten(docb_html_util:pcdata_to_html(Name)), - TName = docb_util:trim(FName), - case catch docb_util:fknidx(TName, "/") of - {'EXIT',_} -> - {drop, ["{name, \"", escq(TName), "\"}.\n"]}; - FuncName -> - {drop, ["{name, \"", escq(FuncName), "\"}.\n"]} - end; - -rule([name, func| _], {_, [_File], [{pcdata, [], Name}]}) -> - FName = lists:flatten(docb_html_util:pcdata_to_html(Name)), - TName = docb_util:trim(FName), - Cmd = case string:tokens(TName, " ") of - [Cmd0| _] -> - Cmd0; - _ -> - TName - end, - {drop, ["{name, \"", escq(Cmd), "\"}.\n"]}; - -rule([fsummary| _], _) -> - {"{fsummary, \"", "\"}.\n"}; - -rule([c, fsummary|_], _) -> - {"", ""}; - -rule([em, fsummary|_], _) -> - {"", ""}; - -rule([pcdata| _], {_, _, Data}) -> - FData = lists:flatten(docb_html_util:pcdata_to_html(Data)), - Out = lists:map(fun($\n) -> $ ; (C) -> C end, FData), - {drop, escq(Out)}; - -rule(_, _) -> - {drop, ""}. - -escq(Cs) -> - lists:flatmap(fun($") -> - "\\\""; - (C) -> [C] - end, - Cs). diff --git a/lib/docbuilder/src/docb_tr_report2html.erl b/lib/docbuilder/src/docb_tr_report2html.erl deleted file mode 100644 index 3386ed972a..0000000000 --- a/lib/docbuilder/src/docb_tr_report2html.erl +++ /dev/null @@ -1,70 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_report2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -%% -%% File extension -%% - -extension() -> - ".html". - -transform(File, {report,_,[Header|Rest]}, Opts) -> - Data = [{[], [], docb_html_util:all_header_data(Header)}], - Tree = {report, Data, [{header,[],[]}|Rest]}, - ChapterLevel = case docb_util:lookup_option(number, Opts) of - false -> none; - Value -> Value - end, - NumberTree = docb_html_util:number(Tree, ChapterLevel, File), - options(NumberTree, Opts). - -options(Tree, []) -> - Tree; -options(Tree, [_|Rest]) -> - options(Tree, Rest). - -rule([header|_], _) -> - {drop, ""}; - -rule([toc|_], {_,_,ToC}) -> - {drop, "\n<h3>Table of Contents</h3>\n" ++ - docb_html_util:format_toc(ToC) ++ "\n"}; - -rule([section|_], _) -> - {"", ""}; - -rule([title|Rest], {_,[Number,_File], [{pcdata,_,Title}]}) -> - N = integer_to_list(docb_html_util:count_sections(Rest)+1), - {drop, "\n<h" ++ N ++ ">" ++ Number ++ " " ++ - docb_html_util:pcdata_to_html(Title) ++ "</h" ++ N ++ ">\n"}; - -rule([erlinclude|_], {_,[File,Tag],_}) -> - docb_html_util:erl_include(File, Tag); - -rule(TagHistory, TagBody) -> - docb_html:rule(TagHistory, TagBody). - -rule([report|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:report_top(Data, Opts), - docb_html_layout:report_bot(Opts)}, Opts}; - -rule(TagHistory, TagBody, Opts) -> - docb_html:rule(TagHistory, TagBody, Opts). diff --git a/lib/docbuilder/src/docb_tr_term2html.erl b/lib/docbuilder/src/docb_tr_term2html.erl deleted file mode 100644 index a3c4a5312a..0000000000 --- a/lib/docbuilder/src/docb_tr_term2html.erl +++ /dev/null @@ -1,124 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_tr_term2html). - --export([extension/0, transform/3, rule/2, rule/3]). - -extension() -> - ".html". - -transform(_File, Tree, Opts) -> - purge(Tree, Opts). - -purge({Tag, Attrs, [Header|Body]}, Opts) -> - TermList = case docb_util:lookup_option({defs,term}, Opts) of - false -> []; - Value -> Value - end, - B1 = purge_body(Body, TermList), - B2 = lists:ukeysort(2, B1), - {Tag, Attrs, [Header|B2]}. - -purge_body([], _) -> - []; -purge_body([{pcdata,_Attrs,_More}|Rest], TermList) -> - purge_body(Rest, TermList); -purge_body([{term,[{"ID","CDATA",ID}],More}|Rest], TermList) -> - case lists:keyfind(ID, 1, TermList) of - false -> - [{term,[{"NAME","CDATA",ID},{"ID","CDATA",ID}],More}| - purge_body(Rest, TermList)]; - {ID, Name, _Description, _Responsible} -> - [{term,[{"NAME","CDATA",Name},{"ID","CDATA",ID}],More}| - purge_body(Rest, TermList)]; - {ID, Name, _Description} -> - [{term,[{"NAME","CDATA",Name},{"ID","CDATA",ID}],More}| - purge_body(Rest, TermList)] - end; -purge_body([{_Tag,_Attrs,More}|Rest], TermList) -> - purge_body(More, TermList) ++ purge_body(Rest, TermList). - -rule([header|_], _) -> - {drop, ""}; -rule(_, _) -> - {drop, ""}. - -rule([term|_], {_,[],[Header]}, Opts) -> - {{docb_html_layout:chapter_top( - docb_html_util:all_header_data(Header), Opts) ++ - "\n<center><h1>Glossary</h1></center>\n", - docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([term|_], {_,[],[Header|_]},Opts) -> - {{docb_html_layout:chapter_top( - docb_html_util:all_header_data(Header), Opts) ++ - "\n<center><h1>Glossary</h1></center>\n<dl>\n", - "\n</dl>\n" ++ docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([term|_], {_,[Data],_}, Opts) -> - {{docb_html_layout:chapter_top(Data, Opts) ++ - "\n<center><h1>Bibliography</h1></center>\n<dl>\n", - "\n</dl>\n" ++ docb_html_layout:chapter_bot(Opts)}, Opts}; - -rule([term|_], {_,[Name,ID],[{termdef,[],[{pcdata,[],Def}]}]}, Opts) -> - TermList = case docb_util:lookup_option({defs,term}, Opts) of - false -> []; - Value -> Value - end, - case lists:keyfind(ID, 1, TermList) of - false -> - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ ID ++ "</strong></a>\n</dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Def) ++ "\n</dd>\n"}, Opts}; - {ID, Name, Description, _Responsible} -> - docb_util:message(warning, - "Global term ~s overriding local", [ID]), - {{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, - Opts}; - {ID, Name, Description} -> - docb_util:message(warning, - "Global term ~s overriding local", [ID]), - {{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts} - end; - -rule([term|_], {_,[Name,ID],_}, Opts) -> - TermList = case docb_util:lookup_option({defs,term}, Opts) of - false -> []; - Value -> Value - end, - case lists:keyfind(ID, 1, TermList) of - false -> - docb_util:message(error, - "The term ~s has no definition", [ID]), - {{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++ - "??" ++ "\n</dd>\n"}, Opts}; - {ID, Name, Description, _Responsible} -> - {{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, - Opts}; - {ID, Name, Description} -> - {{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++ - "<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++ - docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts} - end. diff --git a/lib/docbuilder/src/docb_transform.erl b/lib/docbuilder/src/docb_transform.erl deleted file mode 100644 index 736ac92274..0000000000 --- a/lib/docbuilder/src/docb_transform.erl +++ /dev/null @@ -1,163 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_transform). - --export([file/1, file/2]). --deprecated([{file,1,next_major_release}, - {file,2,next_major_release}]). - -%% file(File) -> ok | {error, Reason} -%% file(File, Opts) -> ok | {error, Reason} -%% File = string(), file name with or without ".xml" extension -%% Opts = [Opt] -%% Reason = badfile | {badopt, Term} -file(File0) -> - file(File0, []). -file(File0, RawOpts) -> - File = filename:rootname(File0), % without extension - Ext = case filename:extension(File0) of - ".xml" -> ".xml"; - ".sgml" -> ".sgml"; - "" -> - %% If the file is given without extension, we try to - %% infer if the source file is XML or SGML. - %% SGML is supported *internally within OTP* for - %% backwards compatibility reasons. - case filelib:is_regular(File++".xml") of - true -> ".xml"; - false -> ".sgml" - end; - _Ext0 -> % this is probably an error... - ".xml" - end, - case filelib:is_regular(File++Ext) of - true -> - case parse(RawOpts) of - {ok, Opts0} -> - {ok, Cwd} = file:get_cwd(), - Opts = [{src_type,Ext}, - {src_dir,Cwd}, - {src_file,File}, - {{local_defs,term},[]}, - {{local_defs,cite},[]} | Opts0], - case docb_main:process(File, Opts) of - errors -> error; - ok -> ok - end; - Error -> % {error, {badopt,Term}} - Error - end; - false -> - {error, badfile} - end. - -parse(RawOpts) -> - parse(RawOpts, []). - -%% Officially supported options - -parse([{html_mod,Module} | RawOpts], Opts) when is_atom(Module) -> - parse(RawOpts, [{html_mod,Module} | Opts]); -parse([{outdir,Dir} | RawOpts], Opts) when is_list(Dir) -> - parse(RawOpts, [{outdir,Dir} | Opts]); -parse([{number,N} | RawOpts], Opts) when is_integer(N) -> - parse(RawOpts, [{number,integer_to_list(N)} | Opts]); -parse([{number,Nstr} | RawOpts], Opts) -> % list when called from script - parse(RawOpts, [{number,Nstr} | Opts]); -parse([{ptype,Type} | RawOpts], Opts) when Type==unix; - Type==windows -> - parse(RawOpts, [{ptype,atom_to_list(Type)} | Opts]); -parse([{ptype,Type} | RawOpts], Opts) -> % list when called from script - parse(RawOpts, [{ptype,Type} | Opts]); -parse([silent | RawOpts], Opts) -> - put(option_silent, true), - parse(RawOpts, [silent | Opts]); -parse([{top,Index} | RawOpts], Opts) when is_list(Index) -> - parse(RawOpts, [{top,Index} | Opts]); -parse([{vsn,Vsn} | RawOpts], Opts) when is_list(Vsn) -> - parse(RawOpts, [{vsn,Vsn} | Opts]); - -parse([{term_defs,File} | RawOpts], Opts) when is_list(File) -> - Opts2 = get_defs(term, File, Opts), - parse(RawOpts, Opts2); -parse([{cite_defs,File} | RawOpts], Opts) when is_list(File) -> - Opts2 = get_defs(cite, File, Opts), - parse(RawOpts, Opts2); - -%% OTP internal options (SGML and PDF support etc.) - -parse([html | RawOpts], Opts) -> - parse(RawOpts, [html | Opts]); -parse([latex | RawOpts], Opts) -> - parse(RawOpts, [latex | Opts]); -parse([{man,Level} | RawOpts], Opts) -> % Level = 1..9 - parse(RawOpts, [{man,Level} | Opts]); - -parse([{booksty,StyFile} | RawOpts], Opts) -> % "otpA4" | "otpBOOK" - parse(RawOpts, [{booksty,StyFile} | Opts]); -parse([{includepath,Dir} | RawOpts], Opts) -> - parse(RawOpts, [{includepath,Dir} | Opts]); -parse([showpaths | RawOpts], Opts) -> - parse(RawOpts, [showpaths | Opts]); -parse([straight | RawOpts], Opts) -> - parse(RawOpts, [straight | Opts]); -parse([{ent,Ent} | RawOpts], Opts) -> - parse(RawOpts, [{ent,Ent} | Opts]); - -%% Undocumented options - -parse([{name, Name} | RawOpts], Opts) -> - parse(RawOpts, [{name, Name} | Opts]); -parse([framework_only | RawOpts], Opts) -> - parse(RawOpts, [framework_only | Opts]); -parse([kwicindex_only | RawOpts], Opts) -> - parse(RawOpts, [kwicindex_only | Opts]); - -parse([], Opts) -> - {ok, Opts}; -parse([Opt | _RawOpts], _Opts) -> - {error, {badopt, Opt}}. - -%% Type = term | cite -get_defs(Type, File, Opts) -> - Key = {defs,Type}, - {PrevDefs, Opts2} = - case lists:keyfind(Key, 1, Opts) of - {_, Defs0} -> - {Defs0, lists:keydelete(Key, 1, Opts)}; - false -> - {[], Opts} - end, - NewDefs = case file:consult(File) of - {ok, [DefL]} when is_list(DefL) -> - DefL; - {ok, _Terms} -> - docb_util:message(error, - "Skipping defs file ~s, does " - "not contain one list", [File]), - []; - {error, Error} -> - Expl = lists:flatten(file:format_error(Error)), - docb_util:message(error, - "Skipping defs file ~s, ~s", - [File, Expl]), - [] - end, - [{Key,PrevDefs++NewDefs} | Opts2]. - - diff --git a/lib/docbuilder/src/docb_util.erl b/lib/docbuilder/src/docb_util.erl deleted file mode 100644 index 9b2eec7733..0000000000 --- a/lib/docbuilder/src/docb_util.erl +++ /dev/null @@ -1,237 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% --module(docb_util). - --export([version/0, old_docb_dir/0, dtd_dir/0]). --export([html_snippet/2, html_snippet/3]). --export([lookup_option/2, lookup_option/3, lookup_options/2, - an_option/2]). --export([outfile/3, full_file_name/4]). --export([message/2, message/3]). --export([ltrim/1, rtrim/1, trim/1]). --export([join/2]). --export([fknidx/2]). - --include("docb_util.hrl"). - -%%--DocBuilder info----------------------------------------------------- - -%% version() -> string() -%% Returns the DocBuilder application version. -version() -> - DocbDir = code:lib_dir(docbuilder), - case string:tokens(filename:basename(DocbDir), "-") of - [_, Vsn] -> Vsn; - _ -> "unknown" - end. - -%% old_docb_dir() -> string() -%% Returns the root directory of Old_DocBuilder (OTP internal). -old_docb_dir() -> - "/home/otp/sgml/docb". - -%% dtd_dir() -> string() -%% Returns the directory where the XML DTDs are located. -dtd_dir() -> - DocbDir = code:lib_dir(docbuilder), - filename:join(DocbDir, "dtd"). - -%%--User defined HTML snippets------------------------------------------ - -%% html_snippet(What, Opts) -> HTML -%% html_snippet(What, Arg, Opts) -> HTML -%% What = head | seealso -%% HTML = string() -html_snippet(What, Opts) -> - case lookup_option(html_mod, Opts) of - false -> ""; - Module -> - case catch Module:What() of - HTML when is_list(HTML) -> - HTML; - {'EXIT', {undef, _}} -> - ""; - {'EXIT', Reason} -> - message(warning, - "Callback function ~p:~p() => ~p", - [Module, What, Reason]), - ""; - Other -> - message(warning, - "Callback function ~p:~p() => ~p", - [Module, What, Other]), - "" - end - end. -html_snippet(What, Arg, Opts) -> - case lookup_option(html_mod, Opts) of - false -> ""; - Module -> - case catch Module:What(Arg) of - HTML when is_list(HTML) -> - HTML; - {'EXIT', {undef, _}} -> - ""; - {'EXIT', Reason} -> - message(warning, - "Callback function ~p:~p(~p) => ~p", - [Module, What, Arg, Reason]), - ""; - Other -> - message(warning, - "Callback function ~p:~p(~p) => ~p", - [Module, What, Arg, Other]), - "" - end - end. - -%%--Option utilities---------------------------------------------------- - -%% Opts = [{Opt,Value} | Opt] - -%% lookup_option(Opt, Opts) -> Value | false -lookup_option(Opt, Opts) -> - case lists:keyfind(Opt, 1, Opts) of - {Opt,Value} -> Value; - false -> false - end. - -%% lookup_option(Opt, Opts, DefaultValue) -> Value | DefaultValue -lookup_option(Opt, Opts, DefaultValue) -> - case lookup_option(Opt,Opts) of - false -> DefaultValue; - Value -> Value - end. - -%% lookup_options(Opt, Opts) -> [Value] -%% Used when the same option can be defined several times and returns -%% the (possibly empty) list of values. -lookup_options(Opt, Opts) -> - [V || {O, V} <- Opts, O == Opt]. - -%% an_option(Opt, Opts) -> bool() -an_option(Opt, Opts) -> - lists:member(Opt, Opts). - -%%--File handling------------------------------------------------------- - -%% outfile(File0, Extension, Opts) -> File -%% Build the full filename for where to place a resulting file. -outfile(File0, Extension, Opts) -> - File = - case regexp:match(File0, "[^/]*\$") of - {match,Start,Length} -> - string:substr(File0, Start, Length); - _ -> - File0 - end, - full_file_name(File, Extension, outdir, Opts). - -%% full_file_name(File, Extension, What, Opts) -> File' -%% File = string() -%% What = outdir | includepath -%% Prepend the full path name. -full_file_name(File, Extension, What, Opts) -> - Path = lookup_option(What, Opts, ""), - full_file_name(File, Extension, Path). - -full_file_name(File0, Extension, Path) -> - File = case filename:extension(File0) of - Extension -> File0; - _ -> File0++Extension - end, - - case File of - [$/|_] -> File; - [$~|_] -> File; - _ when Path=/="" -> filename:join(Path, File); - _ -> File - end. - -%%--Messages to the user------------------------------------------------ - -%% message(Class, Format) -%% message(Class, Format, Values) -> ok -%% Class = info | warning | error -%% Format, Values -- as in io:format/2 -%% Prints a warning or error message. -%% Call as util:message(warning, "~w is undefined", [foo]). -message(Class, Format) -> - message(Class, Format, []). -message(Class, Format, Values) -> - Prefix = case Class of - info -> ""; - warning -> "*** Warning: "; - error -> "*** Error: " - end, - case get(option_silent) of - true when Class==warning -> - ok; - _ -> - io:format(Prefix, []), - io:format(Format, Values), - io:nl() - end. - -%%--String handling----------------------------------------------------- - -%% ltrim(Str) -> Str' -%% rtrim(Str) -> Str' -%% trim(Str) -> Str' -%% Strips whitespace from left, right or both. -ltrim(Str) -> - lists:dropwhile(fun white_space/1, Str). -rtrim(Str) -> - lists:reverse(ltrim(lists:reverse(Str))). -trim(Str) -> - rtrim(ltrim(Str)). - -white_space($ ) -> true; -white_space(C) when C<$ -> true; -white_space($\n) -> true; -white_space($\t) -> true; -white_space(_) -> false. - -%% join(Strings, With) -> string() -join([H1, H2| T], S) -> - H1 ++ S ++ join([H2| T], S); -join([H], _) -> - H; -join([], _) -> - []. - -%%--Other--------------------------------------------------------------- - -%% fknidx(FNdef0, Fn_arity_sep) -> string() -%% Get me the function name and arity. -fknidx(FNdef0, Fn_arity_sep) -> - FNdef = string:strip(FNdef0), - case string:tokens(FNdef,"(") of - [FNdef] -> - %% No parentheses, assume variable: remove nl:s at end, - %% and strip blanks. - string:strip(string:strip(FNdef, right, $\n)); - [Name0|Args0] -> - [Args1|_] = string:tokens(string:strip(hd(Args0)), "-"), - Arity = case Args1 of - [$)|_] -> 0; - _ -> - length(string:tokens(Args1, ",")) - end, - string:strip(Name0)++Fn_arity_sep++integer_to_list(Arity) - end. diff --git a/lib/docbuilder/src/docb_util.hrl b/lib/docbuilder/src/docb_util.hrl deleted file mode 100644 index 01ef3f7fca..0000000000 --- a/lib/docbuilder/src/docb_util.hrl +++ /dev/null @@ -1,34 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999-2000, Ericsson -%% Utvecklings AB. All Rights Reserved.'' -%% -%% $Id$ -%% - -%%% For character conversion - --record(in_opts, {expand_entities=false, - encode_filter = fun(X) -> X end}). --record(out_opts, {escape_chars=false, - remove_nl=false, - delete_trailing_whitespace=false, - delete_trailing_nl=false, - compress_white_space=false, - escape_filter = fun(X) -> X end}). - - --define(pcdata_IN, #in_opts{expand_entities=true}). --define(rcdata_IN, #in_opts{expand_entities=true}). --define(cdata_IN, #in_opts{}). - diff --git a/lib/docbuilder/src/docb_xmerl_tree_cb.erl b/lib/docbuilder/src/docb_xmerl_tree_cb.erl deleted file mode 100644 index bc62069230..0000000000 --- a/lib/docbuilder/src/docb_xmerl_tree_cb.erl +++ /dev/null @@ -1,343 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See -%% the Licence for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson AB. -%% Portions created by Ericsson are Copyright 1999-2006, Ericsson AB. -%% All Rights Reserved.�� -%% -%% $Id$ -%% --module(docb_xmerl_tree_cb). - -%% This is the XMerL callback module for exporting XML to the internal -%% tree format used by DocBuilder. -%% {Doc, _Misc} = xmerl_scan:file("file.xml", [{validation,true}]) -%% Tree = xmerl:export([Doc], docb_xmerl_tree_cb) - --export(['#xml-inheritance#'/0]). - --export(['#root#'/4, - '#text#'/1, - '#element#'/5]). --include("xmerl.hrl"). - -%%--Functions used by xmerl--------------------------------------------- - -'#xml-inheritance#'() -> - []. - -'#root#'(Data, _Attrs, [], _E) -> - Data. - -'#text#'(Text) -> - Text2 = strip_leading_blanks(Text), -%% before -%% case Text2 of -%% [$\n|T] -> -%% case is_empty(T) of -%% true -> []; -%% false -> {pcdata, [], nl(Text2)} -%% end; -%% -%% _ -> -%% {pcdata, [], nl(Text2)} -%% end. -%% after - {pcdata, [], nl(Text2)}. - -'#element#'(Tag, Data, Attrs, Parents, _E) when Tag==pre; Tag==code -> - [H|T] = reinsert_nl(Data), - NewData = [strip_nl(H)|T], - NewData2 = case Tag of - code -> - fix_single_pcdata(NewData); - pre -> - NewData - end, - {Tag, attrs(get_dtd(Parents), Tag, Attrs), NewData2}; -'#element#'(Tag, Data, Attrs, Parents, _E) -> - NewData = case tag_content(Tag) of - no_pcdata -> % remove all pcdata - [Dat|| - Dat <- Data, - begin - Fun = fun({pcdata,_,_}) -> false; - (_) -> true end, - Fun(Dat) - end]; - single_pcdata when length(Data)>1 -> - %% merge several pcdata's into one single pcdata - fix_single_pcdata(Data); - _ -> - lists:flatten(Data) - end, - {Tag, attrs(get_dtd(Parents), Tag, Attrs), NewData}. - -%%--Internal functions-------------------------------------------------- - -%% is_empty(Str) -> bool() -%% Returns true if the string Str only contains blanks, tabs and -%% newlines, false otherwise. -%% is_empty("\n" ++ Text) -> -%% is_empty(Text); -%% is_empty("\t" ++ Text) -> -%% is_empty(Text); -%% is_empty(" " ++ Text) -> -%% is_empty(Text); -%% is_empty("") -> -%% true; -%% is_empty(_) -> -%% false. - -%% reinsert_nl(L1) -> L2 -%% Workaround for <pre>: Normally empty lines are ignored. However, -%% Xmerl splits lines whenever it encounters an entity. In the case of -%% <pre>, this may lead to that we ignores what we think is an empty -%% line but is actually a line break that should be kept, for example -%% in this case: -%% <pre> -%% <input>some command</input> <-- this line break is lost! -%% <some result> -%% </pre> -%% This function reinserts line breaks where necessary. -reinsert_nl([[]|T]) -> - [{pcdata,[],"\\n"} | reinsert_nl(T)]; -reinsert_nl([H|T]) -> - [H | reinsert_nl(T)]; -reinsert_nl([]) -> - []. - -%% sgmls treats line breaks in a way that DocBuilder relies on and -%% which must be imitated here. Replace all "\n" with "\\n" and add -%% "\n" to the end of each text element. -nl("") -> - "\n"; -nl("\n"++Text) -> - "\\n"++nl(Text); -nl([Ch|Text]) -> - [Ch|nl(Text)]. - - -%% strip_leading_blanks(Str) -> Str -%% Leading spaces and tabs before a newline are always redundant -%% and are therefore stripped of here -%% If no newline is found the original string is returned unchanged - -strip_leading_blanks(Str) -> - strip_leading_blanks(Str,Str). - -strip_leading_blanks([],Str) -> - Str; -strip_leading_blanks([$\s|T],Str) -> - strip_leading_blanks(T,Str); -strip_leading_blanks([$\t|T],Str) -> - strip_leading_blanks(T,Str); -strip_leading_blanks(Rest=[$\n|_],_) -> - Rest; -strip_leading_blanks(_,Str) -> - Str. - -%% strip_nl(Str) -> Str -%% The XMerL scan will often result in the contents of <pre> or <code> -%% starting with a newline, as the format is normally: -%% <pre> -%% ..contents.. -%% </pre> -%% However, this newline must be removed, or the resulting HTML will be -%% <pre> -%% -%% ..content.. -%% </pre> -strip_nl({pcdata,[],"\\n"++Str}) -> {pcdata,[],Str}; -strip_nl(E) -> E. - -get_dtd([]) -> - none; -get_dtd(Parents) -> - {DTD, _} = lists:last(Parents), - DTD. - -%% attrs(DTD, Tag, GivenAttrs) -> AllAttrs -%% DTD = Tag = atom() DTD and tag name -%% GivenAttrs = [#xmlAttribute{}] -%% AllAttrs = [{Name, Type, Val}] -%% Name = string() (uppercase) Example: "VALIGN" -%% Type = "CDATA" | "TOKEN" -%% Val = string() (uppercase if type is "TOKEN", as-is otherwise) -%% The XMerL scanning of <file>.xml renders only the given attributes. -%% However, DocBuilder needs also the optional attributes (which not -%% necessarily have been given), so we add them here, using the default -%% values according to the DTDs. -%% NOTE: Uses the information from the DTDs. That is, if some change is -%% done to the DTDs, also this file must be updated. Ideally, the DTDs -%% should be parsed automatically in some way. -%% It can also be noted that this check is superfluous in the case where -%% all attributes are required (except that the attributes are sorted -%% in the same order as in the DTD) and where an optional attribute has -%% type "CDATA" as no sensible default value can be specified in this -%% case. -attrs(DTD, Tag, GivenAttrs) -> - merge_attrs(Tag, default_attrs(DTD, Tag), GivenAttrs). - -merge_attrs(Tag, [{NameA, Type, DefVal}|Default], GivenAttrs) -> - Val = case lists:keyfind(NameA, #xmlAttribute.name, GivenAttrs) of - #xmlAttribute{value=Val0} -> Val0; - false -> DefVal - end, - Attr = {attr_name(NameA), Type, attr_val(Type, Val)}, - [Attr | merge_attrs(Tag, Default, GivenAttrs)]; -merge_attrs(_Tag, [], _GivenAttrs) -> - []. - -attr_name(Atom) -> - string:to_upper(atom_to_list(Atom)). - -attr_val("CDATA", Val) -> Val; -attr_val("TOKEN", Val) -> string:to_upper(Val). - -%% Given the DTD and element tag, return a list [{Name, Value}] where -%% Name (atom) is the name of each possible attribute and -%% Value (lowercase string) its default value. -default_attrs(_, cell) -> - [{align, "TOKEN", "left"}, - {valign, "TOKEN", "middle"}]; -default_attrs(_, cite) -> - [{id, "CDATA", ""}]; % required -default_attrs(_, code) -> - [{type, "TOKEN", "none"}]; -default_attrs(_, codeinclude) -> - [{file, "CDATA", ""}, % required - {tag, "CDATA", ""}, - {type, "TOKEN", "none"}]; -default_attrs(book, contents) -> - [{level, "TOKEN", "2"}]; -default_attrs(_, erleval) -> - [{expr, "CDATA", ""}]; % required -default_attrs(report, erlinclude) -> - [{file, "CDATA", ""}, % required - {tag, "CDATA", ""}]; % required -default_attrs(_, fascicule) -> - [{file, "CDATA", ""}, % required - {href, "CDATA", ""}, % required - {entry, "TOKEN", "no"}]; -default_attrs(book, header) -> - [{titlestyle, "TOKEN", "normal"}]; -default_attrs(_, image) -> - [{file, "CDATA", ""}]; % required -default_attrs(_, include) -> - [{file, "CDATA", ""}]; % required -default_attrs(report, index) -> - [{txt, "CDATA", ""}]; % required -default_attrs(_, list) -> - [{type, "TOKEN", "bulleted"}]; -default_attrs(_, marker) -> - [{id, "CDATA", ""}]; % required -default_attrs(book, onepart) -> - [{lift, "TOKEN", "no"}]; -default_attrs(book, parts) -> - [{lift, "TOKEN", "no"}]; -default_attrs(_, path) -> - [{unix, "CDATA", ""}, - {windows, "CDATA", ""}]; -default_attrs(_, seealso) -> - [{marker, "CDATA", ""}]; % required -default_attrs(report, table) -> - [{width, "CDATA", "0"}, - {colspec, "CDATA", ""}]; -default_attrs(_, table) -> - [{align, "TOKEN", "center"}]; -default_attrs(_, term) -> - [{id, "CDATA", ""}]; % required -default_attrs(book, theheader) -> - [{tag, "TOKEN", "none"}]; -default_attrs(bookinsidecover, theheader) -> - [{tag, "TOKEN", "none"}]; -default_attrs(_, url) -> - [{href, "CDATA", ""}]; % required -default_attrs(_, _) -> []. - -%%--Single PCDATA broken into several fix------------------------------- - -%% When text contains an entity, then XMERL splits it into two -%% PCDATA elements, the second starting with the entity. -%% -%% Example: -%% Magnus Fr�berg => [{pcdata,[],"Magnus Fr\n"},{pcdata,[],"�berg\n"}] -%% -%% This is not handled by DocBuilder which expects many tags, for -%% example title and aname, to contain a single PCDATA element. (That -%% is also what nsgmls returned.) - -fix_single_pcdata([{pcdata,[],Str1}, {pcdata,[],Str2}|T]) -> - fix_single_pcdata([{pcdata,[],Str1++Str2}|T]); -fix_single_pcdata(FixedData) -> - FixedData. - -tag_content(aname) -> single_pcdata; -tag_content(app) -> single_pcdata; -tag_content(approved) -> single_pcdata; -tag_content(appsummary) -> single_pcdata; -tag_content(b) -> single_pcdata; -tag_content(c) -> single_pcdata; -tag_content(cauthor) -> single_pcdata; -tag_content(cell) -> mixed_content; -tag_content(checked) -> single_pcdata; -tag_content(chowpublished) -> single_pcdata; -tag_content(code) -> single_pcdata; % mixed? -tag_content(com) -> single_pcdata; -tag_content(comsummary) -> single_pcdata; -tag_content(copyright) -> mixed_content; -tag_content(ctitle) -> single_pcdata; -tag_content(d) -> mixed_content; -tag_content(date) -> single_pcdata; -tag_content(docno) -> single_pcdata; -tag_content(em) -> mixed_content; -tag_content(email) -> single_pcdata; -tag_content(fascicule) -> single_pcdata; -tag_content(file) -> single_pcdata; -tag_content(filesummary) -> single_pcdata; -tag_content(fsummary) -> mixed_content; -tag_content(headline) -> single_pcdata; -tag_content(holder) -> single_pcdata; -tag_content(i) -> single_pcdata; -tag_content(icaption) -> single_pcdata; -tag_content(id) -> single_pcdata; -tag_content(input) -> mixed_content; -tag_content(item) -> mixed_content; -tag_content(legalnotice) -> single_pcdata; -tag_content(lib) -> single_pcdata; -tag_content(libsummary) -> single_pcdata; -tag_content(module) -> single_pcdata; -tag_content(modulesummary) -> single_pcdata; -tag_content(name) -> single_pcdata; -tag_content(nametext) -> single_pcdata; -tag_content(p) -> mixed_content; -tag_content(pagetext) -> single_pcdata; -tag_content(path) -> single_pcdata; % mixed? -tag_content(pre) -> mixed_content; -tag_content(prepared) -> single_pcdata; -tag_content(resp) -> single_pcdata; -tag_content(responsible) -> single_pcdata; -tag_content(ret) -> single_pcdata; -tag_content(rev) -> single_pcdata; -tag_content(seealso) -> single_pcdata; % mixed? -tag_content(shortdef) -> single_pcdata; -tag_content(shorttitle) -> single_pcdata; -tag_content(tag) -> mixed_content; -tag_content(tcaption) -> single_pcdata; -tag_content(termdef) -> single_pcdata; -tag_content(title) -> single_pcdata; -tag_content(url) -> single_pcdata; % mixed -tag_content(v) -> single_pcdata; -tag_content(year) -> single_pcdata; -tag_content(_) -> no_pcdata. - - diff --git a/lib/docbuilder/src/docbuilder.app.src b/lib/docbuilder/src/docbuilder.app.src deleted file mode 100644 index 64c4770964..0000000000 --- a/lib/docbuilder/src/docbuilder.app.src +++ /dev/null @@ -1,37 +0,0 @@ -{application, docbuilder, - [{description, "Tool for building HTML documentation"}, - {vsn, "%VSN%"}, - {modules, [docb_edoc_xml_cb, - docb_gen, - docb_html, - docb_html_layout, - docb_html_ref, - docb_html_util, - docb_html_util_iso, - docb_main, - docb_pretty_format, - docb_tr_application2html, - docb_tr_appref2html, - docb_tr_chapter2html, - docb_tr_cite2html, - docb_tr_comref2html, - docb_tr_cref2html, - docb_tr_erlref2html, - docb_tr_fileref2html, - docb_tr_first2html, - docb_tr_index2html, - docb_tr_part2html, - docb_tr_refs2kwic, - docb_tr_report2html, - docb_tr_term2html, - docb_transform, - docb_util, - docb_xmerl_tree_cb, - docb_xmerl_xml_cb, - docb_xml_check - ]}, - {registered, []}, - {applications, [kernel, stdlib]}, - {env, []}]}. - - diff --git a/lib/docbuilder/src/docbuilder.appup.src b/lib/docbuilder/src/docbuilder.appup.src deleted file mode 100644 index 54a63833e6..0000000000 --- a/lib/docbuilder/src/docbuilder.appup.src +++ /dev/null @@ -1 +0,0 @@ -{"%VSN%",[],[]}. |