From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- lib/docbuilder/src/Makefile | 121 +++ lib/docbuilder/src/docb_edoc_xml_cb.erl | 1163 +++++++++++++++++++++++ lib/docbuilder/src/docb_gen.erl | 138 +++ lib/docbuilder/src/docb_html.erl | 394 ++++++++ lib/docbuilder/src/docb_html_layout.erl | 380 ++++++++ lib/docbuilder/src/docb_html_ref.erl | 79 ++ lib/docbuilder/src/docb_html_util.erl | 543 +++++++++++ lib/docbuilder/src/docb_html_util_iso.erl | 204 ++++ lib/docbuilder/src/docb_main.erl | 651 +++++++++++++ lib/docbuilder/src/docb_pretty_format.erl | 177 ++++ lib/docbuilder/src/docb_tr_application2html.erl | 288 ++++++ lib/docbuilder/src/docb_tr_appref2html.erl | 48 + lib/docbuilder/src/docb_tr_chapter2html.erl | 59 ++ lib/docbuilder/src/docb_tr_cite2html.erl | 136 +++ lib/docbuilder/src/docb_tr_comref2html.erl | 46 + lib/docbuilder/src/docb_tr_cref2html.erl | 61 ++ lib/docbuilder/src/docb_tr_erlref2html.erl | 46 + lib/docbuilder/src/docb_tr_fileref2html.erl | 46 + lib/docbuilder/src/docb_tr_first2html.erl | 46 + lib/docbuilder/src/docb_tr_index2html.erl | 197 ++++ lib/docbuilder/src/docb_tr_part2html.erl | 240 +++++ lib/docbuilder/src/docb_tr_refs2kwic.erl | 156 +++ lib/docbuilder/src/docb_tr_report2html.erl | 70 ++ lib/docbuilder/src/docb_tr_term2html.erl | 126 +++ lib/docbuilder/src/docb_transform.erl | 161 ++++ lib/docbuilder/src/docb_util.erl | 237 +++++ lib/docbuilder/src/docb_util.hrl | 34 + lib/docbuilder/src/docb_xmerl_tree_cb.erl | 343 +++++++ lib/docbuilder/src/docb_xmerl_xml_cb.erl | 88 ++ lib/docbuilder/src/docb_xml_check.erl | 44 + lib/docbuilder/src/docbuilder.app.src | 37 + lib/docbuilder/src/docbuilder.appup.src | 1 + 32 files changed, 6360 insertions(+) create mode 100644 lib/docbuilder/src/Makefile create mode 100644 lib/docbuilder/src/docb_edoc_xml_cb.erl create mode 100644 lib/docbuilder/src/docb_gen.erl create mode 100644 lib/docbuilder/src/docb_html.erl create mode 100644 lib/docbuilder/src/docb_html_layout.erl create mode 100644 lib/docbuilder/src/docb_html_ref.erl create mode 100644 lib/docbuilder/src/docb_html_util.erl create mode 100644 lib/docbuilder/src/docb_html_util_iso.erl create mode 100644 lib/docbuilder/src/docb_main.erl create mode 100644 lib/docbuilder/src/docb_pretty_format.erl create mode 100644 lib/docbuilder/src/docb_tr_application2html.erl create mode 100644 lib/docbuilder/src/docb_tr_appref2html.erl create mode 100644 lib/docbuilder/src/docb_tr_chapter2html.erl create mode 100644 lib/docbuilder/src/docb_tr_cite2html.erl create mode 100644 lib/docbuilder/src/docb_tr_comref2html.erl create mode 100644 lib/docbuilder/src/docb_tr_cref2html.erl create mode 100644 lib/docbuilder/src/docb_tr_erlref2html.erl create mode 100644 lib/docbuilder/src/docb_tr_fileref2html.erl create mode 100644 lib/docbuilder/src/docb_tr_first2html.erl create mode 100644 lib/docbuilder/src/docb_tr_index2html.erl create mode 100644 lib/docbuilder/src/docb_tr_part2html.erl create mode 100644 lib/docbuilder/src/docb_tr_refs2kwic.erl create mode 100644 lib/docbuilder/src/docb_tr_report2html.erl create mode 100644 lib/docbuilder/src/docb_tr_term2html.erl create mode 100644 lib/docbuilder/src/docb_transform.erl create mode 100644 lib/docbuilder/src/docb_util.erl create mode 100644 lib/docbuilder/src/docb_util.hrl create mode 100644 lib/docbuilder/src/docb_xmerl_tree_cb.erl create mode 100644 lib/docbuilder/src/docb_xmerl_xml_cb.erl create mode 100644 lib/docbuilder/src/docb_xml_check.erl create mode 100644 lib/docbuilder/src/docbuilder.app.src create mode 100644 lib/docbuilder/src/docbuilder.appup.src (limited to 'lib/docbuilder/src') diff --git a/lib/docbuilder/src/Makefile b/lib/docbuilder/src/Makefile new file mode 100644 index 0000000000..e8a07a54e8 --- /dev/null +++ b/lib/docbuilder/src/Makefile @@ -0,0 +1,121 @@ +# ``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_edoc_xml_cb.erl b/lib/docbuilder/src/docb_edoc_xml_cb.erl new file mode 100644 index 0000000000..4dba843341 --- /dev/null +++ b/lib/docbuilder/src/docb_edoc_xml_cb.erl @@ -0,0 +1,1163 @@ +%% ``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_edoc_xml_cb). + +%% This is the EDoc callback module for creating DocBuilder erlref +%% documents (man pages) in XML format, and also a DocBuilder chapter +%% document based on "overview.edoc". +%% +%% Usage examples: +%% docb_gen File +%% docb_gen -chapter overview.edoc +%% or (from an Erlang shell) +%% edoc:file(File, [{layout,docb_edoc_xml_cb},{file_suffix,".xml"}, +%% {preprocess,true}]). +%% +%% The origin of this file is the edoc module otpsgml_layout.erl +%% written by Richard Carlsson. + +-export([module/2, overview/2]). + +-include("xmerl.hrl"). + +-define(NL, "\n"). + +%%-User interface------------------------------------------------------- + +%% ERLREF +module(Element, Opts) -> + SortP = proplists:get_value(sort_functions, Opts, true), + XML = layout_module(Element, SortP), + xmerl:export_simple([XML], docb_xmerl_xml_cb, []). + +%% CHAPTER +overview(Element, _Opts) -> + XML = layout_chapter(Element), + xmerl:export_simple([XML], docb_xmerl_xml_cb, []). + +%%--Internal functions-------------------------------------------------- + +layout_module(#xmlElement{name = module, content = Es}=E, SortP) -> + Name = get_attrval(name, E), + Desc = get_content(description, Es), + ShortDesc = text_only(get_content(briefDescription, Desc)), + FullDesc = otp_xmlify(get_content(fullDescription, Desc)), + Types0 = get_content(typedecls, Es), + Types1 = lists:sort([{type_name(Et), Et} || Et <- Types0]), + Functions = + case SortP of + true -> + lists:sort([{function_name(Ef), Ef} || + Ef <- get_content(functions, Es)]); + false -> + [{function_name(Ef), Ef} || + Ef <- get_content(functions, Es)] + end, + Header = {header, [ + ?NL,{title, [Name]}, + ?NL,{prepared, [""]}, + ?NL,{responsible, [""]}, + ?NL,{docno, ["1"]}, + ?NL,{approved, [""]}, + ?NL,{checked, [""]}, + ?NL,{date, [""]}, + ?NL,{rev, ["A"]}, + ?NL,{file, [Name++".xml"]} + ]}, + Module = {module, [Name]}, + ModuleSummary = {modulesummary, ShortDesc}, + Description = {description, [?NL|FullDesc]}, + Types = case Types1 of + [] -> []; + _ -> + [?NL, {section,[{title,["DATA TYPES"]}, + {marker,[{id,"types"}],[]}, + ?NL|types(Types1)]}] + end, + Funcs = functions(Functions), + See = seealso_module(Es), + Authors = {authors, authors(Es)}, + {erlref, + [?NL,Header, + ?NL,Module, + ?NL,ModuleSummary, + ?NL,Description] + ++ Types ++ + [?NL,Funcs, + ?NL,See, + ?NL,Authors] + }. + +layout_chapter(#xmlElement{name=overview, content=Es}) -> + Title = get_text(title, Es), + Header = {header, [ + ?NL,{title,[Title]}, + ?NL,{prepared,[""]}, + ?NL,{docno,[""]}, + ?NL,{date,[""]}, + ?NL,{rev,[""]}, + ?NL,{file, ["chapter.xml"]} + ]}, + DescEs = get_content(description, Es), + FullDescEs = get_content(fullDescription, DescEs), + Sections = chapter_ify(FullDescEs, first), + {chapter, [?NL, Header, ?NL | Sections]}. + +chapter_ify([], _) -> + []; +chapter_ify(Es, first) -> + %% Everything up to the first section should be made into + %% plain paragraphs -- or if no first section is found, everything + %% should be made into one + case find_next(h3, Es) of + {Es, []} -> + SubSections = subchapter_ify(Es, first), + [{section, [?NL,{title,["Overview"]}, + ?NL | SubSections]}]; + {FirstEs, RestEs} -> + otp_xmlify(FirstEs) ++ chapter_ify(RestEs, next) + end; +chapter_ify([#xmlElement{name=h3} = E | Es], next) -> + {SectionEs, RestEs} = find_next(h3, Es), + SubSections = subchapter_ify(SectionEs, first), + {Marker, Title} = chapter_title(E), + [{section, [?NL,{marker,[{id,Marker}],[]}, + ?NL,{title,[Title]}, + ?NL | SubSections]} | chapter_ify(RestEs, next)]. + +subchapter_ify([], _) -> + []; +subchapter_ify(Es, first) -> + %% Everything up to the (possible) first subsection should be + %% made into plain paragraphs + {FirstEs, RestEs} = find_next(h4, Es), + otp_xmlify(FirstEs) ++ subchapter_ify(RestEs, next); +subchapter_ify([#xmlElement{name=h4} = E | Es], next) -> + {SectionEs, RestEs} = find_next(h4, Es), + Elements = otp_xmlify(SectionEs), + {Marker, Title} = chapter_title(E), + [{section, [?NL,{marker,[{id,Marker}],[]}, + ?NL,{title,[Title]}, + ?NL | Elements]} | subchapter_ify(RestEs, next)]. + +chapter_title(#xmlElement{content=Es}) -> % name = h3 | h4 + case Es of + [#xmlElement{name=a} = E] -> + {get_attrval(name, E), get_text(E)} + end. + +%%--XHTML->XML transformation------------------------------------------- + +%% otp_xmlify(Es1) -> Es2 +%% Es1 = Es2 = [#xmlElement{} | #xmlText{}] +%% Fix things that are allowed in XHTML but not in chapter/erlref DTDs. +%% 1) lists (