Documentation: 78/2378/27
Sylvestre Ledru [Thu, 28 Oct 2010 16:57:04 +0000 (18:57 +0200)]
==============

Massive improvement of the documentation system:
* Improved navigation in the help browser and the web interface.
* Improved look and feel in the help browser and the web interface.
* Colorisation of the Scilab code.
* In the examples, functions can be clicked to see their help pages.
* Improved maintainability.
* Faster build process (30 to 60 minutes => less than 30 seconds)
* jar, html, chm format

FYI, the previous of the html/javahelp build system remains available

@TODO:
* regenerate modules/helptools/data/configuration/scilab_macros.txt
and modules/helptools/data/configuration/scilab_primitives.txt
a build time
* move package forge => modules
* manage jflex

Change-Id: Ia90f9a8abcef07654658c95595bb0368fb1c5ccd

52 files changed:
scilab/CHANGES_5.3.X
scilab/Makefile.am
scilab/Makefile.in
scilab/modules/helptools/Makefile.am
scilab/modules/helptools/Makefile.in
scilab/modules/helptools/data/configuration/scilab_macros.txt [new file with mode: 0644]
scilab/modules/helptools/data/configuration/scilab_primitives.txt [new file with mode: 0644]
scilab/modules/helptools/data/css/scilab_code.css [new file with mode: 0644]
scilab/modules/helptools/data/css/style.css [new file with mode: 0644]
scilab/modules/helptools/data/template/template_chm.html [new file with mode: 0644]
scilab/modules/helptools/data/template/template_html.html [new file with mode: 0644]
scilab/modules/helptools/data/template/template_javahelp.html [new file with mode: 0644]
scilab/modules/helptools/helptools.iss
scilab/modules/helptools/includes/gw_helptools.h
scilab/modules/helptools/macros/xmltochm.sci
scilab/modules/helptools/macros/xmltoformat.sci
scilab/modules/helptools/sci_gateway/c/gw_helptools.c
scilab/modules/helptools/sci_gateway/cpp/sci_buildDocv2.cpp [new file with mode: 0644]
scilab/modules/helptools/sci_gateway/helptools_gateway.xml
scilab/modules/helptools/src/c/helptools.vcproj
scilab/modules/helptools/src/java/jflex/function.jflex [new file with mode: 0644]
scilab/modules/helptools/src/java/jflex/scilab.jflex [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/CHMDocbookTagConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookElement.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookTagConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookLinkResolver.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookTagConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookElement.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookTagConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocMain.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SynopsisLexer.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateFiller.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/UnhandledDocbookTagException.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/ExternalXMLHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLMathMLHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLSVGHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ExternalImageConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/Image.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ImageConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/LaTeXImageConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/MathMLImageConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/SVGImageConverter.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/AbstractScilabCodeHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLScilabCodeHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLWithStyleScilabCodeHandler.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/ScilabCodeServer.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/ScilabLexer.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/source/ScilabSourceBrowser.java [new file with mode: 0644]
scilab/modules/helptools/src/jni/BuildDocObjectv2.giws.xml [new file with mode: 0644]
scilab/modules/helptools/src/jni/SciDocMain.cpp [new file with mode: 0644]
scilab/modules/helptools/src/jni/SciDocMain.hxx [new file with mode: 0644]

index fa46e99..3f6e92c 100644 (file)
@@ -1,6 +1,17 @@
             Changes between version 5.3.0-beta-4 and 5.3.0 of Scilab
             ========================================================
 
+Documentation:
+==============
+
+Massive improvement of the documentation system:
+* Improved navigation in the help browser and the web interface.
+* Improved look and feel in the help browser and the web interface.
+* Colorisation of the Scilab code.
+* In the examples, functions can be clicked to see their help pages.
+* Improved maintainability.
+* Faster build process (30 to 60 minutes => less than 30 seconds)
+
 License:
 ========
 
index c653899..3650df9 100644 (file)
@@ -150,11 +150,11 @@ if BUILD_HELP
        -@if test -x $(top_builddir)/scilab-bin; then \
                cd $(top_builddir);\
                echo "-- Building documentation (English) --"; \
-               echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'en_US');exit;\"";\
-               LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -l en_US -nouserstartup -e "xmltojar([],[],'en_US');exit;";\
+               echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'en_US');exit;\"";\
+               LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -l en_US -nouserstartup -e "xmltojar([],[],'en_US');exit;";\
                echo "-- Building documentation (French) --"; \
-               echo "SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'fr_FR');exit;\""; \
-               SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e "xmltojar([],[],'fr_FR');exit;"; \
+               echo "SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'fr_FR');exit;\""; \
+               SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e "xmltojar([],[],'fr_FR');exit;"; \
        else \
                echo "Cannot find Scilab-adv-cli binary"; \
        fi
index 8e86454..afc1cb3 100644 (file)
@@ -1656,11 +1656,11 @@ doc:$(top_builddir)/scilab-bin $(top_builddir)/bin/scilab-adv-cli
 @BUILD_HELP_TRUE@      -@if test -x $(top_builddir)/scilab-bin; then \
 @BUILD_HELP_TRUE@              cd $(top_builddir);\
 @BUILD_HELP_TRUE@              echo "-- Building documentation (English) --"; \
-@BUILD_HELP_TRUE@              echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'en_US');exit;\"";\
-@BUILD_HELP_TRUE@              LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -l en_US -nouserstartup -e "xmltojar([],[],'en_US');exit;";\
+@BUILD_HELP_TRUE@              echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'en_US');exit;\"";\
+@BUILD_HELP_TRUE@              LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -l en_US -nouserstartup -e "xmltojar([],[],'en_US');exit;";\
 @BUILD_HELP_TRUE@              echo "-- Building documentation (French) --"; \
-@BUILD_HELP_TRUE@              echo "SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'fr_FR');exit;\""; \
-@BUILD_HELP_TRUE@              SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 DOCBOOK_ROOT=$(DOCBOOK_ROOT) $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e "xmltojar([],[],'fr_FR');exit;"; \
+@BUILD_HELP_TRUE@              echo "SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"xmltojar([],[],'fr_FR');exit;\""; \
+@BUILD_HELP_TRUE@              SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e "xmltojar([],[],'fr_FR');exit;"; \
 @BUILD_HELP_TRUE@      else \
 @BUILD_HELP_TRUE@              echo "Cannot find Scilab-adv-cli binary"; \
 @BUILD_HELP_TRUE@      fi
index 642de2b..7b669a0 100644 (file)
@@ -9,13 +9,14 @@ if BUILD_HELP
 USEANT=1
 
 HELPTOOLS_SOURCES = src/jni/BuildDocObject.cpp \
+       src/jni/SciDocMain.cpp \
        src/jni/GiwsException.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_helptools.c
 
-GATEWAY_CPP_SOURCES = sci_gateway/cpp/sci_buildDoc.cpp
+GATEWAY_CPP_SOURCES = sci_gateway/cpp/sci_buildDoc.cpp sci_gateway/cpp/sci_buildDocv2.cpp
 
-GIWS_WRAPPERS = src/jni/BuildDocObject.giws.xml
+GIWS_WRAPPERS = src/jni/BuildDocObject.giws.xml src/jni/BuildDocObjectv2.giws.xml
 
 libscihelptools_la_LIBADD = $(top_builddir)/modules/jvm/libscijvm.la
 
index af6a89b..066ece3 100644 (file)
@@ -124,16 +124,20 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
 @BUILD_HELP_TRUE@@GUI_TRUE@libscihelptools_la_DEPENDENCIES = $(top_builddir)/modules/jvm/libscijvm.la
 am__libscihelptools_la_SOURCES_DIST = sci_gateway/nogui/nogui.c \
        sci_gateway/c/gw_helptools.c src/jni/BuildDocObject.cpp \
-       src/jni/GiwsException.cpp sci_gateway/cpp/sci_buildDoc.cpp
+       src/jni/SciDocMain.cpp src/jni/GiwsException.cpp \
+       sci_gateway/cpp/sci_buildDoc.cpp \
+       sci_gateway/cpp/sci_buildDocv2.cpp
 @BUILD_HELP_FALSE@@GUI_TRUE@am__objects_1 =  \
 @BUILD_HELP_FALSE@@GUI_TRUE@   libscihelptools_la-nogui.lo
 @BUILD_HELP_TRUE@@GUI_TRUE@am__objects_1 =  \
 @BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-gw_helptools.lo
 @GUI_FALSE@am__objects_1 = libscihelptools_la-nogui.lo
 @BUILD_HELP_TRUE@@GUI_TRUE@am__objects_2 = libscihelptools_la-BuildDocObject.lo \
+@BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-SciDocMain.lo \
 @BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-GiwsException.lo
 @BUILD_HELP_TRUE@@GUI_TRUE@am__objects_3 =  \
-@BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-sci_buildDoc.lo
+@BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-sci_buildDoc.lo \
+@BUILD_HELP_TRUE@@GUI_TRUE@    libscihelptools_la-sci_buildDocv2.lo
 am_libscihelptools_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3)
 libscihelptools_la_OBJECTS = $(am_libscihelptools_la_OBJECTS)
@@ -424,13 +428,14 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 @BUILD_HELP_TRUE@@GUI_TRUE@USEANT = 1
 @BUILD_HELP_TRUE@@GUI_TRUE@HELPTOOLS_SOURCES = src/jni/BuildDocObject.cpp \
+@BUILD_HELP_TRUE@@GUI_TRUE@    src/jni/SciDocMain.cpp \
 @BUILD_HELP_TRUE@@GUI_TRUE@    src/jni/GiwsException.cpp
 
 @BUILD_HELP_FALSE@@GUI_TRUE@GATEWAY_C_SOURCES = sci_gateway/nogui/nogui.c
 @BUILD_HELP_TRUE@@GUI_TRUE@GATEWAY_C_SOURCES = sci_gateway/c/gw_helptools.c
 @GUI_FALSE@GATEWAY_C_SOURCES = sci_gateway/nogui/nogui.c
-@BUILD_HELP_TRUE@@GUI_TRUE@GATEWAY_CPP_SOURCES = sci_gateway/cpp/sci_buildDoc.cpp
-@BUILD_HELP_TRUE@@GUI_TRUE@GIWS_WRAPPERS = src/jni/BuildDocObject.giws.xml
+@BUILD_HELP_TRUE@@GUI_TRUE@GATEWAY_CPP_SOURCES = sci_gateway/cpp/sci_buildDoc.cpp sci_gateway/cpp/sci_buildDocv2.cpp
+@BUILD_HELP_TRUE@@GUI_TRUE@GIWS_WRAPPERS = src/jni/BuildDocObject.giws.xml src/jni/BuildDocObjectv2.giws.xml
 @BUILD_HELP_TRUE@@GUI_TRUE@libscihelptools_la_LIBADD = $(top_builddir)/modules/jvm/libscijvm.la
 @BUILD_HELP_TRUE@@GIWS_TRUE@@GUI_TRUE@BUILT_SOURCES = giws
 pkglib_LTLIBRARIES = libscihelptools.la
@@ -684,9 +689,11 @@ distclean-compile:
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-BuildDocObject.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-GiwsException.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-SciDocMain.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-gw_helptools.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-nogui.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-sci_buildDoc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihelptools_la-sci_buildDocv2.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -751,6 +758,13 @@ libscihelptools_la-BuildDocObject.lo: src/jni/BuildDocObject.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihelptools_la-BuildDocObject.lo `test -f 'src/jni/BuildDocObject.cpp' || echo '$(srcdir)/'`src/jni/BuildDocObject.cpp
 
+libscihelptools_la-SciDocMain.lo: src/jni/SciDocMain.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihelptools_la-SciDocMain.lo -MD -MP -MF $(DEPDIR)/libscihelptools_la-SciDocMain.Tpo -c -o libscihelptools_la-SciDocMain.lo `test -f 'src/jni/SciDocMain.cpp' || echo '$(srcdir)/'`src/jni/SciDocMain.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihelptools_la-SciDocMain.Tpo $(DEPDIR)/libscihelptools_la-SciDocMain.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/jni/SciDocMain.cpp' object='libscihelptools_la-SciDocMain.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihelptools_la-SciDocMain.lo `test -f 'src/jni/SciDocMain.cpp' || echo '$(srcdir)/'`src/jni/SciDocMain.cpp
+
 libscihelptools_la-GiwsException.lo: src/jni/GiwsException.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihelptools_la-GiwsException.lo -MD -MP -MF $(DEPDIR)/libscihelptools_la-GiwsException.Tpo -c -o libscihelptools_la-GiwsException.lo `test -f 'src/jni/GiwsException.cpp' || echo '$(srcdir)/'`src/jni/GiwsException.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihelptools_la-GiwsException.Tpo $(DEPDIR)/libscihelptools_la-GiwsException.Plo
@@ -765,6 +779,13 @@ libscihelptools_la-sci_buildDoc.lo: sci_gateway/cpp/sci_buildDoc.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihelptools_la-sci_buildDoc.lo `test -f 'sci_gateway/cpp/sci_buildDoc.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_buildDoc.cpp
 
+libscihelptools_la-sci_buildDocv2.lo: sci_gateway/cpp/sci_buildDocv2.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihelptools_la-sci_buildDocv2.lo -MD -MP -MF $(DEPDIR)/libscihelptools_la-sci_buildDocv2.Tpo -c -o libscihelptools_la-sci_buildDocv2.lo `test -f 'sci_gateway/cpp/sci_buildDocv2.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_buildDocv2.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihelptools_la-sci_buildDocv2.Tpo $(DEPDIR)/libscihelptools_la-sci_buildDocv2.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_buildDocv2.cpp' object='libscihelptools_la-sci_buildDocv2.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihelptools_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihelptools_la-sci_buildDocv2.lo `test -f 'sci_gateway/cpp/sci_buildDocv2.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_buildDocv2.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/scilab/modules/helptools/data/configuration/scilab_macros.txt b/scilab/modules/helptools/data/configuration/scilab_macros.txt
new file mode 100644 (file)
index 0000000..72f5dcf
--- /dev/null
@@ -0,0 +1,1993 @@
+tbx_build_macros
+tbx_builder_macros
+tbx_builder
+tbx_build_help_loader
+tbx_builder_help_lang
+tbx_build_help
+tbx_build_gateway_loader
+tbx_builder_src_lang
+tbx_build_gateway
+tbx_builder_help
+tbx_builder_gateway
+tbx_build_src
+tbx_build_gateway_clean
+tbx_builder_src
+tbx_build_loader
+tbx_builder_gateway_lang
+tbx_build_cleaner
+apropos
+add_help_chapter
+help_from_sci
+help_skeleton
+del_help_chapter
+xmltops
+manedit
+xmltoformat
+xmltojar
+xmltopdf
+del_module_help_chapter
+check_help
+xmltohtml
+xmlfiletohtml
+clean_help
+help
+extract_help_examples
+add_module_help_chapter
+find_links
+xmltochm
+edit_error
+getDiagramVersion
+xcos_simulate
+loadScicosLibs
+xcosConfigureModelica
+xcos_close
+xcos_compile
+generateBlockImage
+importScicosDiagram
+xcosBlockEval
+errorDiagramPath
+xcosPalAdd
+xcosPalAddBlock
+xcosPalExport
+%diagram_xcos
+xcosBlockInterface
+xcos_open
+xcosPal
+xcosCodeGeneration
+getModelicaPath
+importXcosDiagram
+closeDiagramPath
+generateBlockImages
+importScicosPal
+openDiagramPath
+xcosClearBlockWarning
+xcosShowBlockWarning
+xcos_run
+ReadmiMatrix
+WritemiMatrix
+loadmatfile
+savematfile
+atomsGui
+cbAtomsGui
+atomsDepTreeShow
+atomsAutoloadDel
+atomsRepositoryAdd
+atomsRepositoryDel
+atomsInstall
+atomsSystemInit
+atomsAutoload
+atomsSetConfig
+atomsRemove
+atomsRepositoryList
+atomsUpdate
+atomsLoad
+atomsShow
+atomsSearch
+atomsIsInstalled
+atomsSystemUpdate
+atomsIsLoaded
+atomsVersion
+atomsTest
+atomsAutoloadAdd
+atomsAutoloadList
+atomsGetLoaded
+atomsCategoryList
+atomsGetLoadedPath
+atomsGetInstalled
+atomsList
+init_param
+remove_param
+list_param
+set_param
+get_param
+is_param
+add_param
+temp_law_vfsa
+temp_law_fsa
+neigh_func_fsa
+temp_law_csa
+compute_initial_temp
+neigh_func_default
+accept_func_vfsa
+neigh_func_vfsa
+optim_sa
+neigh_func_csa
+temp_law_huang
+temp_law_default
+accept_func_default
+pareto_filter
+coding_ga_binary
+mutation_ga_binary
+mutation_ga_default
+optim_nsga2
+init_ga_default
+optim_nsga
+selection_ga_elitist
+optim_ga
+crossover_ga_default
+optim_moga
+crossover_ga_binary
+selection_ga_random
+coding_ga_identity
+convert_to_float
+ana_style
+scisptdemo
+condestsp
+test_on_columns
+cond2sp
+PlotSparse
+rafiter
+replace_Ix_by_Fx
+ReadHBSparse
+scicos
+lincos
+steadycos
+scicos_simulate
+scicos_demonstration
+create_gif
+initial_scicos_tables
+get_scicos_version
+create_palette
+find_scicos_version
+returntoscilab
+fixedpointgcd
+with_modelica_compiler
+scilab2scicos
+xcos_workspace_init
+scicos_getvalue
+write_csv
+read_csv
+readxls
+demo_begin
+demo_function_choice
+demo_folder_choice
+demo_mdialog
+demo_gui
+demo_file_choice
+demo_viewCode
+demo_compiler
+demo_choose
+demo_run
+demo_message
+demo_end
+launchtest
+nonreg_test_run
+test_run
+unit_test_run
+scitest
+devtools_run_builder
+bench_run
+test_clean
+testexamples
+auread
+savewave
+mapsound
+lin2mu
+playsnd
+soundsec
+wavwrite
+mu2lin
+auwrite
+wavread
+sound
+loadwave
+analyze
+addmenus
+plotout
+texout
+TCL_CreateSlave
+config
+gettklib
+winclose
+sciGUI_init
+winlist
+translatepaths
+cb_m2sci_gui
+matfile2sci
+mfile2sci
+m2sci_gui
+sci2map
+mtlb_grid
+mtlb_logical
+mtlb_strcmp
+%s_l_b
+%b_p_s
+mtlb_int16
+mtlb_std
+mtlb_qz
+mtlb_colordef
+mtlb_true
+mtlb_strfind
+mtlb_rand
+mtlb_rcond
+mtlb_fftshift
+mtlb_eval
+%b_s_s
+mtlb_linspace
+mtlb_cumsum
+mtlb_uint16
+mtlb_eye
+sci_sparse
+%s_x_b
+mtlb_toeplitz
+mtlb_uint32
+%b_l_b
+mtlb_strrep
+mtlb_sscanf
+mtlb_full
+%b_prod
+mtlb_beta
+%b_a_b
+mtlb_randn
+%msp_m_s
+%msp_e
+mtlb_sortrows
+mtlb
+%msp_nnz
+mtlb_fread
+%b_x_b
+mtlb_sprintf
+mtlb_min
+mstr2sci
+%s_m_msp
+mtlb_box
+mtlb_sum
+mtlb_diff
+mtlb_double
+mtlb_legendre
+mtlb_all
+%msp_t
+mtlb_diag
+mtlb_delete
+%msp_maxi
+asciimat
+mtlb_isfield
+mtlb_l
+mtlb_semilogx
+%s_f_b
+mtlb_choices
+mtlb_any
+%b_a_s
+%b_sum
+mtlb_close
+mtlb_axes
+mtlb_realmin
+mtlb_fft
+mtlb_logic
+mtlb_dir
+%b_x_s
+mtlb_meshdom
+mtlb_exist
+mtlb_mesh
+mtlb_strcmpi
+fseek_origin
+mtlb_tril
+mtlb_var
+%b_r_b
+mtlb_realmax
+mtlb_ifft
+mtlb_findstr
+mtlb_int8
+mtlb_a
+mtlb_mean
+mtlb_hold
+mtlb_e
+%msp_sparse
+%b_s_b
+%b_f_s
+mtlb_semilogy
+%s_s_b
+mtlb_false
+mtlb_error
+mtlb_upper
+mtlb_triu
+%s_m_b
+mtlb_i
+mtlb_setstr
+%s_p_b
+mtlb_echo
+mtlb_int32
+mtlb_cov
+mtlb_filter
+mtlb_uint8
+%msp_length
+mtlb_prod
+enlarge_shape
+mtlb_cond
+mtlb_fscanf
+mtlb_is
+%msp_abs
+%s_r_b
+mtlb_size
+mtlb_subplot
+mtlb_fliplr
+mtlb_lower
+%b_l_s
+mtlb_dec2hex
+mtlb_0
+mtlb_s
+mtlb_fopen
+mtlb_t
+mtlb_image
+mtlb_fwrite
+mtlb_type
+firstnonsingleton
+mtlb_fprintf
+%b_cumsum
+mtlb_format
+mtlb_zeros
+mtlb_axis
+mtlb_sort
+mtlb_max
+mtlb_plot
+mtlb_get
+%s_c_b
+%b_cumprod
+mtlb_ones
+mtlb_isletter
+mtlb_conv
+%msp_find
+%s_a_msp
+mtlb_isa
+mtlb_repmat
+makecell
+mtlb_isspace
+%msp_a_s
+%s_d_b
+mtlb_median
+mtlb_find
+mtlb_loglog
+%b_m_s
+%b_m_b
+mtlb_cumprod
+mtlb_num2str
+mtlb_imp
+char
+%b_d_s
+%s_a_b
+mtlb_more
+%b_r_s
+%b_c_s
+mtlb_qr
+mtlb_pcolor
+center
+nancumsum
+wcenter
+pca
+cmoment
+nansum
+mvcorrel
+stdevf
+ftest
+covar
+thrownan
+mean
+samplef
+ftuneq
+st_deviation
+mad
+sample
+perctl
+msd
+stdev
+moment
+median
+correl
+nanmax
+meanf
+samwr
+variancef
+nanmeanf
+nanmean
+nfreq
+mvvacov
+princomp
+quart
+harmean
+variance
+show_pca
+nanstdev
+iqr
+nanmedian
+geomean
+regress
+strange
+nand2mean
+nanmin
+tabul
+trimmean
+toc
+date
+tic
+datenum
+datevec
+eomday
+calendar
+now
+isLeapYear
+weekday
+etime
+clock
+blanks
+expression2code
+format_txt
+strcmpi
+arobasestring2strings
+tokenpos
+%_strsplit
+justify
+instruction2code
+tree2code
+isnum
+ascii2string
+cat_code
+sci2exp
+eval
+evstr
+rhs2code
+erfinv
+sprand
+spzeros
+pcg
+qmr
+issparse
+gmres
+adj2sp
+speye
+sp2adj
+mfft
+cheb1mag
+cspect
+mrfit
+iirlp
+zpell
+system
+iirgroup
+iir
+sincd
+find_freq
+buttmag
+czt
+ifft
+sskf
+yulewalk
+wigner
+filt_sinc
+phc
+hank
+%sn
+%asn
+zpbutt
+kalm
+wiener
+lev
+eqiir
+levin
+zpch2
+lindquist
+intdec
+fft2
+frfit
+remezb
+fftshift
+trans
+dft
+srfaur
+faurre
+hilbert
+chepol
+group
+iirmod
+ffilt
+lattn
+frmag
+srkf
+findm
+jmat
+zpch1
+bilt
+detrend
+cepstrum
+analpf
+fsfirlin
+eqfir
+window
+convol
+mese
+ell1mag
+filter
+%k
+pspect
+casc
+hilb
+cheb2mag
+wfir
+coffg
+denom
+htrianr
+pdiv
+horner
+determ
+sylm
+gcd
+cmndred
+colcompr
+invr
+lcm
+pfactors
+inv_coeff
+factors
+hrmt
+pol2des
+rowcompr
+polfact
+pol2str
+derivat
+hermit
+detr
+numer
+systmat
+diophant
+lcmdiag
+%st_i_c
+%hm_exp
+%ce_i_st
+%lss_o_s
+%p_m_hm
+%hm_m_s
+%sp_a_sp
+%r_s_p
+%p_n_l
+%sp_q_sp
+%lss_s_p
+%l_o_p
+%r_tril
+%p_i_r
+%hm_sign
+%s_s_sp
+%l_o_s
+%s_i_hm
+%hm_g_hm
+%hm_f_hm
+%hm_h_hm
+%p_cumsum
+%st_i_spb
+%r_s_r
+%r_size
+%c_matrix
+%r_y_r
+%hm_floor
+%hm_j_hm
+%spb_e
+%l_o_l
+%p_k_p
+%b_g_s
+%sp_l_sp
+%lss_i_r
+%p_c_lss
+%p_m_r
+%hm_int
+%ce_e
+%hm_5
+%r_s
+%c_i_ce
+%lss_m_r
+%s_o_st
+%b_i_s
+%p_c_r
+%sp_f_s
+%r_v_s
+%r_s_s
+%s_f_cblock
+%s_r_p
+%c_ones
+%p_z_p
+%r_d_r
+%st_n_s
+%p_o_lss
+%p_i_p
+%sp_sqrt
+%b_i_ce
+%p_v_r
+%c_i_hm
+%s_s_hm
+%i_ascii
+%p_r_p
+%r_s_hm
+%p_l_lss
+%msp_i_s
+%lss_a_lss
+%hm_k_hm
+%s_i_ce
+%choose
+%m_n_l
+%hm_and
+%spb_i_b
+%s_q_sp
+%st_i_msp
+%c_i_c
+%p_v_p
+%p_k_r
+%st_i_st
+%hm_mean
+%s_l_r
+%hm_s
+%lss_o_lss
+%s_x_hm
+%st_f_st
+%st_i_fptr
+%r_r_lss
+%hm_real
+%r_o_r
+%r_o_p
+%lss_f_s
+generic_i_h
+%r_string
+%r_p
+%hm_isreal
+%lss_n_p
+%lss_v_lss
+%s_3_hm
+%lss_i_lss
+%l_i_s
+%p_k_s
+%lss_n_s
+%s_q_r
+%hm_x_hm
+%st_i_i
+%spb_prod
+%hm_2_hm
+%p_f_lss
+%r_o_s
+%s_s_ip
+%r_c_lss
+%xls_e
+%lss_l_s
+%c_b_s
+%s_e
+%r_f_s
+%r_prod
+%p_y_p
+%r_l_s
+%b_h_s
+%st_i_s
+%hm_i_b
+%c_o_l
+%sp_cumsum
+%s_s_r
+%sp_sum
+%hm_2_s
+%s_r_s
+%p_y_r
+%spb_cumprod
+%r_l_p
+%s_l_lss
+%r_l_r
+%l_o_st
+%st_string
+%sp_s_s
+%spb_i_ce
+%lss_l_p
+%b_i_sp
+%s_c_cblock
+%champdat_i_h
+%i_x_i
+%b_i_b
+%st_o_c
+%st_6
+%s_y_sp
+%hm_median
+%p_cumprod
+%st_o_p
+%r_s_lss
+%hm_r_s
+%sp_triu
+%lss_s_r
+%lss_i_s
+%p_i_h
+%hm_find
+st_i_generic
+%s_c_r
+%cblock_e
+%i_gcd
+%r_n_lss
+%s_or
+%r_l_lss
+%p_det
+%ip_o_ip
+%c_e
+%p_d_s
+%r_f_lss
+%i_length
+%hm_ones
+%hm_ceil
+%r_triu
+%s_r_lss
+%spb_diag
+%r_diag
+%r_i_st
+%ce_i_ce
+%r_d_p
+%r_x_p
+%s_h_b
+%b_diag
+%lss_f_lss
+%hm_size
+%lss_r_lss
+%hm_i_s
+%p_v_s
+%r_eye
+%i_e
+%mc_i_s
+%l_n_l
+%r_v_lss
+%s_x_r
+%i_a_i
+%hm_1_hm
+%spb_sum
+%s_m_r
+%msp_i_st
+%p_y_s
+%l_i_h
+%s_o_hm
+%ce_6
+%spb_or
+%ce_p
+%lss_c_r
+%ip_m_s
+%c_eye
+%p_d_p
+%r_m_lss
+%lss_s
+%s_and
+%p_s_r
+%i_lcm
+%sp_d_s
+%st_i_lss
+%s_r_sp
+%hm_cumsum
+%sp_int
+%r_a_lss
+%lss_n_lss
+%s_f_sp
+%hm_e
+%st_o_s
+%b_triu
+%spb_triu
+%p_q_s
+%c_b_c
+%r_n_s
+%p_o_l
+%sp_sin
+%st_i_ip
+%ip_i_st
+%msp_n_msp
+%msp_spones
+%xlssheet_p
+%s_n_lss
+%r_p_s
+%st_n_mc
+%s_n_r
+%p_a_lss
+%s_l_hm
+%sp_i_ce
+%r_e
+%spb_i_h
+%lss_r_p
+%st_o_l
+%p_n_r
+%sp_c_s
+%i_i_s
+generic_i_st
+%sp_y_sp
+%s_m_lss
+%l_n_s
+%p_q_r
+%s_i_h
+%ip_s_s
+%sp_s_sp
+%lss_s_lss
+%sp_z_sp
+%sp_r_s
+%p_f_r
+%p_o_r
+%cblock_size
+%r_det
+%r_q_p
+%s_i_p
+%st_i_h
+%s_f_r
+%i_d_i
+%spb_h_b
+%sp_p_s
+%c_rand
+%b_h_spb
+%sp_k_sp
+%hm_isnan
+%xlssheet_e
+%lss_m_p
+%l_n_st
+%r_rand
+%hm_d_hm
+%p_x_hm
+%hm_string
+%sp_ceil
+%i_bezout
+%st_n_c
+%lss_l_r
+%p_l_s
+%hm_1_s
+%lss_inv
+%s_v_r
+%b_f_spb
+%spb_h_spb
+%s_l_s
+%spb_tril
+%spb_g_spb
+%r_f_r
+%st_t
+%s_h_s
+%st_i_p
+%hm_3_hm
+%st_p
+%sp_i_sp
+%xls_p
+%hm_a_s
+%hm_a_hm
+%r_r_s
+%hm_m_r
+%3d_i_h
+%i_i_i
+%st_i_sp
+%p_v_lss
+%hm_bool2s
+%c_tril
+%lss_t
+%s_a_hm
+%hm_s_r
+%sp_or
+%s_m_hm
+%sp_length
+%hm_i_ce
+%s_y_p
+%lss_r_s
+%hm_cos
+%hm_s_hm
+%sp_norm
+%p_i_ce
+%hm_o_hm
+%hm_j_s
+%b_i_h
+%r_simp
+%s_f_lss
+%c_triu
+%r_i_p
+%hm_i_r
+%hm_m_p
+%sp_z_s
+%r_sum
+%sp_tril
+%s_q_p
+%r_n_p
+%lss_v_s
+%s_k_hm
+%hm_k_s
+%s_d_sp
+%p_r_s
+%l_n_p
+%s_pow
+%sp_cos
+%dir_p
+%hm_i_p
+%l_o_c
+%hm_abs
+%r_i_s
+%sp_k_s
+%xlssheet_string
+%p_q_p
+%cblock_c_s
+%hm_imag
+%r_z_p
+%hm_degree
+%h_i_st
+%s_b_i
+%c_i_s
+%hm_n_s
+%c_n_st
+%st_n_l
+%c_f_s
+%i_or
+%ce_string
+%sp_y_s
+%s_z_r
+%r_a_s
+%s_i_lss
+%hm_round
+%b_matrix
+%s_n_hm
+%r_o_lss
+%s_a_lss
+%c_n_l
+%s_2_hm
+%r_k_p
+%b_i_spb
+%s_b_s
+%s_l_p
+generic_i_hm
+%s_a_sp
+generic_i_s
+%p_s_lss
+%lss_size
+%r_y_p
+%b_tril
+%r_c_s
+%r_a_p
+%st_i_b
+%r_r_r
+%lss_s_s
+%s_5
+%lt_i_s
+%p_matrix
+%hm_prod
+%ip_p
+%r_c_p
+%s_g_b
+%ce_matrix
+%r_matrix
+%s_s_lss
+%r_m_p
+%i_i_h
+%st_size
+%fptr_i_st
+%r_i_lss
+%hm_i_st
+%lss_r_r
+%r_q_s
+%sp_diag
+%r_k_s
+%r_r_p
+%sp_q_s
+%lss_m_lss
+%b_c_spb
+%hm_cumprod
+%p_sum
+%ce_f_ce
+%lss_l_lss
+%hm_o_s
+%hm_n_hm
+%p_x_r
+%hm_conj
+%ip_a_s
+%b_iconvert
+%s_i_spb
+%p_m_lss
+%p_n_lss
+%c_i_h
+%hm_x_p
+%r_a_r
+%lss_eye
+%lss_o_r
+%lss_i_st
+%s_n_st
+%cblock_f_cblock
+%sp_a_s
+%s_c_lss
+%msp_o_msp
+%s_d_p
+%p_i_hm
+%sp_exp
+%i_r_i
+%sp_r_sp
+%st_i_r
+%s_l_sp
+%p_a_r
+%hm_x_s
+%p_simp
+%s_i_c
+%i_s_i
+%sp_and
+%lss_f_p
+%lss_a_s
+%r_m_hm
+%i_h_i
+%hm_log
+%s_i_b
+%r_m_r
+%hm_i_hm
+%r_i_hm
+%spb_c_b
+%c_a_c
+%i_i_hm
+%sp_i_st
+%ip_string
+%s_matrix
+%s_v_s
+%s_d_r
+%r_t
+%s_4_hm
+%hm_st_deviation
+%hm_4_s
+%r_clean
+%lss_m_s
+%r_ones
+%s_i_st
+%r_j_s
+%sp_i_s
+%s_o_lss
+%sp_d_sp
+%spb_g_b
+%lss_v_r
+%st_c_st
+%r_d_s
+%hm_q_hm
+%lss_i_p
+%mc_o_st
+%lss_rand
+%r_norm
+%lss_v_p
+%lss_n_r
+%hm_i_i
+%ce_size
+%r_a_hm
+%s_a_r
+%s_g_s
+%s_k_p
+%0_i_st
+%hm_d_s
+%r_c_r
+%sp_cumprod
+%p_prod
+%lss_c_s
+%c_diag
+generic_i_ce
+%s_i_s
+%sp_floor
+%lss_norm
+%hm_rand
+%i_g_i
+%mc_n_st
+%s_q_hm
+%l_o_m
+%hm_sqrt
+%r_m_s
+%cblock_p
+%hm_zeros
+%sp_e
+%hm_maxi
+%mc_i_st
+%ticks_i_h
+%ar_p
+%spb_i_st
+%lss_c_lss
+%msp_p
+%c_o_st
+%i_round
+%p_i_st
+%hm_o_i
+%sp_i_h
+%lss_f_r
+%i_and
+%b_e
+%r_x_r
+%p_d_r
+%lss_i_ce
+%cblock_c_cblock
+%l_i_st
+%sp_round
+%s_r_r
+%lss_a_r
+%l_n_c
+%p_l_p
+%i_m_i
+%p_e
+%r_cumprod
+%p_p_s
+%p_z_s
+%st_e
+createstruct
+%xlssheet_size
+%r_f_p
+%spb_f_b
+%s_v_p
+%hm_mini
+%s_1_hm
+%s_k_r
+%i_i_st
+%ce_c_ce
+%p_z_r
+%b_i_st
+%st_o_tl
+%r_q_r
+%lss_a_p
+%hm_a_r
+%lss_e
+%s_k_sp
+%b_i_hm
+%r_k_r
+%hm_iconvert
+%p_r_r
+%grayplot_i_h
+%lss_o_p
+%p_r_lss
+%hm_p
+%b_g_spb
+%c_i_st
+%p_i_lss
+%p_string
+%hm_4_hm
+%s_y_r
+%p_o_sp
+%ce_t
+%l_isequal
+%r_i_r
+%ce_i_s
+%hm_3_s
+%hm_matrix
+%c_i_r
+%s_z_p
+%s_c_sp
+%p_j_s
+%st_n_p
+%s_z_sp
+%r_n_r
+%lss_c_p
+%s_i_r
+%m_o_l
+%spb_and
+%sp_inv
+%mc_i_h
+%i_i_ce
+%hm_or
+%p_l_r
+%r_inv
+%s_i_sp
+%s_n_l
+%r_x_s
+%s_a_ip
+%st_o_mc
+%lss_ones
+%b_string
+%hm_sum
+%spb_cumsum
+%s_simp
+%r_v_r
+%s_v_lss
+%r_z_s
+%hm_s_s
+%s_o_l
+%p_inv
+%ip_n_ip
+%i_b_s
+%sp_l_s
+%sp_prod
+%hm_fft
+%c_i_lss
+%r_z_r
+%hm_c_hm
+%r_y_s
+%r_v_p
+%l_n_m
+%s_o_r
+%s_m_ip
+%p_i_s
+%hm_sin
+%r_i_ce
+optimsimplex_setnbve
+optimsimplex_reflect
+%TSIMPLEX_p
+optimsimplex_getx
+optimsimplex_getall
+optimsimplex_fvmean
+optimsimplex_setallfv
+optimsimplex_center
+optimsimplex_xbar
+optimsimplex_shrink
+optimsimplex_setallx
+optimsimplex_compsomefv
+optimsimplex_setn
+optimsimplex_deltafv
+%TSIMPLEX_string
+optimsimplex_setall
+optimsimplex_fvstdev
+optimsimplex_size
+optimsimplex_destroy
+optimsimplex_getfv
+optimsimplex_getnbve
+optimsimplex_getve
+optimsimplex_log
+optimsimplex_computefv
+optimsimplex_getallx
+optimsimplex_setve
+optimsimplex_deltafvmax
+optimsimplex_setx
+optimsimplex_getn
+optimsimplex_dirmat
+optimsimplex_gradientfv
+optimsimplex_print
+optimsimplex_setfv
+optimsimplex_fvvariance
+optimsimplex_sort
+optimsimplex_check
+optimsimplex_getallfv
+optimsimplex_tostring
+optimsimplex_new
+optimbase_configure
+optimbase_set
+optimbase_checkcostfun
+optimbase_terminate
+optimbase_proj2bnds
+optimbase_isfeasible
+optimbase_hasconstraints
+optimbase_display
+%TOPTIM_p
+optimbase_checkx0
+optimbase_histget
+optimbase_stoplog
+optimbase_hasbounds
+optimbase_logshutdown
+optimbase_incriter
+optimbase_outputcmd
+optimbase_cget
+%TOPTIM_string
+optimbase_new
+optimbase_log
+optimbase_logstartup
+optimbase_destroy
+optimbase_get
+optimbase_hasnlcons
+optimbase_isinnonlincons
+optimbase_histset
+optimbase_checkbounds
+optimbase_outstruct
+optimbase_function
+optimbase_isinbounds
+nmplot_historyplot
+fminsearch
+neldermead_log
+%TNMPLOT_p
+neldermead_configure
+nmplot_outputcmd
+neldermead_costf
+nmplot_get
+nmplot_restart
+nmplot_new
+neldermead_search
+nmplot_simplexhistory
+%TNELDER_string
+nmplot_log
+neldermead_new
+neldermead_destroy
+optimget
+optimset
+nmplot_search
+neldermead_restart
+optimplotfunccount
+neldermead_get
+nmplot_cget
+%TNMPLOT_string
+neldermead_cget
+nmplot_contour
+%TNELDER_p
+neldermead_display
+nmplot_display
+nmplot_destroy
+nmplot_configure
+optimplotx
+nmplot_function
+neldermead_function
+neldermead_updatesimp
+optimplotfval
+datafit
+pack
+bvodeS
+numdiff
+list2vec
+lmitool
+unpack
+NDcost
+leastsq
+derivative
+fit_dat
+recons
+lmisolver
+vec2list
+qpsolve
+aplat
+pencost
+karmarkar
+trace
+eigenmarkov
+gschur
+sqroot
+kroneck
+psmall
+orth
+randpencil
+classmarkov
+nlev
+im_inv
+fullrf
+aff2ab
+spantwo
+colcomp
+householder
+rowshuff
+pinv
+projspec
+spaninter
+diff
+linsolve
+rowcomp
+chsolve
+cond
+companion
+polar
+pencan
+quaskro
+proj
+penlaur
+squeeze
+range
+glever
+chfact
+pen2ea
+fullrfk
+rref
+spanplus
+coff
+norm
+sva
+pbig
+cmb_lin
+kernel
+gspec
+genmarkov
+givens
+rank
+jre_path
+check_librarypath
+check_classpath
+ssprint
+printf
+prettyprint
+sprintf
+unix_g
+unix_w
+unix_s
+getscilabkeywords
+unix_x
+input
+halt
+smooth
+interp1
+interpln
+%s_x_i
+%i_l_s
+%s_r_i
+%i_4_s
+%s_l_i
+%i_d_s
+%i_o_s
+%s_a_i
+%i_plot2d2
+%i_j_s
+%i_s_s
+%i_sign
+%s_q_i
+%i_3_s
+%i_Matplot
+%i_plot2d1
+%i_p_s
+%i_m_s
+%i_fft
+%i_r_s
+%s_i_i
+%s_2_i
+%s_n_i
+%i_x_s
+%i_p_i
+%s_p_i
+%s_o_i
+%s_d_i
+%i_contour
+%s_1_i
+%i_a_s
+%i_msprintf
+%i_plot2d
+%i_q_s
+%i_1_s
+%s_j_i
+%i_j_i
+%i_contour2d
+%i_mprintf
+%i_champ
+%i_mfprintf
+%s_s_i
+%i_string
+%s_m_i
+%i_n_s
+%s_4_i
+%i_2_s
+%s_3_i
+%i_champ1
+dllinfo
+G_make
+ilib_compile
+ilib_gen_Make_unix
+findmsvccompiler
+ilib_build
+haveacompiler
+detectmsifort64tools
+ilib_for_link
+VCtoLCCLib
+configure_msifort
+configure_lcc
+with_lcc
+findmsifortcompiler
+ilib_mex_build
+detectmsvc64tools
+chooselcccompiler
+ilib_gen_Make
+configure_msvc
+ilib_gen_loader
+gencompilationflags_unix
+ilib_gen_gateway
+ilib_gen_cleaner
+findlcccompiler
+uiCreateNode
+uiGetParentNode
+uiGetChildrenNode
+uiGetNodePosition
+uiEqualsTree
+uiInsertNode
+uiConcatTree
+uiCreateTree
+uiDeleteNode
+uiFindNode
+uiDumpTree
+getvalue
+figure
+addmenu
+menubar
+close
+x_matrix
+about
+x_choices
+findobj
+clipboard
+createpopup
+struct
+isstruct
+cell
+isfield
+iscellstr
+fieldnames
+iscell
+hypermat
+arl2
+cls2dls
+specfact
+narsimul
+nicholschart
+gtild
+sensi
+smga
+rowinout
+syslin
+minreal
+dt_ility
+parrot
+gamitg
+gcare
+des2tf
+h_norm
+minss
+chart
+cont_frm
+dsimul
+calfrq
+hallchart
+trfmod
+bilin
+nehari
+lft
+sysdiag
+repfreq
+equil1
+statgain
+ss2tf
+ccontrg
+phasemag
+arhnk
+arsimul
+reglin
+armax1
+leqr
+invsyslin
+abcd
+findx0BD
+h_cl
+entropy
+hankelsv
+gfrancis
+ss2ss
+trzeros
+prbs_a
+cont_mat
+csim
+findAC
+lqr
+dhnorm
+unobs
+obsv_mat
+markp2ss
+freson
+kpure
+h2norm
+h_inf
+lin
+abinv
+lyap
+obsvss
+macglov
+solve
+sylv
+m_circle
+sm2ss
+imrep2ss
+linf
+leqe
+obscont
+gfare
+p_margin
+lqe
+pfss
+stabil
+canon
+syssize
+balreal
+projsl
+contrss
+trianfml
+findBDK
+noisegen
+dscr
+sysconv
+observer
+linfn
+inistate
+zgrid
+dcf
+zeropen
+cainv
+frep2tf
+findR
+flts
+arma2p
+bloc2ss
+des2ss
+cfspec
+findABCD
+g_margin
+ctr_gram
+lqg2stan
+ssrand
+krac2
+obs_gram
+h_inf_st
+evans
+lqg
+sdiff
+fourplan
+bloc2exp
+dbphi
+armac
+fspecg
+ddp
+equil
+rowregul
+st_ility
+trisolve
+show_margins
+black
+svplot
+fspec
+sysfact
+time_id
+riccati
+tf2des
+lqg_ltr
+sgrid
+invrs
+bstap
+ui_observer
+epred
+augment
+plzr
+armax
+gainplot
+colinout
+colregul
+ric_desc
+copfac
+dtsi
+routh_t
+bode
+ss2des
+nyquist
+lcf
+tf2ss
+acf
+fstabst
+sm2des
+xs2fig
+xs2emf
+xend
+xinit
+driver
+datatipRemove
+datatipToggle
+datatipGetStruct
+datatipInitStruct
+datatipDefaultDisplay
+datatipSetInterp
+datatipManagerMode
+datatipSetOrientation
+%datatips_p
+orthProj
+datatipRedraw
+datatipMove
+datatipSetStruct
+datatipLookfor
+pixDist
+datatipSetDisplay
+setStringPosition
+datatipCreate
+datatipGetEntities
+datatipRemoveAll
+fac3d
+gda
+surf
+pie
+hsv2rgb
+zlabel
+plotframe
+fgrayplot
+check2dFun
+jetcolormap
+ghdl_fields
+%_plot2d4
+getlinestyle
+springcolormap
+contour
+%_Matplot
+Sfgrayplot
+xselect
+%h_get
+getcolor
+oldplot
+coolcolormap
+%h_delete
+genfac3d
+rgb2name
+%h_matrix
+xinfo
+%_plot2d1
+gca
+title
+fcontour
+setTitleLabelProperty
+%_plot2d3
+fcontour2d
+sd2sci
+barh
+getTitleLabelPropertyNam
+xrpoly
+getSurfPropertyName
+sca
+ged_insert
+xclear
+%_xget
+addcolor
+%_plot3d
+xsave
+ResetFigureDDM
+setSurfProperty
+getColorIndex
+bar
+getfont
+rotate
+xstringl
+%h_load
+rainbowcolormap
+scf
+%_champ1
+pinkcolormap
+getsymbol
+%h_set
+bonecolormap
+graduate
+%h_draw
+histplot
+xnumb
+xlabel
+Sgrayplot
+fplot2d
+clf
+fplot3d1
+polarplot
+twinkle
+barhomogenize
+eval3dp
+contourf
+fchamp
+plot
+sdf
+getmark
+fac3d1
+eval3d
+hotcolormap
+setDefaultColor
+coppercolormap
+%_xtitle
+graycolormap
+square
+%_plot2d2
+edit_curv
+legend
+xbasr
+%_param3d
+scaling
+colordef
+oceancolormap
+titlepage
+%_fec
+paramfplot2d
+gcf
+%_Matplot1
+%h_copy
+whitecolormap
+replot
+%h_save
+ghdl2tree
+%_plot2d
+sda
+errbar
+checkXYPair
+%h_p
+%_xstringb
+color
+TitleLabel
+gr_menu
+%_grayplot
+fplot3d
+getPlotPropertyName
+name2rgb
+projaff
+hsvcolormap
+xsetm
+subplot
+plot3d2
+%_param3d1
+plot3d3
+seteventhandler
+colorbar
+%_champ
+ged
+xload
+wintercolormap
+setPlotProperty
+%h_e
+autumncolormap
+nf3d
+gdf
+locate
+ylabel
+%_xset
+mesh
+secto3d
+getLineSpec
+get_figure_handle
+isoview
+hist3d
+%_plot3d1
+gce
+summercolormap
+dragrect
+milk_drop
+contour2d
+graypolarplot
+legends
+fullfile
+dir
+get_file_path
+scanf
+mdelete
+fprintf
+sscanf
+listfiles
+mkdir
+dispfiles
+rmdir
+fscanf
+dirname
+is_absolute_path
+listvarinfile
+ls
+get_profile
+profile
+recompilefunction
+reset_profiling
+plotprofile
+check_gateways
+bytecodewalk
+macrovar
+warnobsolete
+genlib_old
+showprofile
+remove_profiling
+head_comments
+add_profiling
+createfun
+bytecode
+getd
+listfunctions
+genlib
+fun2string
+get_function_path
+tanhm
+convertindex
+coshm
+setdiff
+num2cell
+toeplitz
+cothm
+atanhm
+pertrans
+bitor
+flipdim
+cellstr
+%_gsort
+csch
+acotd
+acosm
+tand
+vectorfind
+permute
+atanh
+csgn
+logm
+intersect
+bitget
+cotd
+asinhm
+factor
+isempty
+binomial
+modulo
+primes
+asinm
+acoth
+isnan
+asecd
+meshgrid
+asech
+atanm
+ind2sub
+ndims
+%sp_gsort
+IsAScalar
+acsc
+log2
+GLoad
+perms
+csc
+tanh
+ndgrid
+resize_matrix
+log10
+fix
+acsch
+dec2hex
+erfc
+acot
+atand
+erfcx
+sec
+squarewave
+bitset
+nextpow2
+linspace
+sub2ind
+acosd
+inttrap
+acosh
+union
+secd
+complex
+coth
+asec
+cell2mat
+signm
+factorial
+intsplin
+acoshm
+sinc
+erf
+isvector
+lex_sort
+base2dec
+bitcmp
+asind
+pmodulo
+null
+tanm
+cosm
+sinm
+sqrtm
+isinf
+cat
+hex2dec
+sinhm
+logspace
+asinh
+bitand
+bin2dec
+dec2oct
+sind
+oct2dec
+cscd
+sinh
+cosd
+cosh
+cotg
+sech
+bitxor
+unique
+acscd
+dec2bin
+intc
+integrate
+odeoptions
+dae
+daeoptions
+intl
+toolboxes
+with_javasci
+with_macros_source
+typeof
+whos
+perl
+OS_Version
+getshell
+who_user
+check_versions
+check_modules_xml
+ver
+add_demo
+edit
+with_atlas
+whereami
+with_texmacs
+with_tk
+with_pvm
diff --git a/scilab/modules/helptools/data/configuration/scilab_primitives.txt b/scilab/modules/helptools/data/configuration/scilab_primitives.txt
new file mode 100644 (file)
index 0000000..f343bea
--- /dev/null
@@ -0,0 +1,644 @@
+%i_abs
+%i_cumprod
+%i_cumsum
+%i_diag
+%i_matrix
+%i_max
+%i_maxi
+%i_min
+%i_mini
+%i_mput
+%i_p
+%i_prod
+%i_sum
+%i_tril
+%i_triu
+%msp_full
+%msp_spget
+Calendar
+ClipBoard
+Matplot
+Matplot1
+PlaySound
+TCL_DeleteInterp
+TCL_DoOneEvent
+TCL_EvalFile
+TCL_EvalStr
+TCL_ExistArray
+TCL_ExistInterp
+TCL_ExistVar
+TCL_GetVar
+TCL_GetVersion
+TCL_SetVar
+TCL_UnsetVar
+TCL_UpVar
+_
+about
+abs
+acos
+addcb
+addf
+addhistory
+addinter
+amell
+and
+argn
+arl2_ius
+ascii
+asin
+atan
+backslash
+balanc
+banner
+basename
+bdiag
+beep
+besselh
+besseli
+besselj
+besselk
+bessely
+beta
+bezout
+bfinit
+blkfc1i
+blkslvi
+bool2s
+browsevar
+bsplin3val
+buildDoc
+buildouttb
+bvode
+c_link
+calerf
+call
+callblk
+captions
+cd
+cdfbet
+cdfbin
+cdfchi
+cdfchn
+cdff
+cdffnc
+cdfgam
+cdfnbn
+cdfnor
+cdfpoi
+cdft
+ceil
+champ
+champ1
+chdir
+chol
+clean
+clear_pixmap
+clearfun
+clearglobal
+closeEditor
+closeXcos
+code2str
+coeff
+comp
+completion
+conj
+contour2di
+contr
+convstr
+copy
+copyfile
+corr
+cos
+coserror
+createdir
+cshep2d
+ctree2
+ctree3
+ctree4
+cumprod
+cumsum
+curblock
+curblockc
+dasrt
+dassl
+data2sig
+debug
+deff
+definedfields
+degree
+delbpt
+delete
+deletefile
+delip
+delmenu
+det
+dgettext
+dhinf
+diag
+diary
+diffobjs
+disp
+dispbpt
+displayhistory
+disposefftwlibrary
+dlgamma
+dnaupd
+dneupd
+double
+draw
+drawaxis
+drawlater
+drawnow
+dsaupd
+dsearch
+dseupd
+duplicate
+editor
+editvar
+emptystr
+end_scicosim
+ereduc
+errcatch
+errclear
+error
+eval_cshep2d
+exec
+execstr
+exists
+exp
+expm
+exportUI
+export_to_hdf5
+eye
+fadj2sp
+fec
+feval
+fftw
+fftw_flags
+fftw_forget_wisdom
+fftwlibraryisloaded
+file
+fileext
+fileinfo
+fileparts
+filesep
+find
+findBD
+findfiles
+floor
+format
+fort
+fprintfMat
+freq
+frexp
+fromc
+fromjava
+fscanfMat
+fsolve
+fstair
+full
+fullpath
+funcprot
+funptr
+gamma
+gammaln
+geom3d
+get
+get_absolute_file_path
+get_fftw_wisdom
+getblocklabel
+getcallbackobject
+getdate
+getdebuginfo
+getdefaultlanguage
+getdrives
+getdynlibext
+getenv
+getfield
+gethistory
+gethistoryfile
+getinstalledlookandfeels
+getio
+getlanguage
+getlongpathname
+getlookandfeel
+getmd5
+getmemory
+getmodules
+getos
+getpid
+getrelativefilename
+getscicosvars
+getscilabmode
+getshortpathname
+gettext
+getvariablesonstack
+getversion
+glist
+global
+glue
+grand
+grayplot
+grep
+gsort
+gstacksize
+havewindow
+helpbrowser
+hess
+hinf
+historymanager
+historysize
+host
+iconvert
+iconvert
+ieee
+ilib_verbose
+imag
+impl
+import_from_hdf5
+imult
+inpnvi
+int
+int16
+int2d
+int32
+int3d
+int8
+interp
+interp2d
+interp3d
+intg
+intppty
+inttype
+inv
+is_handle_valid
+isalphanum
+isascii
+isdef
+isdigit
+isdir
+isequal
+isequalbitwise
+iserror
+isfile
+isglobal
+isletter
+isreal
+iswaitingforinput
+javaclasspath
+javalibrarypath
+kron
+lasterror
+ldiv
+ldivf
+legendre
+length
+lib
+librarieslist
+libraryinfo
+linear_interpn
+lines
+link
+linmeq
+list
+load
+loadfftwlibrary
+loadhistory
+log
+log1p
+lsq
+lsq_splin
+lsqrsolve
+lsslist
+lstcat
+lstsize
+ltitr
+lu
+ludel
+lufact
+luget
+lusolve
+macr2lst
+macr2tree
+matfile_close
+matfile_listvar
+matfile_open
+matfile_varreadnext
+matfile_varwrite
+matrix
+max
+maxfiles
+maxi
+mclearerr
+mclose
+meof
+merror
+messagebox
+mfprintf
+mfscanf
+mget
+mgeti
+mgetl
+mgetstr
+min
+mini
+mlist
+mode
+model2blk
+mopen
+move
+movefile
+mprintf
+mput
+mputl
+mputstr
+mscanf
+mseek
+msprintf
+msscanf
+mtell
+mtlb_mode
+mtlb_sparse
+mucomp
+mulf
+nearfloat
+newaxes
+newest
+newfun
+nnz
+notify
+number_properties
+ode
+odedc
+oldbesseli
+oldbesselj
+oldbesselk
+oldbessely
+ones
+opentk
+optim
+or
+ordmmd
+parallel_concurrency
+parallel_run
+param3d
+param3d1
+part
+pathconvert
+pathsep
+permutobj
+phase_simulation
+plot2d
+plot2d1
+plot2d2
+plot2d3
+plot2d4
+plot3d
+plot3d1
+pointer_xproperty
+poly
+ppol
+pppdiv
+predef
+print
+printfigure
+printsetupbox
+prod
+progressionbar
+prompt
+qld
+qp_solve
+qr
+raise_window
+rand
+rankqr
+rat
+rcond
+rdivf
+read
+read4b
+readb
+readgateway
+readmps
+real
+realtime
+realtimeinit
+regexp
+relocate_handle
+remez
+removedir
+removelinehistory
+res_with_prec
+resethistory
+residu
+ricc
+ricc_old
+rlist
+roots
+rotate_axes
+round
+rpem
+rtitr
+rubberbox
+save
+saveafterncommands
+saveconsecutivecommands
+savehistory
+schur
+sci_haltscicos
+sci_tree2
+sci_tree3
+sci_tree4
+sciargs
+scicos_debug
+scicos_debug_count
+scicos_time
+scicosim
+scinotes
+sctree
+semidef
+set
+set_blockerror
+set_fftw_wisdom
+set_xproperty
+setbpt
+setdefaultlanguage
+setenv
+setfield
+sethistoryfile
+setlanguage
+setlookandfeel
+setmenu
+sfact
+sfinit
+show_pixmap
+show_window
+showalluimenushandles
+sident
+sig2data
+sign
+simp
+simp_mode
+sin
+size
+slash
+sleep
+sorder
+sparse
+spchol
+spcompack
+spec
+spget
+splin
+splin2d
+splin3d
+spones
+sqrt
+stacksize
+str2code
+strcat
+strchr
+strcmp
+strcspn
+strindex
+string
+stringbox
+stripblanks
+strncpy
+strrchr
+strrev
+strsplit
+strspn
+strstr
+strsubst
+strtod
+strtok
+subf
+sum
+svd
+swap_handles
+symfcti
+syredi
+system_getproperty
+system_setproperty
+ta2lpd
+tan
+taucs_chdel
+taucs_chfact
+taucs_chget
+taucs_chinfo
+taucs_chsolve
+testmatrix
+timer
+tlist
+tohome
+tokens
+toolbar
+toprint
+tr_zer
+tril
+triu
+type
+typename
+uiDisplayTree
+uicontextmenu
+uicontrol
+uigetcolor
+uigetdir
+uigetfile
+uigetfont
+uimenu
+uint16
+uint32
+uint8
+uipopup
+uiputfile
+uiwait
+ulink
+umf_ludel
+umf_lufact
+umf_luget
+umf_luinfo
+umf_lusolve
+umfpack
+unglue
+unix
+unsetmenu
+unzoom
+usecanvas
+user
+var2vec
+varn
+vec2var
+waitbar
+warnBlockByUID
+warning
+where
+whereis
+winsid
+with_embedded_jre
+with_module
+writb
+write
+write4b
+x_choose
+x_choose_modeless
+x_dialog
+x_mdialog
+xarc
+xarcs
+xarrows
+xchange
+xchoicesi
+xclick
+xcos
+xcosConfigureXmlFile
+xcosDiagramClose
+xcosDiagramOpen
+xcosDiagramToHDF5
+xcosPalCategoryAdd
+xcosPalDelete
+xcosPalDisable
+xcosPalEnable
+xcosPalGenerateIcon
+xcosPalLoad
+xcosPalMove
+xdel
+xfarc
+xfarcs
+xfpoly
+xfpolys
+xfrect
+xget
+xgetech
+xgetmouse
+xgraduate
+xgrid
+xlfont
+xls_open
+xls_read
+xname
+xpause
+xpoly
+xpolys
+xrect
+xrects
+xs2bmp
+xs2eps
+xs2gif
+xs2jpg
+xs2pdf
+xs2png
+xs2ppm
+xs2ps
+xs2svg
+xsegs
+xset
+xsetech
+xstring
+xstringb
+xtitle
+zeros
+znaupd
+zneupd
+zoom_rect
diff --git a/scilab/modules/helptools/data/css/scilab_code.css b/scilab/modules/helptools/data/css/scilab_code.css
new file mode 100644 (file)
index 0000000..24f5f12
--- /dev/null
@@ -0,0 +1,96 @@
+.comment {
+ font-style: italic;
+ color: #01a801
+}
+
+.default {
+ font-style: normal;
+ color: #000000
+}
+
+.special {
+ font-style: normal;
+ color: #ffaa00
+}
+
+.constants {
+ font-style: normal;
+ color: #da70d6
+}
+
+.operator {
+ font-style: normal;
+ color: #5c5c5c
+}
+
+.number {
+ font-style: normal;
+ color: #bc8f8f
+}
+
+.fkeyword {
+ font-style: normal;
+ color: #b01813
+}
+
+.skeyword {
+ font-style: normal;
+ color: #a020f0
+}
+
+.ckeyword {
+ font-style: normal;
+ color: #5f9ea0
+}
+
+.command {
+ font-style: normal;
+ color: #32b9b9
+}
+
+.macro {
+ font-style: normal;
+ color: #ae5cb0
+}
+
+a.command {
+ font-style: normal;
+ text-decoration: underline;
+ color: #32b9b9
+}
+
+a.macro {
+ font-style: normal;
+ text-decoration: underline;
+ color: #ae5cb0
+}
+
+.string {
+ font-style: normal;
+ color: #bc8f8f
+}
+
+.id {
+ font-style: normal;
+ color: #000000
+}
+
+.inputoutputargs {
+ font-weight: bold;
+ color: #834310
+}
+
+.functionid {
+ font-weight: bold;
+ color: #000000
+}
+
+.field {
+ font-style: normal;
+ color: #aaaaaa
+}
+
+.openclose {
+ font-style: normal;
+ color: #4a55db
+}
diff --git a/scilab/modules/helptools/data/css/style.css b/scilab/modules/helptools/data/css/style.css
new file mode 100644 (file)
index 0000000..adf63c4
--- /dev/null
@@ -0,0 +1,185 @@
+body {
+    color:#000000;
+    background-color:#ffffff;
+    font-family:sans-serif;
+    font-size:100%;
+    margin:0;
+    padding:0;
+}
+
+.refpurpose {
+    font-size: 110%;
+}
+
+.synopsis {
+    border: 1px solid black;
+    width:80%;
+    padding: 0.5em;
+}
+
+.term {
+    color:#800000;
+    font-size:100%;
+}
+
+h3 {
+    color: #000063;
+    font-weight: bold;
+    font-size:130%;
+    margin-bottom: 10px;
+}
+
+.programlisting {
+    font-family: monospace;
+    font-size: 100%;
+    background-color:#EEEEFF;
+    border-color:#CCCCCC ;
+    border-style:solid;
+    border-width:2px medium;
+    width:80%;
+    color:#333333;
+    line-height:120%;
+    padding:10px;
+}
+
+.literal {
+    font-size: 100%;
+}
+
+a {
+    color:#355F7C;
+    text-decoration:none;
+}
+
+a:hover {
+    text-decoration:underline;
+}
+
+.itemizedlist {
+    list-style-type: disk;
+}
+
+.inline-list li {
+    display: inline;
+    list-style-type: disk;
+}
+
+.vert-list {
+    list-style-type: disk;
+}
+
+pre {
+    margin-bottom: 0px;
+    margin-top: 0px;
+}
+
+.leftpart {
+    position:absolute;
+    float:left;
+    width: 186px;
+    padding: 5px;
+    font-size: smaller;
+}
+
+.content {
+    margin-left: 196px
+}
+
+.container {
+    width:100%
+}
+
+ul.toc li.list-active {
+    list-style-type:disc;
+    font-weight:bold
+}
+
+ul.toc li.parent {
+    font-size: 115%;
+    padding: 5px 0px 5px 11px;
+    border-bottom: 1px solid #cccccc;
+    margin-bottom: 5px
+}
+
+ul.toc li.root {
+    font-size: 135%;
+    padding: 5px 0px 5px 11px;
+    border-bottom: 1px solid #cccccc;
+    margin-bottom: 5px
+}
+
+ul.toc li {
+    font-size: 85%;
+    margin: 1px 0 1px 1px;
+    padding: 1px 0 1px 11px;
+    background-repeat: no-repeat;
+    background-position: center left;
+    list-style-type: circle
+}
+
+.next {
+    float:right
+    text-align: right;
+}
+
+.center {
+    text-align: center;
+}
+
+/* Top and bottom navigation controls on manual pages --------------------- */
+div.manualnavbar {
+    background-color: #E0E0E0;
+       color: inherit;
+       padding: 4px;
+       margin-bottom: 10px;
+}
+div.manualnavbar .prev {
+       padding-right: 4px;
+}
+div.manualnavbar .next {
+    text-align: right;
+       padding-left: 4px;
+}
+
+div.manualnavbar .top {
+       text-align: center;
+            display: block;
+}
+
+div.manualnavbar hr {
+       color: #cccccc;
+       background-color: #cccccc;
+}
+
+/* Footer navigation area ------------------------------------------------- */
+
+#pagefooter {
+       position: relative;
+       font-size: 75%;
+       color: inherit;
+       background-color: #cccccc;
+       width: 100%;
+}
+
+#pagefooterleft {
+       position: absolute;
+       top: 0px;
+       left: 0px;
+       padding: 6px;
+       margin-right: 30%;
+}
+
+#pagefooterright {
+       text-align: right;
+       margin-left: 50%;
+       padding: 6px;
+}
+#footnav {
+       color: inherit;
+       background-color: #9999cc;
+       border-width: 1px 0px;
+       border-color: #333366;
+       border-style: solid;
+       text-align: right;
+       padding-right: 6px;
+}
diff --git a/scilab/modules/helptools/data/template/template_chm.html b/scilab/modules/helptools/data/template/template_chm.html
new file mode 100644 (file)
index 0000000..acb02d0
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
+    <title><!--<title>--> - <!--<subtitle>--></title>
+    <link rel="stylesheet" href="scilab_code.css" type="text/css">
+    <link rel="stylesheet" href="style.css" type="text/css">
+    <!--<start>-->
+    <!--<top>-->
+    <!--<next>-->
+    <!--<previous>-->
+  </head>
+  <body>
+    
+    <!--<content>-->
+    
+  </body>
+</html>
diff --git a/scilab/modules/helptools/data/template/template_html.html b/scilab/modules/helptools/data/template/template_html.html
new file mode 100644 (file)
index 0000000..b4d92b7
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}" lang="{$lang}">
+  <head{$profile}>
+    <title><!--<title>--> <!--<subtitle>--></title>
+    <style type="text/css" media="all">
+      @import url("scilab_code.css");
+      @import url("style.css");
+    </style>
+    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
+    <!--[if IE]><![endif]><![endif]-->
+    <!-- <meta http-equiv="Content-Type" content="text/html; charset={$config['charset']}"/>
+        <link rel="shortcut icon" href="{$_SERVER['STATIC_ROOT']}/favicon.ico" />{$link}
+        $canonical
+        <script type="text/javascript" src="{$_SERVER['STATIC_ROOT']}/userprefs.js"></script>{$base}{$meta}{$moreheadtags}
+        -->
+  </head>
+  <body>
+    <div class="container">
+      <div class="leftpart">
+       <!--<toclist>-->
+      </div>
+      <div class="content">
+
+       <div class="manualnavbar">
+         <span class="next">
+           <!--<next>-->
+         </span>
+         <span class="prev">
+           <!--<previous>-->
+         </span>
+         <hr />
+       </div>
+
+       <!--<content>-->
+
+       <div class="manualnavbar">
+         <span class="next">
+           <!--<next>-->
+         </span>
+         <span class="prev">
+           <!--<previous>-->
+         </span>
+         <hr />
+       </div>
+
+       <div id="footnav">
+         <!--<version>-->
+       </div>
+
+       <div id="pagefooter">
+         <div id="pagefooterleft">
+           <a href="http://www.scilab.org/">Consortium Scilab (DIGITEO)</a><br />
+           Copyright (c) 1989-2010 (INRIA)<br />
+           Copyright (c) 1989-2007 (ENPC)<br />
+           with <a href="http://www.scilab.org/communities/developer_zone/contribute/contributors_list">contributors</a>
+         </div>
+
+         <div id="pagefooterright">
+           Last updated:<br /><!--<generationdate>-->
+           <br /><br /><br />
+         </div>
+       </div>
+      </div>
+    </div>
+  </body>
+</html>
diff --git a/scilab/modules/helptools/data/template/template_javahelp.html b/scilab/modules/helptools/data/template/template_javahelp.html
new file mode 100644 (file)
index 0000000..9ded030
--- /dev/null
@@ -0,0 +1,47 @@
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
+    <title><!--<title>--> - <!--<subtitle>--></title>
+    <style type="text/css" media="all">
+      @import url("scilab_code.css");
+      @import url("style.css");
+    </style>
+  </head>
+  <body>
+    <div class="manualnavbar">
+    <table width="100%"><tr>
+      <td width="30%">
+       <!--<previous>-->
+      </td>
+      <td width="40%" class="center">
+       <!--<top>-->
+      </td>
+      <td width="30%" class="next">
+       <!--<next>-->
+      </td>
+    </tr></table>
+      <hr />
+    </div>
+
+
+
+    <!--<path>-->
+    <br /><br />
+    <!--<content>-->
+
+
+    <div class="manualnavbar">
+    <table width="100%"><tr>
+      <td width="30%">
+       <!--<previous>-->
+      </td>
+      <td width="40%" class="center">
+       <!--<top>-->
+      </td>
+      <td width="30%" class="next">
+       <!--<next>-->
+      </td>
+    </tr></table>
+      <hr />
+    </div>
+  </body>
+</html>
index 175f0d3..3381456 100644 (file)
@@ -74,6 +74,7 @@ Source: modules\{#HELPTOOLS}\css\*.*; DestDir: {app}\modules\{#HELPTOOLS}\css; C
 Source: modules\{#HELPTOOLS}\doc\*.*; DestDir: {app}\modules\{#HELPTOOLS}\doc; Flags: recursesubdirs; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
 Source: modules\{#HELPTOOLS}\schema\*.*; DestDir: {app}\modules\{#HELPTOOLS}\schema; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
 Source: modules\{#HELPTOOLS}\xsl\*.*; DestDir: {app}\modules\{#HELPTOOLS}\xsl; Flags: recursesubdirs; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
+Source: modules\{#HELPTOOLS}\data\*.*; DestDir: {app}\modules\{#HELPTOOLS}\data; Flags: recursesubdirs; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
 ;
 Source: modules\{#HELPTOOLS}\etc\{#HELPTOOLS}.quit; DestDir: {app}\modules\{#HELPTOOLS}\etc; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
 Source: modules\{#HELPTOOLS}\etc\{#HELPTOOLS}.start; DestDir: {app}\modules\{#HELPTOOLS}\etc; Components: {#COMPN_SCILAB} and {#COMPN_JVM_MODULE}
index 6b57776..51bc90f 100644 (file)
@@ -20,6 +20,8 @@ HELPTOOLS_IMPEXP int gw_helptools(void);
 /*--------------------------------------------------------------------------*/ 
 HELPTOOLS_IMPEXP int sci_buildDoc(char *fname,unsigned long fname_len);
 /*--------------------------------------------------------------------------*/ 
+HELPTOOLS_IMPEXP int sci_buildDocv2(char *fname,unsigned long fname_len);
+/*--------------------------------------------------------------------------*/ 
 #endif /*  __GW_HELPTOOLS__ */
 /*--------------------------------------------------------------------------*/
 
index a438c68..1f645e2 100644 (file)
@@ -1,6 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
-// Copyright (C) 2009 DIGITEO - Allan CORNET
+// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+// Copyright (C) 2009-2010 -  DIGITEO - Allan CORNET
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
 function generated_files = xmltochm(dirs,titles,directory_language,default_language)
-       
-       all_scilab_help        = %F;
-       
-       if getos() <> 'Windows' then
-               warning(msprintf(gettext("%s: This function is only supported on Windows platforms.\n"),"xmltochm"));
-               return;
-       end
-       
-       lhs=argn(1);
-       rhs=argn(2);
-       
-       select rhs
-       
-       case 0 then
-               generated_files = xmltoformat("chm");
-               dirs = [];
-               
-       case 1 then
-               generated_files = xmltoformat("chm",dirs);
-
-       case 2 then
-               generated_files = xmltoformat("chm",dirs,titles);
-
-       case 3 then
-               generated_files = xmltoformat("chm",dirs,titles,directory_language);
-
-       case 4 then
-               generated_files = xmltoformat("chm",dirs,titles,directory_language,default_language);
-
-       else
-               error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"),"xmltochm",4));
-       end
-       
-       if (dirs == []) then 
-               all_scilab_help = %T;
-       end
-
-       if getos() == 'Windows' then
-               if (generated_files <> []) then
-                       if (getHHCpath() <> '') then
-                               for i = 1:size(generated_files,'*')
-                                       cmdline = getHHCpath() + ' ' +getshortpathname(generated_files(i));
-                                       [msg,err] = dos(cmdline);
-                                       chm_origin = 'htmlhelp.chm';
-
-                                       chm_name = tokens(generated_files(i),filesep());
-                                       chm_name = chm_name($-1);
-                                       chm_name = chm_name + '.chm';
-
-                                       chm_src = strsubst(generated_files(i),'htmlhelp.hhp',chm_origin);
-                                       dir_src_idx = strindex(chm_src,filesep());
-                                       dir_src_chm = part(chm_src,1:dir_src_idx($));
-                                               
-                                       if all_scilab_help then
-                                               if (i == 1) then
-                                                       dir_dest_chm = part(chm_src,1:dir_src_idx($-2)) + 'chm' + filesep();
-                                               else
-                                                       dir_dest_chm = part(chm_src,1:dir_src_idx($-3)) + 'chm' + filesep();
-                                               end
-                                       else
-                                               dir_dest_chm = part(chm_src,1:dir_src_idx($-3)) + 'chm' + filesep();
-                                       end
-                                       
-                                       chm_destination = dir_dest_chm  + chm_name;
-                                       
-                                       copyfile(chm_src, chm_destination);
-                                       generated_files(i) = chm_destination;
-                               end
-                       else
-                               warning(msprintf(gettext("%s: hhc.exe not found.\n"),"xmltochm"));
-                       end
-               else
-                       warning(msprintf(gettext("%s: no file generate.\n"),"xmltochm"));
-         end   
-       end
-       
-endfunction
 
+  all_scilab_help    = %F;
+
+  if getos() <> "Windows" then
+    warning(msprintf(gettext("%s: This function is only supported on Windows platforms.\n"),"xmltochm"));
+    return;
+  end
+
+  lhs = argn(1);
+  rhs = argn(2);
+
+  select rhs
+
+  case 0 then
+    generated_files = xmltoformat("chm");
+    dirs = [];
+
+  case 1 then
+    generated_files = xmltoformat("chm", dirs);
+
+  case 2 then
+    generated_files = xmltoformat("chm", dirs, titles);
+
+  case 3 then
+    generated_files = xmltoformat("chm", dirs, titles, directory_language);
+
+  case 4 then
+    generated_files = xmltoformat("chm", dirs, titles, directory_language, default_language);
+
+  else
+    error(msprintf(gettext("%s: Wrong number of input argument(s): At most %d expected.\n"), "xmltochm", 4));
+  end
+
+  if (dirs == []) then
+    all_scilab_help = %T;
+  end
+
+  if getos() == "Windows" then
+    if (generated_files <> []) then
+      if (getHHCpath() <> "") then
+        for i = 1:size(generated_files, "*")
+          currentpath = pwd();
+          [path,fname,extension] = fileparts(getshortpathname(generated_files(i)));
+          cd(path);
+          cmdline = getHHCpath() + " " + fname + extension;
+          [msg,err] = dos(cmdline);
+          cd(currentpath);
+          chm_origin = "htmlhelp.chm";
+
+          chm_name = tokens(generated_files(i), filesep());
+          chm_name = chm_name($-1);
+          chm_name = chm_name + '.chm';
+
+          chm_src = strsubst(generated_files(i), "htmlhelp.hhp", chm_origin);
+          dir_src_idx = strindex(chm_src, filesep());
+          dir_src_chm = part(chm_src,1:dir_src_idx($));
+
+          if all_scilab_help then
+            if (i == 1) then
+              dir_dest_chm = part(chm_src,1:dir_src_idx($-2)) + "chm" + filesep();
+            else
+              dir_dest_chm = part(chm_src,1:dir_src_idx($-3)) + "chm" + filesep();
+            end
+          else
+            dir_dest_chm = part(chm_src,1:dir_src_idx($-3)) + "chm" + filesep();
+          end
+
+          chm_destination = dir_dest_chm  + chm_name;
+
+          copyfile(chm_src, chm_destination);
+          generated_files(i) = chm_destination;
+        end
+      else
+        warning(msprintf(gettext("%s: hhc.exe not found.\n"), "xmltochm"));
+      end
+    else
+      warning(msprintf(gettext("%s: no file generate.\n"), "xmltochm"));
+    end
+  end
+
+endfunction
 
 function HHC_path = getHHCpath()
 
   if win64() then
-    std_path = getshortpathname(getenv('ProgramFiles(x86)','') + filesep() + 'HTML Help Workshop' + filesep() + 'hhc.exe');
+    std_path = getshortpathname(getenv("ProgramFiles(x86)", "") + filesep() + "HTML Help Workshop" + filesep() + "hhc.exe");
+  else
+    std_path = getshortpathname(std_path = getenv("ProgramFiles", "") + filesep() + "HTML Help Workshop" + filesep() + "hhc.exe");
+  end
+
+  if (fileinfo(std_path) == []) then
+    HHC_path = "";
   else
-    std_path = getshortpathname(std_path = getenv('ProgramFiles','') + filesep() + 'HTML Help Workshop' + filesep() + 'hhc.exe');
+    HHC_path = std_path;
   end
 
-       if (fileinfo(std_path) == []) then
-         HHC_path = '';
-       else
-         HHC_path = std_path;
-       end
-       
 endfunction
index ef88247..6f8fb30 100644 (file)
@@ -454,7 +454,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
     if all_scilab_help then
 
-        mprintf(_("Building the scilab manual file ["+output_format+"] (Please wait building ... this can take a while)\n"));
+        mprintf(_("Building the scilab manual file ["+output_format+"]\n"));
 
         // Define and create the final output directory if does not exist
         final_output_dir = pathconvert(SCI+"/modules/helptools/"+output_format_ext,%f,%f);
@@ -487,8 +487,8 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
         if is_chm then
             final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
         elseif is_html then
-            final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f);
-        else
+            final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f); 
+       else
             final_help_file = pathconvert(final_output_dir+"/scilab_" + my_wanted_language + "_help." + output_format_ext,%f,%f);
         end
 
@@ -510,8 +510,12 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
         end
 
         // process the build
-        buildDoc(output_format,modules_tree("master_document"),my_wanted_language);
-
+        if output_format=="javaHelp" | output_format=="html" | output_format=="chm" then
+          buildDocv2(output_format,modules_tree("master_document"), my_wanted_language);
+        else
+          buildDoc(output_format,modules_tree("master_document"), my_wanted_language);
+        end
+        
         // Check if the help file has been generated
         if fileinfo(buildDoc_file)==[] then
             error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
@@ -549,7 +553,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
             this_tree  = contrib_tree(dirs_c(k));
 
-            mprintf(_("\nBuilding the manual file [%s] in %s. (Please wait building ... this can take a while)\n"),output_format,strsubst(dirs_c(k),SCI_long,"SCI"));
+            mprintf(_("\nBuilding the manual file [%s] in %s.\n"),output_format,strsubst(dirs_c(k),SCI_long,"SCI"));
 
             // Define and create the final output directory if does not exist
             final_output_dir = pathconvert(dirs_c(k)+"/../../"+output_format_ext,%f,%f);
@@ -604,8 +608,12 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
             end
 
             // process the build
-            buildDoc(output_format,this_tree("master_document"),directory_language_c(k),dirs_c(k));
-
+            if output_format=="javaHelp" | output_format=="html" | output_format=="chm" then
+              buildDocv2(output_format,this_tree("master_document"),directory_language_c(k),dirs_c(k));
+            else
+              buildDoc(output_format,this_tree("master_document"),directory_language_c(k),dirs_c(k));
+            end
+            
             // Check if the help file has been generated
             if fileinfo(buildDoc_file)==[] then
                 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
@@ -657,12 +665,12 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
             if nb_dir > 1 then
                 if displaydone == 0 then
-                    mprintf(_("\nBuilding the manual file [%s]. (Please wait building ... this can take a while)\n"),output_format);
+                    mprintf(_("\nBuilding the manual file [%s].\n"),output_format);
                     displaydone = 1;
                 end
                 mprintf(_("\t%s\n"),strsubst(dirs(k),SCI_long,"SCI"));
             else
-                mprintf(_("\nBuilding the manual file [%s] in %s. (Please wait building ... this can take a while)\n"),output_format,strsubst(dirs(k),SCI_long,"SCI"));
+                mprintf(_("\nBuilding the manual file [%s] in %s.\n"),output_format,strsubst(dirs(k),SCI_long,"SCI"));
             end
 
             // Define and create the final output directory if does not exist
@@ -723,9 +731,13 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
             end
 
             // process the build
-            buildDoc(output_format,this_tree("master_document"),directory_language(k),dirs(k));
+            if output_format=="javaHelp" | output_format=="html" | output_format=="chm" then
+              buildDocv2(output_format,this_tree("master_document"),directory_language(k),dirs(k));
+            else
+              buildDoc(output_format,this_tree("master_document"),directory_language(k),dirs(k));
+             end
 
-            // Check if the help file has been generated
+             // Check if the help file has been generated
             if fileinfo(buildDoc_file)==[] then
                 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
             end
@@ -1365,7 +1377,7 @@ function master_document = x2f_tree_to_master( tree )
 
     // Process the path if under windows
     if getos() == 'Windows' then
-        tree_xmllist(:,2) = "file:///"+ getshortpathname(tree_xmllist(:,2));
+        tree_xmllist(:,2) = "file:///"+ strsubst(getlongpathname(tree_xmllist(:,2)) ,"\","/");
     end
 
     // Add entities
index d067d0c..06cacd1 100644 (file)
@@ -24,7 +24,8 @@ static BOOL loadedDep = FALSE;
 /*--------------------------------------------------------------------------*/
 static gw_generic_table Tab[] =
 {
-       {sci_buildDoc,"buildDoc"}
+       {sci_buildDoc,"buildDoc"},
+       {sci_buildDocv2,"buildDocv2"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_helptools(void)
diff --git a/scilab/modules/helptools/sci_gateway/cpp/sci_buildDocv2.cpp b/scilab/modules/helptools/sci_gateway/cpp/sci_buildDocv2.cpp
new file mode 100644 (file)
index 0000000..179ff29
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2008 - INRIA - Sylvestre LEDRU
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include "SciDocMain.hxx"
+#include "GiwsException.hxx"
+
+extern "C"
+{
+/*--------------------------------------------------------------------------*/
+#include <string.h>
+#include "stack-c.h"
+#include "gw_helptools.h"
+#include "Scierror.h"
+#include "setgetSCIpath.h"
+#include "localization.h"
+#include "setgetlanguage.h"
+#include "getScilabJavaVM.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "ConvertSlash.h"
+#endif
+/*--------------------------------------------------------------------------*/
+#define PATHTOCSS "/modules/helptools/css/javahelp.css"
+#define PATHTOBUILDDOC "/modules/helptools/build/doc/scilab_%s_help/"
+#define PATHTOMASTERXML "/modules/helptools/master_%s_help.xml"
+#define DEFAULTEXPORT "JH"
+#ifdef _MSC_VER
+    static void __slashToAntislash(std::string *in)
+    {
+        size_t found = in->rfind("/");
+
+        while (found != std::string::npos)
+        {
+            in->replace (found, 1, "\\");
+            found = in->rfind("/");
+        }
+    }
+#endif
+/*--------------------------------------------------------------------------*/
+    int sci_buildDocv2(char *fname,unsigned long l)
+    {
+        static int l1 = 0,n1 = 0,m1 = 0;
+        static int l2 = 0,n2 = 0,m2 = 0;
+        static int l3 = 0,n3 = 0,m3 = 0;
+        static int l4 = 0,n4 = 0,m4 = 0;
+        //     static int Row_Output = 0, Col_Output = 0;
+        std::string exportFormat;
+        std::string SciPath = getSCIpath(); /* Scilab path */
+        std::string masterXML; /* Which file contains all the doc stuff */
+        std::string masterXMLTMP;
+        std::string outputDirectory; /* Working directory */
+        std::string outputDirectoryTMP;
+        std::string language;
+        std::string styleSheet; /* the CSS */
+        //     std::string pathToGenerated;
+        org_scilab_forge_scidoc::SciDocMain *doc = NULL;
+
+        CheckRhs(0,4);
+        CheckLhs(1,1);
+
+        styleSheet = SciPath+PATHTOCSS;
+
+        if (Rhs < 1)
+        {
+            exportFormat = DEFAULTEXPORT;
+        }
+        else
+        {
+            if (GetType(1) != sci_strings)
+            {
+                Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname,1);
+                return 0;
+                // Wrong type string
+            }
+                 
+            GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
+            exportFormat = cstk(l1);
+        }
+
+        if ( Rhs < 3) /* Language not provided */
+        {
+            language = getlanguage();
+        }
+        else
+        {
+            GetRhsVar(3,STRING_DATATYPE,&m3,&n3,&l3);
+            if (m3*n3 == 0)
+            {
+                language = getlanguage();
+            }
+            else
+            {
+                language = std::string(cstk(l3));
+            }
+        }
+
+        if (Rhs < 2)
+        {
+            /* Update the path with the localization */
+            masterXMLTMP = std::string("/modules/helptools/master_")+language+std::string("_help.xml");
+            masterXML = SciPath + masterXMLTMP;
+        }
+        else
+        {
+            if (GetType(2) != sci_strings)
+            {
+                // Wrong type string
+                Scierror(999,_("%s: Wrong for type for input argument #%d: String expected.\n"),fname,2);
+                return 0;
+            }
+
+            GetRhsVar(2,STRING_DATATYPE,&m2,&n2,&l2);
+            masterXML = cstk(l2);
+        }
+
+        if (Rhs == 4)
+        {
+            if (GetType(4) == sci_strings)
+            {
+                GetRhsVar(4,STRING_DATATYPE,&m4,&n4,&l4);
+                outputDirectory = std::string(cstk(l4))+std::string("/scilab_")+language+std::string("_help/");
+            }
+            else
+            {
+                Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname,4);
+                return FALSE;
+            }
+        }
+        else /* Scilab help */
+        {
+            /* Update the path with the localization */
+            outputDirectoryTMP = std::string("/modules/helptools/")+std::string(exportFormat)+std::string("/scilab_")+language+std::string("_help/");
+
+            outputDirectory = SciPath+outputDirectoryTMP;
+        }
+
+        try
+        {
+            doc = new org_scilab_forge_scidoc::SciDocMain(getScilabJavaVM());
+
+#ifdef _MSC_VER
+            __slashToAntislash(&outputDirectory);
+            __slashToAntislash(&styleSheet);
+            __slashToAntislash(&masterXML);
+#endif
+
+//            doc->buildDocumentation((char*) exportFormat.c_str());
+
+            if (doc->setOutputDirectory((char *) outputDirectory.c_str()))
+            {
+                doc->setWorkingLanguage((char *) language.c_str());
+                doc->setExportFormat((char *) exportFormat.c_str());
+
+                doc->process((char *) masterXML.c_str(), (char *) styleSheet.c_str());
+            }
+            else
+            {
+                Scierror(999,_("%s: Could find or create the working directory %s.\n"), fname, outputDirectory.c_str());
+                return FALSE;
+            }
+        }
+        catch(GiwsException::JniException ex)
+        {
+            Scierror(999,_("%s: Error while building documentation: %s.\n"), fname, ex.getJavaDescription().c_str());
+            Scierror(999,_("%s: Execution Java stack %s.\n"), fname, ex.getJavaStackTrace().c_str());
+            return FALSE;
+        }
+
+        if (doc != NULL) delete doc;
+        LhsVar(1) = 0 ;
+        C2F(putlhsvar)();
+        return 0;
+    }
+/*--------------------------------------------------------------------------*/
+}
index fdb82f2..f00a80a 100644 (file)
@@ -30,4 +30,5 @@
 -->
 
 <PRIMITIVE gatewayId="60" primitiveId="1" primitiveName="buildDoc" />
+<PRIMITIVE gatewayId="60" primitiveId="2" primitiveName="buildDocv2" />
 </GATEWAY>
index df5c407..a64154f 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <VisualStudioProject
        ProjectType="Visual C++"
        Version="9,00"
@@ -36,6 +36,9 @@
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                        />
                        <Tool
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                                TargetEnvironment="3"
                        />
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                        />
                        <Tool
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                                TargetEnvironment="3"
                        />
                                RelativePath="..\..\sci_gateway\cpp\sci_buildDoc.cpp"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\sci_gateway\cpp\sci_buildDocv2.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\jni\SciDocMain.cpp"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="Header Files"
                                RelativePath=".\resource.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\jni\SciDocMain.hxx"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="localization"
diff --git a/scilab/modules/helptools/src/java/jflex/function.jflex b/scilab/modules/helptools/src/java/jflex/function.jflex
new file mode 100644 (file)
index 0000000..8407eee
--- /dev/null
@@ -0,0 +1,116 @@
+//CHECKSTYLE:OFF
+
+package org.scilab.forge.scidoc ;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+%%
+
+%public
+%class SynopsisLexer
+%final
+%unicode
+%char
+%type void
+
+%switch
+
+%{
+    private static String currentName;
+    private static StringBuilder htmlBuffer = new StringBuilder(512);
+    private static SynopsisLexer lexer = new SynopsisLexer();
+
+    private SynopsisLexer() { }
+
+    public static String convert(String name, String str) {
+        currentName = name;
+        try {
+            lexer.yyreset(new StringReader(str.trim()));
+           lexer.yybegin(YYINITIAL);
+            htmlBuffer.setLength(0);
+           lexer.yylex();
+           
+           return htmlBuffer.toString();
+        } catch (IOException e) {
+            return null;
+        }
+    }
+
+%}
+
+%eofval{
+  return;
+%eofval}
+
+/* main character classes */
+white = [ \t]+
+eol = ("\r" | "\n" | "\r\n"){white}*
+
+id = ([a-zA-Z%_#!?][a-zA-Z0-9_#!$?]*)|("$"[a-zA-Z0-9_#!$?]+)
+
+comments = "//"[^\r\n]*
+
+nothing = [^a-zA-Z%_#!?/\n\r<>&\"\']+ | "/"
+
+dquote = "\""
+quote = "'"
+lt = "<"
+gt = ">"
+amp = "&"
+
+%%
+
+<YYINITIAL> {
+
+  {comments}                     {
+                                   htmlBuffer.append("<span class=\"comment\">");
+                                  htmlBuffer.append(yytext());
+                                  htmlBuffer.append("</span>");
+                                 }
+
+  {id}                          {
+                                  String str = yytext();
+                                  if (str.equals(currentName)) {
+                                     htmlBuffer.append("<span class=\"functionid\">");
+                                  } else {
+                                     htmlBuffer.append("<span class=\"default\">");
+                                  }                            
+                                  htmlBuffer.append(str);
+                                  htmlBuffer.append("</span>");
+                                }
+
+  {dquote}                       {
+                                  htmlBuffer.append("&quot;");
+                                 }
+     
+  {quote}                        {
+                                  htmlBuffer.append("&apos;");
+                                 }
+
+  {lt}                           {
+                                  htmlBuffer.append("&lt;");
+                                 }
+
+  {gt}                           {
+                                  htmlBuffer.append("&gt;");
+                                 }
+
+  {amp}                          {
+                                  htmlBuffer.append("&amp;");
+                                 }
+
+  {white}                       {
+                                  htmlBuffer.append(" ");
+                                }
+
+  {eol}                                 {
+                                  htmlBuffer.append("\n");
+                                }
+
+  {nothing}                      {
+                                   htmlBuffer.append("<span class=\"default\">");
+                                  htmlBuffer.append(yytext());
+                                  htmlBuffer.append("</span>");
+                                 }
+}
diff --git a/scilab/modules/helptools/src/java/jflex/scilab.jflex b/scilab/modules/helptools/src/java/jflex/scilab.jflex
new file mode 100644 (file)
index 0000000..1f061a0
--- /dev/null
@@ -0,0 +1,811 @@
+//CHECKSTYLE:OFF
+
+package org.scilab.forge.scidoc.scilab;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.IOException;
+
+%%
+
+%public
+%class ScilabLexer
+%final
+%unicode
+%char
+%type void
+%switch
+
+%{
+    private static Set<String> commands;
+    private static Set<String> macros;
+
+    private int beginString;
+    private boolean transposable;
+    private boolean breakstring;
+    private boolean breakargs;
+    private int whitesOnFirstLine;
+    private int saveLexState;
+    
+    private String id;
+    private List<String> returnValues = new ArrayList();
+    private List<String> argsValues = new ArrayList();
+    private List<String> localFun = new ArrayList();       
+    
+    private AbstractScilabCodeHandler handler;
+
+    public ScilabLexer(String primFile, String macroFile) {
+       if (commands == null) {
+                 commands = new HashSet();
+         macros = new HashSet();
+          loadNames(primFile, commands);
+                 loadNames(macroFile, macros);
+       }
+    }
+
+    public ScilabLexer(Set primitives, Set macros) {
+       commands = primitives;
+       this.macros = macros;
+    }    
+
+    private void loadNames(String file, Set set) {
+       if (file == null) {
+          return;
+       }
+       BufferedReader input = null;
+       try {
+          input =  new BufferedReader(new FileReader(file));
+          String line = null;
+          while ((line = input.readLine()) != null) {
+            set.add(line);
+          }
+       } catch (IOException e) {
+                 System.err.println(e);
+       }
+       if (input != null) {
+          try {
+            input.close();
+          } catch (IOException e) {
+                    System.err.println(e);
+          }
+       }
+    }
+
+    private String trimEnd(String str) {
+        int end = str.length() - 1;
+       int i = end;
+        for (; i >= 0; i--) {
+          char c = str.charAt(i);      
+          if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
+             break;
+          }
+        }
+       if (i != end) {
+          return str.substring(0, i + 1);
+       }
+
+       return str;
+    }
+
+    public String convert(AbstractScilabCodeHandler h, String code) {
+        Reader reader = new StringReader(trimEnd(code));
+       String str = convert(h, reader, true);
+       try {
+         reader.close();
+       } catch (IOException e) { }
+       
+       return str;
+    }
+
+    public String convert(AbstractScilabCodeHandler h, Reader code, boolean ret) {
+        if (code == null) {
+          return null;
+       } else {
+          handler = h;
+          transposable = false;
+           breakargs = false;
+           breakstring = false;        
+          whitesOnFirstLine = 0;      
+          localFun.clear();
+           yyreset(code);
+          yybegin(CLEANFIRST);
+           try {
+              yylex();
+          } catch (IOException e) {
+              return null;
+          }
+          if (ret) {
+              return h.toString();
+           }
+          return "";
+       }      
+    }
+%}
+
+/* main character classes */
+eol = "\r" | "\n" | "\r\n"
+
+open = "[" | "(" | "{"
+close = "]" | ")" | "}"
+
+comment = "//"
+
+quote = "'"
+
+dquote = "\""
+
+cstes = "%t" | "%T" | "%f" | "%F" | "%e" | "%pi" | "%inf" | "%i" | "%z" | "%s" | "%nan" | "%eps" | "SCI" | "WSCI" | "SCIHOME" | "TMPDIR"
+
+dottransp = ".'"
+lt = "<"
+gt = ">"
+neq = "<>"
+leq = "<="
+geq = ">="
+amp = "&"
+
+operator = ".*" | "./" | ".\\" | ".^" | ".**" | "+" | "-" | "/" | "\\" | "*" | "^" | "**" | "==" | "~=" | ".*." | "./." | ".\\." | "/." | "=" | "|" | "@" | "@=" | "~"
+
+structureKwds = "if" | "for" | "while" | "try" | "select" | "end" | "then" | "do" | "catch" | "case" | "elseif" | "else"
+
+controlKwds = "abort" | "break" | "quit" | "return" | "resume" | "pause" | "continue" | "exit"
+
+break = ".."(".")*
+breakinstring = {break}[ \t]*
+
+special = "$" | ":" | {break}
+
+string = (([^\t\'\"\r\n<>&\.]*)|([\'\"]{2})|("."[^\t\'\"\r\n<>&\.]))+
+
+id = ([a-zA-Z%_#!?][a-zA-Z0-9_#!$?]*)|("$"[a-zA-Z0-9_#!$?]+)
+
+dot = "."
+
+digit = [0-9]
+exp = [dDeE][+-]?{digit}*
+number = ({digit}+"."?{digit}*{exp}?)|("."{digit}+{exp}?)
+
+/* function declaration */
+white = [ \t]+
+funcomments = {white}* "//"
+fun = "function" {white}
+funb = "function["
+endfun = "endfunction"
+
+htmlentity = "&"[#a-zA-Z0-9]*";"
+
+%x QSTRING, COMMENT, FIELD, COMMANDS, COMMANDSWHITE, BREAKSTRING, FUNCTION, TYPEID, FUNNAME, RETS, ARGS, BREAKINARGS, WHITESEOL, CLEANFIRST, CLEAN
+
+%%
+
+<CLEANFIRST> {
+  {white}*{eol}+                { }
+
+  {white}                        {
+                                  whitesOnFirstLine = yylength();
+                                  yybegin(YYINITIAL);
+                                 }
+
+  .                             {
+                                  yypushback(1);
+                                  yybegin(YYINITIAL);
+                                }
+}
+
+<CLEAN> {
+  {eol}+                        {
+                                  handler.handleNothing("\n");
+                                }
+
+  {white}                        {
+                                  int len = yylength() - whitesOnFirstLine;
+                                  if (len > 0) {
+                                     yypushback(len); 
+                                  }
+                                  yybegin(saveLexState);
+                                 }
+
+  .                             {
+                                  yypushback(1);
+                                  yybegin(saveLexState);
+                                }
+}
+
+<YYINITIAL> {
+  {htmlentity}                  {
+                                  transposable = false;
+                                  handler.handleDefault(yytext());   
+                                 } 
+
+  {comment}                      {
+                                   transposable = false;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
+                                 }
+
+  {dottransp}                    {
+                                   transposable = false;
+                                  handler.handleOperator(".&#0039;");
+                                 }
+
+  {lt}                           {
+                                   transposable = false;
+                                  handler.handleOperator("&#0060;");
+                                 }
+
+  {gt}                           {
+                                   transposable = false;
+                                  handler.handleOperator("&#0062;");
+                                 }
+
+  {leq}                          {
+                                   transposable = false;
+                                  handler.handleOperator("&#0060;=");
+                                 }
+
+  {geq}                          {
+                                   transposable = false;
+                                  handler.handleOperator("&#0062;=");
+                                }
+
+  {neq}                          {
+                                   transposable = false;
+                                  handler.handleOperator("&#0060;&#0062;");
+                                 }
+
+  {amp}                          {
+                                   transposable = false;
+                                  handler.handleOperator("&#0038;");
+                                 }
+
+  {operator}                     {
+                                   transposable = false;
+                                  handler.handleOperator(yytext());
+                                 }
+
+  {funb}                         {
+                                   transposable = false;
+                                  handler.handleFKeywords("function");
+                                  handler.handleNothing(" ");
+                                  handler.handleOpenClose("[");
+                                   yybegin(RETS);
+                                 }
+
+  {fun}                          {
+                                   transposable = false;
+                                  handler.handleFKeywords("function");
+                                  handler.handleNothing(" ");
+                                   yybegin(FUNCTION);
+                                 }
+
+  {endfun}                       {
+                                   transposable = false;
+                                  returnValues.clear();
+                                  argsValues.clear();
+                                  handler.handleFKeywords("endfunction");
+                                 }
+
+  {structureKwds}                {
+                                   transposable = false;
+                                  handler.handleSKeywords(yytext());
+                                 }
+
+  {controlKwds}                  {
+                                   transposable = false;
+                                  handler.handleCKeywords(yytext());
+                                }
+
+  {cstes}                        {
+                                   transposable = true;
+                                  handler.handleConstants(yytext());
+                                 }
+
+  {id}                           {
+                                   transposable = true;
+                                   String str = yytext();
+                                  if (commands.contains(str)) {
+                                      yybegin(COMMANDS);
+                                      handler.handleCommand(str);
+                                   } else if (macros.contains(str)) {
+                                       yybegin(COMMANDS);
+                                      handler.handleMacro(str);
+                                   } else if (localFun.contains(str)) {
+                                       yybegin(COMMANDS);
+                                       handler.handleFunctionId(str);
+                                   } else {
+                                       if (returnValues.contains(str) || argsValues.contains(str)) {
+                                          handler.handleInputOutputArgs(str);
+                                       }  else {
+                                          handler.handleId(str);
+                                      }
+                                   }
+                                }
+
+  {number}                       {
+                                   transposable = true;
+                                  handler.handleNumber(yytext());
+                                 }
+
+  {special}                      {
+                                   transposable = false;
+                                  handler.handleSpecial(yytext());
+                                 }
+
+  {dot}                          {
+                                   transposable = false;
+                                   yybegin(FIELD);
+                                  handler.handleOperator(yytext());
+                                 }
+
+  {quote}                        {
+                                   if (transposable) {
+                                      handler.handleOperator("&#0039;");
+                                   } else {
+                                       beginString = zzStartRead;
+                                       yybegin(QSTRING);
+                                      handler.handleString("&#0039;");
+                                   }
+                                 }
+
+  {open}                         {
+                                   transposable = false;
+                                  handler.handleOpenClose(yytext());
+                                 }
+
+  {close}                        {
+                                   transposable = true;
+                                  handler.handleOpenClose(yytext());
+                                 }
+
+  {dquote}                       {
+                                   transposable = false;
+                                   beginString = zzStartRead;
+                                   yybegin(QSTRING);
+                                  handler.handleString("&#0034;");
+                                 }
+
+  " "                            {
+                                  handler.handleNothing(" ");
+                                 }
+
+  "\t"                           {
+                                  handler.handleNothing("    ");
+                                 }
+
+  "\0"                          {
+                                  return;
+                                }
+
+  .                              {
+                                   transposable = false;
+                                  handler.handleDefault(yytext());
+                                 }
+
+  {eol}                          {
+                                  handler.handleNothing("\n");
+                                  saveLexState = YYINITIAL;
+                                  yybegin(CLEAN);
+                                }
+
+}
+
+<FUNCTION> {
+  "["                            {
+                                  handler.handleOpenClose("[");
+                                   yybegin(RETS);
+                                 }
+
+  {id}                           {
+                                   id = yytext();
+                                   yybegin(TYPEID);
+                                 }
+
+  .                              |
+  {eol}                          {
+                                  yypushback(1);
+                                   yybegin(YYINITIAL);
+                                 }
+}
+
+<TYPEID> {
+  "="                            {
+                                   returnValues.add(id);
+                                  handler.handleInputOutputArgsDecl(id);
+                                  handler.handleOperator("=");
+                                   yybegin(FUNNAME);
+                                 }
+
+  "("                            {
+                                  localFun.add(id);
+                                  handler.handleFunctionIdDecl(id);
+                                  handler.handleOpenClose("(");
+                                   yybegin(ARGS);
+                                 }
+
+  [ \t]                          { }
+
+  {funcomments}                  {
+                                  localFun.add(id);
+                                  handler.handleFunctionIdDecl(id);
+                                  yypushback(yylength());
+                                  yybegin(YYINITIAL);
+                                 }
+
+  .                              |
+  {eol}                                 {
+                                  yypushback(1);
+                                   yybegin(YYINITIAL);
+                                 }
+}
+
+<FUNNAME> {
+  {id}                           {
+                                  id = yytext();
+                                  localFun.add(id);
+                                  handler.handleFunctionIdDecl(id);
+                                 }
+
+  [ \t]                          { }
+
+  "("                            {
+                                  handler.handleOpenClose("(");
+                                   yybegin(ARGS);
+                                 }
+
+  {funcomments}                  {
+                                  yypushback(yylength());
+                                  yybegin(YYINITIAL);
+                                 }
+
+  .                              |
+  {eol}                                 {
+                                  yypushback(1);
+                                  yybegin(YYINITIAL);
+                                 }
+}
+
+<ARGS> {
+  {id}                           {
+                                  id = yytext();
+                                   argsValues.add(id);
+                                  handler.handleInputOutputArgsDecl(id);
+                                 }
+
+  ","                            {
+                                  handler.handleDefault(", ");
+                                 }
+
+  {white}                        { }
+
+  {break}                        {
+                                  handler.handleSpecial(yytext());
+                                  yybegin(BREAKINARGS);
+                                 }
+
+  ")"                            {
+                                  handler.handleOpenClose(")");
+                                  yybegin(YYINITIAL);
+                                 }
+
+  .                              |
+  {eol}                          {
+                                  yypushback(1);
+                                  yybegin(YYINITIAL);
+                                 }
+}
+
+<BREAKINARGS> {
+  " "                            {
+                                  handler.handleNothing(" ");
+                                 }
+
+  {comment}                      {
+                                  breakargs = true;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
+                                 }
+
+  {white}*{eol}                         {
+                                  handler.handleNothing("\n");
+                                  saveLexState = WHITESEOL;
+                                  yybegin(CLEAN);
+                                }
+
+  .                              {
+                                  yypushback(1);
+                                  yybegin(YYINITIAL);
+                                 }                              
+}
+
+<WHITESEOL> {
+  " "                           {
+                                  handler.handleNothing(" ");
+                                 }
+
+  .                              |
+  {eol}                                 {
+                                  yypushback(1);
+                                  yybegin(ARGS);
+                                }
+}
+
+<RETS> {
+  {id}                           {
+                                  id = yytext();
+                                   returnValues.add(id);
+                                  handler.handleInputOutputArgsDecl(id);
+                                 }
+
+  ","                            {
+                                  handler.handleDefault(", ");
+                                 }
+
+  "]"                            {
+                                  handler.handleOpenClose("]");
+                                 }
+
+  "["                            {
+                                  handler.handleOpenClose("[");
+                                 }
+
+  "="                            {
+                                  handler.handleOperator("=");
+                                   yybegin(FUNNAME);
+                                 }
+
+  "..."                          {
+                                  handler.handleNothing("...");
+                                 }
+
+  {white}                       { }
+
+  .                              |
+  {eol}                          {
+                                  yypushback(1);
+                                  yybegin(YYINITIAL);
+                                 }
+}
+
+<COMMANDS> {
+  [ \t]*"("                      {
+                                   yypushback(yylength());
+                                   yybegin(YYINITIAL);
+                                 }
+
+  " "                            {
+                                   yybegin(COMMANDSWHITE);
+                                  handler.handleNothing(" ");
+                                 }
+
+  "\t"                           {
+                                   yybegin(COMMANDSWHITE);
+                                  handler.handleNothing("    ");
+                                 }
+  .
+                                 {
+                                   yypushback(1);
+                                   yybegin(YYINITIAL);
+                                 }
+
+  {eol}                          {
+                                  handler.handleNothing("\n");
+                                  saveLexState = YYINITIAL;
+                                  yybegin(CLEAN);
+                                }
+}
+
+<COMMANDSWHITE> {
+  {comment}                      {
+                                   transposable = false;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
+                                 }
+
+  ([^ \t,;/\n\r<>&]*)           |
+  ("/"[^ /<>&]*)                {
+                                  handler.handleString(yytext());
+                                 }
+
+  {lt}                           {
+                                   transposable = false;
+                                  handler.handleString("&#0060;");
+                                 }
+
+  {gt}                           {
+                                   transposable = false;
+                                  handler.handleString("&#0062;");
+                                 }
+
+  {amp}                          {
+                                   transposable = false;
+                                  handler.handleString("&#0038;");
+                                 }
+
+  " "                            {
+                                  handler.handleNothing(" ");
+                                 }
+
+  "\t"                           {
+                                  handler.handleNothing("    ");
+                                 }
+  .
+                                 {
+                                   yypushback(1);
+                                   yybegin(YYINITIAL);
+                                 }
+
+  {eol}                          {
+                                  handler.handleNothing("\n");
+                                  saveLexState = YYINITIAL;
+                                  yybegin(CLEAN);
+                                }
+}
+
+<FIELD> {
+  {id}                           {
+                                  handler.handleField(yytext());
+                                 }
+
+  .                              {
+                                   yypushback(1);
+                                   yybegin(YYINITIAL);
+                                 }
+
+ {eol}                          {
+                                  handler.handleNothing("\n");
+                                  saveLexState = YYINITIAL;
+                                  yybegin(CLEAN);
+                                 }
+}
+
+<QSTRING> {
+  {breakinstring}                {
+                                   yypushback(yylength());
+                                   yybegin(BREAKSTRING);
+                                   transposable = false;
+                                  handler.handleString(yytext());
+                                 }
+
+  {lt}                           {
+                                   transposable = false;
+                                  handler.handleString("&#0060;");
+                                 }
+
+  {gt}                           {
+                                   transposable = false;
+                                  handler.handleString("&#0062;");
+                                 }
+
+  {amp}                          {
+                                   transposable = false;
+                                  handler.handleString("&#0038;");
+                                 }
+
+  {string}                       |
+  "."                            {
+                                  handler.handleString(yytext());
+                                 }
+
+  {quote}                        {
+                                   transposable = false;
+                                   yybegin(YYINITIAL);
+                                  handler.handleString("&#0039;");
+                                 }
+
+  {dquote}                       {
+                                   transposable = false;
+                                   yybegin(YYINITIAL);
+                                  handler.handleString("&#0034;");
+                                 }
+
+  "\0"                          {
+                                  return;
+                                }
+
+  .                              {
+                                  handler.handleString(yytext());
+                                 }
+
+ {eol}                          {
+                                  handler.handleNothing("\n");
+                                  saveLexState = YYINITIAL;
+                                  yybegin(CLEAN);
+                                 }
+}
+
+<COMMENT> {
+  [^&<>\'\"\n\0]*                {
+                                  handler.handleComment(yytext());
+                                 }
+
+  {lt}                           {
+                                  handler.handleComment("&#0060;");
+                                 }
+
+  {gt}                           {
+                                  handler.handleComment("&#0062;");
+                                 }
+
+  {amp}                          {
+                                  handler.handleComment("&#0038;");
+                                 }
+
+  {quote}                        {
+                                  handler.handleComment("&#0039;");
+                                 }
+
+  {dquote}                       {
+                                  handler.handleComment("&#0034;");
+                                 }
+
+  {eol}                          {
+                                  if (breakstring) {
+                                    saveLexState = QSTRING;
+                                    breakstring = false;
+                                  } else if (breakargs) {
+                                    saveLexState = WHITESEOL;
+                                    breakargs = false;
+                                  } else {
+                                    saveLexState = YYINITIAL;
+                                  }
+                                  handler.handleNothing("\n");
+                                  yybegin(CLEAN);
+                                 }
+
+  "\0"                          {
+                                  return;
+                                }
+}
+
+<BREAKSTRING> {
+  {break}                        {
+                                   breakstring = true;
+                                  handler.handleSpecial(yytext());
+                                 }
+
+  " "                            {
+                                  handler.handleNothing(" ");
+                                 }
+
+  "\t"                           {
+                                  handler.handleNothing("    ");
+                                 }
+
+  {comment}                      {
+                                   transposable = false;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
+                                 }
+
+  .                              {
+                                  handler.handleDefault(yytext());
+                                 }
+
+  {eol}                          {                                
+                                  if (breakstring) {
+                                     breakstring = false;
+                                     saveLexState = QSTRING;
+                                  } else {
+                                     saveLexState = YYINITIAL;
+                                  }
+                                  handler.handleNothing("\n");
+                                  yybegin(CLEAN);
+                                 }
+
+  "\0"                          {
+                                  return;
+                                }
+}
+
+<<EOF>>                          {
+                                   return;
+                                 }
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/CHMDocbookTagConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/CHMDocbookTagConverter.java
new file mode 100644 (file)
index 0000000..1661d24
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.xml.sax.SAXException;
+
+/**
+ * Class to convert DocBook to CHM
+ * @author Calixte DENIZET
+ */
+public class CHMDocbookTagConverter extends HTMLDocbookTagConverter {
+
+    private StringBuilder buffer = new StringBuilder(8192);
+    private String outName;
+    private List<String> filesList = new ArrayList();
+
+    /**
+     * Constructor
+     * @param inName the name of the input stream
+     * @param primConf the file containing the primitives of Scilab
+     * @param macroConf the file containing the macros of Scilab
+     * @param out the output stream
+     */
+    public CHMDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, boolean checkLast) throws IOException, SAXException {
+        super(inName, outName, primConf, macroConf, template, version, imageDir, checkLast);
+        this.outName = new File(outName).getCanonicalPath() + File.separator;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createHTMLFile(String id, String fileName, String subtitle, String contents) {
+        super.createHTMLFile(id, fileName, subtitle, contents);
+        filesList.add(fileName);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makePrevious(String id) {
+        buffer.setLength(0);
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "<link rel=\"prev\" href=\"\" title=\"\">";
+        }
+        HTMLDocbookLinkResolver.TreeId prev = leaf.getPrevious();
+        if (prev.parent != null) {
+            buffer.append("<link rel=\"prev\" href=\"");
+            buffer.append(mapId.get(prev.id));
+            buffer.append("\" title=\"");
+            buffer.append(tocitem.get(prev.id));
+            buffer.append("\">");
+
+            return buffer.toString();
+        }
+
+        return "<link rel=\"prev\" href=\"\" title=\"\">";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeTop(String id) {
+        buffer.setLength(0);
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "<link rel=\"up\" href=\"\" title=\"\">";
+        }
+        HTMLDocbookLinkResolver.TreeId prev = leaf.getPrevious();
+        if (prev.parent != null) {
+            buffer.append("<link rel=\"up\" href=\"");
+            if (!leaf.isRoot()) {
+                buffer.append(mapId.get(leaf.id));
+                buffer.append("\" title=\"");
+                buffer.append(tocitem.get(leaf.id));
+            } else {
+                buffer.append(indexFilename);
+                buffer.append("\" title=\"");
+                buffer.append(bookTitle);
+            }
+            buffer.append("\">");
+
+            return buffer.toString();
+        }
+
+        return "<link rel=\"up\" href=\"\" title=\"\">";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeNext(String id) {
+        buffer.setLength(0);
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "<link rel=\"next\" href=\"\" title=\"\">";
+        }
+        HTMLDocbookLinkResolver.TreeId next = leaf.getNext();
+        if (next != null) {
+            buffer.append("<link rel=\"next\" href=\"");
+            buffer.append(mapId.get(next.id));
+            buffer.append("\" title=\"");
+            buffer.append(tocitem.get(next.id));
+            buffer.append("\">");
+
+            return buffer.toString();
+        }
+
+        return "<link rel=\"next\" href=\"\" title=\"\">";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeStart(String id) {
+        buffer.setLength(0);
+        buffer.append("<link rel=\"start\" href=\"");
+        buffer.append(indexFilename);
+        buffer.append("\" title=\"");
+        buffer.append(bookTitle);
+        buffer.append("\">");
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endDocument() throws SAXException {
+        try {
+            FileOutputStream outToc = new FileOutputStream("toc.hhc");
+            FileOutputStream outFiles = new FileOutputStream("htmlhelp.hhp");
+            OutputStreamWriter writerFiles = new OutputStreamWriter(outFiles);
+            OutputStreamWriter writerToc = new OutputStreamWriter(outToc);
+            convertTree(writerToc);
+            writerToc.flush();
+            writerToc.close();
+            outToc.flush();
+            outToc.close();
+
+            convertFileList(writerFiles);
+            writerFiles.flush();
+            writerFiles.close();
+            outFiles.flush();
+            outFiles.close();
+        } catch (IOException e) {
+            exceptionOccured(e);
+        }
+    }
+
+    private void convertFileList(Appendable buffer) throws IOException {
+        // Allan : si tu penses que l'on peut faire un truc plus configurable, dis-moi je ferais un fichier modele
+        // que l'on remplira ensuite avec les bonnes options...
+        buffer.append("[OPTIONS]\n");
+        buffer.append("Binary TOC=Yes\n");
+        buffer.append("Compatibility=1.1 or later\n");
+        buffer.append("Compiled file=htmlhelp.chm\n");
+        buffer.append("Contents file=");
+        buffer.append(outName);
+        buffer.append("toc.hhc\n");
+        buffer.append("Default Window=Main\n");
+        buffer.append("Default topic=");
+        buffer.append(outName);
+        buffer.append("index.html\n");
+        buffer.append("Display compile progress=Yes\n");
+        buffer.append("Full-text search=Yes\n");
+        buffer.append("Language=");
+        buffer.append("0x0409");// Allan : code pr la langue
+        buffer.append("\nTitle=");
+        buffer.append(bookTitle);
+        buffer.append("\nEnhanced decompilation=No\n\n");
+        buffer.append("[WINDOWS]\n");
+        buffer.append("Main=\"");
+        buffer.append(bookTitle);
+        buffer.append("\",\",");
+        buffer.append(outName);
+        buffer.append("toc.hhc\",,\"");
+        buffer.append(outName);
+        buffer.append("index.html\",\"");
+        buffer.append(outName);
+        buffer.append("index.html\",,,,,0x2520,,0x603006,,,,,,,,0\n\n[FILES]\n");
+        for (String s : filesList) {
+            buffer.append(outName);
+            buffer.append(s);
+            buffer.append("\n");
+        }
+    }
+
+    private void convertTreeId(HTMLDocbookLinkResolver.TreeId leaf, Appendable buffer) throws IOException {
+        if (leaf.children != null) {
+            for (HTMLDocbookLinkResolver.TreeId c : leaf.children) {
+                buffer.append("<LI><OBJECT type=\"text/sitemap\">\n<param name=\"Name\" value=\"");
+                buffer.append(tocitem.get(c.id));
+                buffer.append("\">\n<param name=\"Local\" value=\"");
+                buffer.append(outName);
+                buffer.append(mapId.get(c.id));
+                buffer.append("\">\n</OBJECT>\n</LI>\n");
+                if (c.children != null) {
+                    buffer.append("<UL>\n");
+                    convertTreeId(c, buffer);
+                    buffer.append("</UL>\n");
+                }
+            }
+        }
+    }
+
+    private void convertTree(Appendable buffer) throws IOException {
+        buffer.append("<HTML>\n<HEAD>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n</HEAD>\n<BODY>\n<OBJECT type=\"text/site properties\">\n<param name=\"ImageType\" value=\"Folder\">\n</OBJECT>\n");
+        buffer.append("<UL>\n<LI><OBJECT type=\"text/sitemap\">\n<param name=\"Name\" value=\"");
+        buffer.append(bookTitle);
+        buffer.append("\">\n<param name=\"Local\" value=\"");
+        buffer.append(outName);
+        buffer.append("index.html\">\n</OBJECT>\n</LI>\n<UL>\n");
+        convertTreeId(tree, buffer);
+        buffer.append("</UL>\n</UL>\n</BODY>\n</HTML>");
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookElement.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookElement.java
new file mode 100644 (file)
index 0000000..28aa392
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.util.Map;
+
+public class DocbookElement {
+       
+    private Map<String, String> attributes;
+    private String name;
+    private StringBuilder contents;
+       
+    /**
+     * Default constructor
+     * @param name the tag name
+     * @param attributes the attributes and its values
+     */
+    protected DocbookElement(String name, Map attributes) {
+       this.name = name;
+       this.attributes = attributes;
+       contents = new StringBuilder();
+    }
+
+    /**
+     * @return a new DocbookElement
+     */
+    public DocbookElement getNewInstance(String name, Map attributes) {
+       return new DocbookElement(name, attributes);
+    }
+
+    /**
+     * @return the tag name
+     */
+    public String getName() {
+       return name;
+    }
+
+    /**
+     * @return the attributes
+     */
+    public Map<String, String> getAttributes() {
+       return attributes;
+    }
+    
+    /**
+     * @return the buffer used to add contents of the tag
+     */
+    public StringBuilder getStringBuilder() {
+       return contents;
+    }
+
+    /**
+     * @param the buffer to use
+     */
+    public void setStringBuilder(StringBuilder buf) {
+       contents = buf;
+    }
+
+    /**
+     * This method can be used to store other things...
+     * and it should be override since it does nothing...
+     * I created it to handle the case where the converter has two String (or more)
+     * to generate with the same data.
+     * @param obj the Object to append.
+     */
+    public void append(Object obj) { }
+
+    /**
+     * This method can be used to get what it has been stored with append
+     * @return an object
+     */
+    public Object get() {
+       return null;
+    }
+
+    /**
+     * Add a parent to retrieve its contents
+     * @param elem the parent
+     */
+    public void setParent(DocbookElement elem) { }
+
+    /**
+     * @return the parent element
+     */
+    public DocbookElement getParent() {
+       return null;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookTagConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/DocbookTagConverter.java
new file mode 100644 (file)
index 0000000..cba270e
--- /dev/null
@@ -0,0 +1,509 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.scilab.forge.scidoc.external.ExternalXMLHandler;
+
+/**
+ * Class the convert a DocBook xml file
+ * @author Calixte DENIZET
+ */
+public class DocbookTagConverter extends DefaultHandler {
+
+    private static final String DOCBOOKURI = "http://docbook.org/ns/docbook";
+    private static final Class[] argsType = new Class[]{Map.class, String.class};
+    private static final File lastGenerationFile = new File(System.getProperty("java.io.tmpdir") + File.separator + "scidocLastGen");
+
+    private Map<String, Method> mapMeth = new HashMap();
+    private Map<String, ExternalXMLHandler> externalHandlers = new HashMap();
+    private List<DocbookTagConverter> converters;
+
+    private final File in;
+    private DocbookElement baseElement = new DocbookElement(null, null);
+
+    private Stack<DocbookElement> stack = new Stack();
+
+    /**
+     * The file which is parsed
+     */
+    protected String currentFileName;
+
+    /**
+     * Useful to locate the errors
+     */
+    protected Locator locator;
+
+    /**
+     * The local time where the last generation occured.
+     */
+    protected long lastGeneration;
+
+    /**
+     * Constructor
+     * @param in the input file path
+     */
+    public DocbookTagConverter(String in) throws IOException {
+       if (in != null && !in.isEmpty()) {
+               this.in = new File(in);
+       } else {
+               this.in = null;
+       }
+    }
+
+    /**
+     * Constructor
+     * @param in the inputstream
+     * @param inName the name of the input file
+     */
+    public DocbookTagConverter(String inName, DocbookElement elem) throws IOException {
+        this(inName);
+        baseElement = elem;
+    }
+
+    /**
+     * Handle the tag
+     * @param tag the tag to handle
+     * @param attributes the attributes as a Map
+     * @param contents the contents between the matching tags
+     * @return the HTML code
+     * @throws UnhandledDocbookTagException if an handled tga is encountered
+     */
+    public String handleDocbookTag(String tag, Map attributes, String contents) throws SAXException {
+        if (tag != null && tag.length() > 0) {
+            Method method = mapMeth.get(tag);
+            if (method == null) {
+                String name = "handle" + Character.toString(Character.toUpperCase(tag.charAt(0))) + tag.substring(1);
+                try {
+                    method = this.getClass().getMethod(name, argsType);
+                    mapMeth.put(tag, method);
+                } catch (NoSuchMethodException e) {
+                    throw new UnhandledDocbookTagException(tag);
+                }
+            }
+            try {
+                return (String) method.invoke(this, new Object[]{attributes, contents});
+            } catch (IllegalAccessException e) {
+                throw new UnhandledDocbookTagException(tag);
+            } catch (InvocationTargetException e) {
+                throw new SAXException("Problem with tag " + tag + "\n" + e.getCause());
+            }
+        } else {
+            throw new UnhandledDocbookTagException(tag);
+        }
+    }
+
+    /**
+     * Register an Docbook tag converter. The aim is to parse the xml one time.
+     * @param c the converter to register
+     */
+    public void registerConverter(DocbookTagConverter c) {
+        if (converters == null) {
+            converters = new ArrayList();
+        }
+
+        converters.add(c);
+        c.setDocumentLocator(locator);
+    }
+
+    /**
+     * @param c the converter to remove
+     */
+    public void removeConverter(DocbookTagConverter c) {
+        if (converters != null) {
+            converters.remove(c);
+        }
+    }
+
+    /**
+     * @return all the registered converters
+     */
+    public DocbookTagConverter[] getConverters() {
+        if (converters == null) {
+            return null;
+        }
+
+        return converters.toArray(new DocbookTagConverter[0]);
+    }
+
+    /**
+     * Register an XMLHandler for external XML
+     * @param h the external XML handler
+     */
+    public void registerExternalXMLHandler(ExternalXMLHandler h) {
+        if (externalHandlers.get(h.getURI()) == null) {
+            externalHandlers.put(h.getURI(), h);
+        }
+    }
+
+    /**
+     * @param tagName the tag name
+     * @return true if the contents of the tag must be escaped
+     */
+    public boolean isEscapable(String tagName) {
+        return true;
+    }
+
+    /**
+     * @param tagName the tag name
+     * @return true if the contents of the tag must be trimed
+     */
+    public boolean isTrimable(String tagName) {
+        return true;
+    }
+
+    /**
+     * @return the parent tag name
+     */
+    public String getParentTagName() {
+        return stack.peek().getName();
+    }
+
+    /**
+     * @return the parent tag contents
+     */
+    public String getParentContent() {
+        return stack.peek().getStringBuilder().toString();
+    }
+
+    /**
+     * Start the conversion
+     * @throws SAXException if a problem is encountered during the parsing
+     * @throws IOException if an IO problem is encountered
+     */
+    public void convert() throws SAXException, IOException {
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        factory.setValidating(false);
+        factory.setNamespaceAware(true);
+
+        try {
+            factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+            SAXParser parser = factory.newSAXParser();
+            parser.parse(in, this);
+        } catch (ParserConfigurationException e) {
+            exceptionOccured(e);
+        } catch (SAXException e) {
+            System.err.println(e);
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+        currentFileName = systemId;
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.resolveEntity(publicId, systemId);
+            }
+        }
+        try {
+            URI uri = new URI(systemId);
+            if (new File(uri).lastModified() > lastGeneration) {
+                return super.resolveEntity(publicId, systemId);
+            }
+        } catch (URISyntaxException e) { }
+
+        return new InputSource(new StringReader(""));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void startDocument() throws SAXException {
+        stack.push(baseElement.getNewInstance(null, null));
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.startDocument();
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endDocument() throws SAXException {
+        stack.clear();
+
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.endDocument();
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+        if (uri.equals(DOCBOOKURI)) {
+                int len = attributes.getLength();
+                Map<String, String> map = new HashMap(len);
+                for (int i = 0; i < len; i++) {
+                    map.put(attributes.getLocalName(i), attributes.getValue(i));
+                }
+                stack.push(baseElement.getNewInstance(localName, map));
+        } else {
+            ExternalXMLHandler h = externalHandlers.get(uri);
+            if (h == null) {
+                exceptionOccured(new SAXException("uri " + uri + " not handled"));
+                return;
+            }
+            StringBuilder buf = h.startExternalXML(localName, attributes);
+            if (buf != null) {
+                DocbookElement elem = baseElement.getNewInstance(localName, null);
+                elem.setStringBuilder(buf);
+                stack.push(elem);
+            }
+        }
+
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.startElement(uri, localName, qName, attributes);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endElement(String uri, String localName, String qName) throws SAXException {//if (localName.equals("member")&&titi>1){titi=0;System.out.println(currentFileName);}
+        if (uri.equals(DOCBOOKURI)) {
+            DocbookElement elem = stack.pop();
+            if (!elem.getName().equals(localName)) {
+                exceptionOccured(new SAXException("tag " + elem.getName() + " is closed with tag " + localName));
+                return;
+            }
+            try {
+                DocbookElement elemp = stack.peek();
+                elemp.setParent(elem);
+                StringBuilder buf = elem.getStringBuilder();
+                if (isTrimable(elem.getName())) {
+                    buf = trim(buf);
+                }
+                String str = handleDocbookTag(elem.getName(), elem.getAttributes(), buf.toString());
+                if (str != null) {
+                    elemp.getStringBuilder().append(str);
+                }
+            } catch (SAXException e) {
+                exceptionOccured(e);
+                return;
+            }
+        } else {
+            ExternalXMLHandler h = externalHandlers.get(uri);
+            if (h == null) {
+                exceptionOccured(new SAXException("uri " + uri + " not handled"));
+                return;
+            }
+            String str = h.endExternalXML(localName);
+            if (str != null) {
+                stack.pop();
+                stack.peek().getStringBuilder().append(str);
+            }
+        }
+
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.endElement(uri, localName, qName);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        int end = start + length;
+
+        if (isEscapable(stack.peek().getName())) {
+            StringBuilder buf = stack.peek().getStringBuilder();
+            int save = start;
+            for (int i = start; i < end; i++) {
+                switch (ch[i]) {
+                case '\'' :
+                    buf.append(ch, save, i - save);
+                    buf.append("&#0039;");
+                    save = i + 1;
+                    break;
+                case '\"' :
+                    buf.append(ch, save, i - save);
+                    buf.append("&#0034;");
+                    save = i + 1;
+                    break;
+                case '<' :
+                    buf.append(ch, save, i - save);
+                    buf.append("&lt;");
+                    save = i + 1;
+                    break;
+                case '>' :
+                    buf.append(ch, save, i - save);
+                    buf.append("&gt;");
+                    save = i + 1;
+                    break;
+                case '&' :
+                    buf.append(ch, save, i - save);
+                    buf.append("&amp;");
+                    save = i + 1;
+                    break;
+                default :
+                    break;
+                }
+            }
+
+            if (save < end) {
+                buf.append(ch, save, end - save);
+            }
+        } else {
+            stack.peek().getStringBuilder().append(ch, start, length);
+        }
+
+        if (converters != null) {
+            for (DocbookTagConverter conv : converters) {
+                conv.characters(ch, start, length);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDocumentLocator(Locator locator) {
+        this.locator = locator;
+    }
+
+    /**
+     * @return the used stack
+     */
+    protected Stack<DocbookElement> getStack() {
+        return stack;
+    }
+
+    /**
+     * Handle an exception depending on the presence of a locator
+     * @param e the exception to handle
+     * @throws SAXException if problem
+     */
+    protected void exceptionOccured(Exception e) throws SAXException {
+        String sId = "";
+        if (currentFileName != null) {
+            sId = "SystemID:" + currentFileName;
+        }
+        
+        String file;
+               try {
+                       file = in.getCanonicalPath();
+               } catch (IOException e1) {
+                       e1.printStackTrace();
+                       file = null;
+               }
+        if (locator != null) {
+            throw new SAXException("Cannot parse " + file + ":\n" + e.getMessage() + "\n" + sId + " at line " + locator.getLineNumber());
+        } else {
+            throw new SAXException("Cannot parse " + file + ":\n" + e.getMessage() + "\n" + sId);
+        }
+    }
+
+    protected void getLastGeneration(long time) {
+        BufferedReader input = null;
+        lastGeneration = 0;
+        if (lastGenerationFile.exists()) {
+            try {
+                input = new BufferedReader(new FileReader(lastGenerationFile));
+                String line = input.readLine();
+                if (line != null) {
+                    lastGeneration = Long.parseLong(line);
+                    if (time > lastGeneration) {
+                        lastGeneration = 0;
+                    }
+                }
+            } catch (IOException e) {
+                System.err.println(e);
+            }
+            if (input != null) {
+                try {
+                    input.close();
+                } catch (IOException e) {
+                    System.err.println(e);
+                }
+            }
+        }
+    }
+
+    protected void saveLastGeneration() {
+        try {
+            FileOutputStream out = new FileOutputStream(lastGenerationFile);
+            OutputStreamWriter writer = new OutputStreamWriter(out);
+            writer.append(Long.toString(System.currentTimeMillis()));
+            writer.flush();
+            writer.close();
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+    }
+
+    /**
+     * @param the StringBuilder to trim
+     * @return a trimed StringBuilder
+     */
+    private static StringBuilder trim(StringBuilder buf) {
+        int start = 0;
+        int i = 0;
+        int end = buf.length();
+        char c;
+        for (; i < end; i++) {
+            c = buf.charAt(i);
+            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
+                break;
+            }
+        }
+        buf.delete(0, i);
+        end = end - i;
+        for (i = end - 1; i >= 0; i--) {
+            c = buf.charAt(i);
+            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
+                break;
+            }
+        }
+        buf.setLength(i + 1);
+
+        return buf;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookLinkResolver.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookLinkResolver.java
new file mode 100644 (file)
index 0000000..f01231d
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.IOException;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Class the convert a DocBook xml file
+ * @author Calixte DENIZET
+ */
+public class HTMLDocbookLinkResolver extends DefaultHandler {
+
+    private Map<String, String> mapId = new LinkedHashMap();
+    private Map<String, String> toc = new LinkedHashMap();
+    private Map<String, TreeId> mapTreeId = new HashMap();
+    private TreeId tree = new TreeId(null, "root");
+
+    private TreeId currentLeaf = tree;
+
+    private String current;
+    private String lastId;
+    private Locator locator;
+    private String currentFileName;
+    private boolean waitForRefname;
+    private boolean waitForTitle;
+    private boolean getContents;
+    private final File in;
+    private int level;
+    private StringBuilder buffer = new StringBuilder(256);
+
+    /**
+     * Constructor
+     * @param in the input file path
+     */
+    public HTMLDocbookLinkResolver(String in) throws IOException, SAXException {
+       this.in = new File(in);
+        resolvLinks();
+    }
+
+    /**
+     * @return the map id
+     */
+    public Map<String, String> getMapId() {
+        return mapId;
+    }
+
+    /**
+     * @return the tocs
+     */
+    public Map<String, String> getToc() {
+        return toc;
+    }
+
+    /**
+     * @return the document tree
+     */
+    public TreeId getTree() {
+        return tree;
+    }
+
+    /**
+     * @return the document tree
+     */
+    public Map<String, TreeId> getMapTreeId() {
+        return mapTreeId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+        currentFileName = systemId;
+        return super.resolveEntity(publicId, systemId);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void startDocument() throws SAXException { }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endDocument() throws SAXException { }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+        int len = attributes.getLength();
+        String id = null;
+        for (int i = 0; i < len; i++) {
+            if (attributes.getLocalName(i).equals("id")) {
+                id = attributes.getValue(i);
+                break;
+            }
+        }
+
+        if (localName.equals("title")) {
+            if (waitForTitle) {
+                getContents = true;
+                buffer.setLength(0);
+            }
+        } else if (localName.equals("refname")) {
+            if (waitForRefname) {
+                getContents = true;
+                buffer.setLength(0);
+            }
+        } else if (localName.equals("refentry") || localName.equals("section") || localName.equals("part") || localName.equals("chapter")) {
+            if (id == null) {
+                throw new SAXException(errorMsg());
+            }
+            current = id + ".html";
+            lastId = id;
+            mapId.put(id, current);
+            waitForTitle = localName.charAt(0) != 'r';
+            waitForRefname = !waitForTitle;
+            TreeId leaf = new TreeId(currentLeaf, id);
+            currentLeaf.add(leaf);
+            currentLeaf = leaf;
+        } else if (id != null && current != null) {
+            mapId.put(id, current + "#" +id);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endElement(String uri, String localName, String qName) throws SAXException {
+        if (getContents) {
+            toc.put(lastId, buffer.toString().trim());
+            getContents = false;
+            waitForRefname = false;
+            waitForTitle = false;
+        }
+        if (localName.equals("refentry") || localName.equals("section") || localName.equals("part") || localName.equals("chapter")) {
+            currentLeaf = currentLeaf.parent;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDocumentLocator(Locator locator) {
+        this.locator = locator;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        if (getContents) {
+            int end = start + length;
+            int save = start;
+            for (int i = start; i < end; i++) {
+                switch (ch[i]) {
+                case '\'' :
+                    buffer.append(ch, save, i - save);
+                    buffer.append("&#0039;");
+                    save = i + 1;
+                    break;
+                case '\"' :
+                    buffer.append(ch, save, i - save);
+                    buffer.append("&#0034;");
+                    save = i + 1;
+                    break;
+                case '<' :
+                    buffer.append(ch, save, i - save);
+                    buffer.append("&lt;");
+                    save = i + 1;
+                    break;
+                case '>' :
+                    buffer.append(ch, save, i - save);
+                    buffer.append("&gt;");
+                    save = i + 1;
+                    break;
+                case '&' :
+                    buffer.append(ch, save, i - save);
+                    buffer.append("&amp;");
+                    save = i + 1;
+                    break;
+                default :
+                    break;
+                }
+            }
+
+            if (save < end) {
+                buffer.append(ch, save, end - save);
+            }
+        }
+    }
+
+    /**
+     * Start the conversion
+     * @throws SAXException if a problem is encountered during the parsing
+     * @throws IOException if an IO problem is encountered
+     */
+    protected void resolvLinks() throws SAXException, IOException {
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        factory.setValidating(false);
+        factory.setNamespaceAware(true);
+
+        try {
+            SAXParser parser = factory.newSAXParser();
+            parser.parse(in, this);
+        } catch (ParserConfigurationException e) {
+            System.err.println(e);
+        }
+    }
+
+    /**
+     * @return the error message
+     */
+    private String errorMsg() {
+        String str;
+        if (currentFileName != null) {
+            str = currentFileName;
+        } else {
+               try {
+                               str = in.getCanonicalPath();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                               str = null;
+                       }
+        }
+
+        return "Refentry without id attributes in file " + str + " at line " + locator.getLineNumber();
+    }
+
+    class TreeId {
+
+        String id;
+        TreeId parent;
+        int pos;
+        List<TreeId> children;
+
+        TreeId(TreeId parent, String id) {
+            this.parent = parent;
+            this.id = id;
+            if (parent == null) {
+                mapTreeId.clear();
+            }
+            mapTreeId.put(id, this);
+        }
+
+        void add(TreeId child) {
+            if (children == null) {
+                children = new ArrayList();
+            }
+            child.pos = children.size();
+            children.add(child);
+        }
+
+        boolean isRoot() {
+            return parent == null;
+        }
+
+        TreeId getPrevious() {
+            if (pos > 0) {
+                return parent.children.get(pos - 1);
+            }
+            return parent;
+        }
+
+        TreeId getNext() {
+            TreeId l = this;
+            while (l.parent != null && l.pos == l.parent.children.size() - 1) {
+                l = l.parent;
+            }
+
+            if (l.parent == null) {
+                return null;
+            }
+            return l.parent.children.get(l.pos + 1);
+        }
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookTagConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookTagConverter.java
new file mode 100644 (file)
index 0000000..db7e6e0
--- /dev/null
@@ -0,0 +1,1250 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.xml.sax.SAXException;
+
+import org.scilab.forge.scidoc.image.ImageConverter;
+import org.scilab.forge.scidoc.image.LaTeXImageConverter;
+import org.scilab.forge.scidoc.image.MathMLImageConverter;
+import org.scilab.forge.scidoc.image.SVGImageConverter;
+import org.scilab.forge.scidoc.scilab.ScilabLexer;
+import org.scilab.forge.scidoc.scilab.HTMLScilabCodeHandler;
+
+/**
+ * Class to convert DocBook to HTML
+ * @author Calixte DENIZET
+ */
+public class HTMLDocbookTagConverter extends DocbookTagConverter implements TemplateFiller {
+
+    private static final String LATEXBASENAME = "Equation_LaTeX_";
+
+    private StringBuilder buffer = new StringBuilder(8192);
+    private int latexCompt;
+    private String imageDir;
+    private String outName;
+    private boolean checkLast;
+    private boolean hasExamples;
+    private int warnings;
+    private int nbFiles;
+
+    protected Map<String, String> mapId;
+    protected Map<String, String> tocitem;
+    protected HTMLDocbookLinkResolver.TreeId tree;
+    protected Map<String, HTMLDocbookLinkResolver.TreeId> mapTreeId;
+
+    protected TemplateHandler templateHandler;
+
+    protected ScilabLexer scilabLexer;
+
+    protected String bookTitle = "";
+    protected String partTitle = "";
+    protected String chapterTitle = "";
+    protected String sectionTitle = "";
+    protected String fileSubtitle = "";
+
+    protected String refpurpose = "";
+    protected String refname = "";
+    protected String version;
+
+    protected String indexFilename = "index" /*UUID.randomUUID().toString()*/ + ".html";
+
+    /**
+     * Constructor
+     * @param in the input stream
+     * @param inName the name of the input stream
+     * @param primConf the file containing the primitives of Scilab
+     * @param macroConf the file containing the macros of Scilab
+     * @param out the output stream
+     */
+    public HTMLDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, boolean checkLast) throws IOException, SAXException {
+        super(inName);
+
+        this.version = version;
+        this.imageDir = imageDir;
+        this.checkLast = checkLast;
+        this.outName = outName + File.separator;
+        HTMLDocbookLinkResolver resolver = new HTMLDocbookLinkResolver(inName);
+        mapId = resolver.getMapId();
+        tocitem = resolver.getToc();
+        tree = resolver.getTree();
+        mapTreeId = resolver.getMapTreeId();
+        scilabLexer = new ScilabLexer(primConf, macroConf);
+        File tpl = new File(template);
+        templateHandler = new TemplateHandler(this, tpl);
+        ImageConverter.registerExternalImageConverter(LaTeXImageConverter.getInstance());
+        ImageConverter.registerExternalImageConverter(MathMLImageConverter.getInstance());
+        ImageConverter.registerExternalImageConverter(SVGImageConverter.getInstance());
+        if (checkLast) {
+            getLastGeneration(tpl.lastModified());
+        }
+    }
+
+    /**
+     * @return the buffer used
+     */
+    public StringBuilder getBuffer() {
+        return buffer;
+    }
+
+    /**
+     * @param tag the tag name
+     * @param contents the contents to enclose between opening and closing tags
+     */
+    public String encloseContents(String tag, String contents) {
+        buffer.setLength(0);
+        if (contents == null) {
+            contents = null;
+        }
+        buffer.append("<");
+        buffer.append(tag);
+        buffer.append(">");
+        buffer.append(contents);
+        buffer.append("</");
+        buffer.append(tag);
+        buffer.append(">");
+
+        return buffer.toString();
+    }
+
+    /**
+     * @param tag the tag name
+     * @param attrs the attributes {attr1, value1, attr2, value2, ...}
+     * @param contents the contents to enclose between opening and closing tags
+     */
+    public String encloseContents(String tag, String[] attrs ,String contents) {
+        buffer.setLength(0);
+        if (contents == null) {
+            contents = "";
+        }
+        buffer.append("<");
+        buffer.append(tag);
+        if (attrs != null) {
+            for (int i = 0; i < attrs.length; i += 2) {
+                buffer.append(" ");
+                buffer.append(attrs[i]);
+                buffer.append("=\"");
+                buffer.append(attrs[i + 1]);
+                buffer.append("\"");
+            }
+        }
+
+        buffer.append(">");
+        buffer.append(contents);
+        buffer.append("</");
+        buffer.append(tag);
+        buffer.append(">");
+
+        return buffer.toString();
+    }
+
+    /**
+     * @param tag the tag name
+     * @param clazz the css class name
+     * @param contents the contents to enclose between opening and closing tags
+     */
+    public String encloseContents(String tag, String clazz, String contents) {
+        buffer.setLength(0);
+        if (contents == null) {
+            contents = "";
+        }
+        buffer.append("<");
+        buffer.append(tag);
+        buffer.append(" class=\"");
+        buffer.append(clazz);
+        buffer.append("\">");
+        buffer.append(contents);
+        buffer.append("</");
+        buffer.append(tag);
+        buffer.append(">");
+
+        return buffer.toString();
+    }
+
+    public void endDocument() throws SAXException {
+        if (checkLast) {
+            saveLastGeneration();
+        }
+        super.endDocument();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEscapable(String tagName) {
+        return !"latex".equals(tagName) && !"programlisting".equals(tagName) && !"synopsis".equals(tagName);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isTrimable(String tagName) {
+        return !"programlisting".equals(tagName) && !"synopsis".equals(tagName);
+    }
+
+    /**
+     * @param fileName the file to create
+     * @param subtitle the subtitle of the file
+     * @param contents the contents of the file
+     */
+    public void createHTMLFile(String id, String fileName, String subtitle, String contents) {
+        fileSubtitle = subtitle;
+        nbFiles++;
+        templateHandler.generateFileFromTemplate(outName + fileName, id, contents);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeTitle(String id) {
+        return refname;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeSubtitle(String id) {
+        return fileSubtitle;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makePrevious(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"previous\">");
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "";
+        }
+        HTMLDocbookLinkResolver.TreeId prev = leaf.getPrevious();
+        if (prev.parent != null) {
+            buffer.append("<a href=\"");
+            buffer.append(mapId.get(prev.id));
+            buffer.append("\">");
+            buffer.append(tocitem.get(prev.id));
+            buffer.append("</a></span>\n");
+
+            return buffer.toString();
+        }
+
+        return "";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makePath(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"path\">");
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "";
+        }
+        String str = tocitem.get(id);
+        leaf = leaf.parent;
+        while (leaf != null && !leaf.isRoot()) {
+            str = "<a href=\"" + mapId.get(leaf.id) + "\">" + tocitem.get(leaf.id) + "</a> &gt; " + str;
+            leaf = leaf.parent;
+        }
+
+        str = "<a href=\"" + indexFilename  + "\">" + bookTitle + "</a> &gt;&gt; " + str;
+        buffer.append(str);
+        buffer.append("</span>\n");
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeTop(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"top\">");
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "";
+        }
+
+        String str = tocitem.get(id);
+        leaf = leaf.parent;
+        if (leaf != null) {
+            buffer.append("<a href=\"");
+            if (!leaf.isRoot()) {
+                buffer.append(mapId.get(leaf.id));
+                buffer.append("\">");
+                buffer.append(tocitem.get(leaf.id));
+            } else {
+                buffer.append(indexFilename);
+                buffer.append("\">");
+                buffer.append(bookTitle);
+            }
+            buffer.append("</a></span>\n");
+        } else {
+            return "";
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeNext(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"next\">");
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "";
+        }
+        HTMLDocbookLinkResolver.TreeId next = leaf.getNext();
+        if (next != null) {
+            buffer.append("<a href=\"");
+            buffer.append(mapId.get(next.id));
+            buffer.append("\">");
+            buffer.append(tocitem.get(next.id));
+            buffer.append("</a></span>\n");
+
+            return buffer.toString();
+        }
+
+        return "";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeStart(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"start\">");
+        buffer.append("<a href=\"");
+        buffer.append(indexFilename);
+        buffer.append("\">");
+        buffer.append(bookTitle);
+        buffer.append("</a></span>\n");
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeTocList(String id) {
+        buffer.setLength(0);
+        HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
+        if (leaf == null) {
+            return "";
+        }
+
+        HTMLDocbookLinkResolver.TreeId parent = leaf.parent;
+        buffer.append("<ul class=\"toc\">\n");
+        String str = "";
+        while (parent != null && !parent.isRoot()) {
+            str = "<li class=\"parent\"><a href=\"" + mapId.get(parent.id) + "\">" + tocitem.get(parent.id) + "</a></li>\n" + str;
+            parent = parent.parent;
+        }
+        buffer.append("<li class=\"root\"><a href=\"");
+        buffer.append(indexFilename);
+        buffer.append("\">");
+        buffer.append(bookTitle);
+        buffer.append("</a></li>\n");
+        buffer.append(str);
+
+        parent = leaf.parent;
+
+        for (HTMLDocbookLinkResolver.TreeId c : parent.children) {
+            if (c == leaf) {
+                buffer.append("<li class=\"list-active\"><a href=\"");
+            } else {
+                buffer.append("<li><a href=\"");
+            }
+            buffer.append(mapId.get(c.id));
+            buffer.append("\">");
+            buffer.append(tocitem.get(c.id));
+            buffer.append("</a></li>\n");
+        }
+        buffer.append("</ul>\n");
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeLastModified(String id) {
+        buffer.setLength(0);
+        try {
+            buffer.append("<span class=\"lastmodified\">");
+            buffer.append(new Date(new File(new URI(currentFileName)).lastModified()).toString());
+            buffer.append("</span>\n");
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeGenerationDate(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"generationdate\">");
+        buffer.append(new Date(System.currentTimeMillis()).toString());
+        buffer.append("</span>\n");
+
+        return buffer.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String makeVersion(String id) {
+        buffer.setLength(0);
+        buffer.append("<span class=\"version\">");
+        buffer.append(version);
+        buffer.append("</span>\n");
+
+        return buffer.toString();
+    }
+
+    /**
+     * Handle a refentry
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefentry(Map<String, String> attributes, String contents) throws SAXException {
+        String fileName = attributes.get("id") + ".html";
+        createHTMLFile(attributes.get("id"), fileName, refpurpose, contents);
+        if (!hasExamples) {
+            warnings++;
+            //System.err.println("Warning (should be fixed): no example in " + currentFileName);
+        } else {
+            hasExamples = false;
+        }
+        String rp = encloseContents("span", "refentry-description", refpurpose);
+        String str = encloseContents("li", encloseContents("a", new String[]{"href", fileName, "class", "refentry"}, attributes.get("id")) + " &#8212; " + rp);
+        refpurpose = "";
+        refname = "";
+
+        return str;
+    }
+
+    /**
+     * Handle a section
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleSection(Map<String, String> attributes, String contents) throws SAXException {
+        String fileName = attributes.get("id") + ".html";
+        String str = encloseContents("ul", "list-refentry", contents);
+        String title = encloseContents("h3", "title-section", sectionTitle);
+        createHTMLFile(attributes.get("id"), fileName, sectionTitle, title + "\n" + str);
+
+        str = encloseContents("li", encloseContents("a", new String[]{"href", fileName, "class", "section"}, sectionTitle) + "\n" + str);
+        sectionTitle = "";
+
+        return str;
+    }
+
+    /**
+     * Handle a book
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleBook(Map<String, String> attributes, String contents) throws SAXException {
+        String str = encloseContents("ul", "list-part", contents);
+        String title = encloseContents("h3", "book-title", bookTitle);
+        createHTMLFile("index", indexFilename, bookTitle, title + "\n" + str);
+
+        if (warnings != 0) {
+            System.out.println("Total files without example: " + warnings);
+            System.out.println("Total generated html files: " + nbFiles);
+        }
+
+        return encloseContents("li", encloseContents("a", new String[]{"href", indexFilename, "class", "part"}, bookTitle) + "\n" + str);
+    }
+
+    /**
+     * Handle a part
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handlePart(Map<String, String> attributes, String contents) throws SAXException {
+        String fileName = attributes.get("id") + ".html";
+        String str = encloseContents("ul", "list-chapter", contents);
+        String title = encloseContents("h3", "title-part", partTitle);
+        createHTMLFile(attributes.get("id"), fileName, partTitle, title + "\n" + str);
+
+        str = encloseContents("li", encloseContents("a", new String[]{"href", fileName, "class", "part"}, partTitle) + "\n" + str);
+        partTitle = "";
+
+        return str;
+    }
+
+    /**
+     * Handle a chapter
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleChapter(Map<String, String> attributes, String contents) throws SAXException {
+        String fileName = attributes.get("id") + ".html";
+        String str = encloseContents("ul", "list-refentry", contents);
+        String title = encloseContents("h3", "title-chapter", chapterTitle);
+        createHTMLFile(attributes.get("id"), fileName, chapterTitle, title + "\n" + str);
+
+        str = encloseContents("li", encloseContents("a", new String[]{"href", fileName, "class", "chapter"}, chapterTitle) + "\n" + str);
+        chapterTitle = "";
+
+        return str;
+    }
+
+    // partiellement merdique car le style de title depend du noeud pere.
+    /**
+     * Handle a title
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTitle(Map<String, String> attributes, String contents) throws SAXException {
+        String clazz = "title";
+        String parent = getParentTagName();
+        if (parent.equals("chapter")) {
+            chapterTitle = contents;
+        } else if (parent.equals("part")) {
+            partTitle = contents;
+        } else if (parent.equals("info")) {
+            bookTitle = contents;
+        } else if (parent.equals("section")) {
+            sectionTitle = contents;
+        } else if (parent.equals("refsection") && contents.toLowerCase().startsWith("example")) {
+            hasExamples = true;
+            return encloseContents("h3", clazz, contents);
+        } else {
+            return encloseContents("h3", clazz, contents);
+        }
+
+        return null;
+    }
+
+    /**
+     * Handle a para
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handlePara(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("p", "para", contents);
+    }
+
+    /**
+     * Handle a literal
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleLiteral(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("code", "literal", contents);
+    }
+
+    /**
+     * Handle a refnamediv
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefnamediv(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "refnamediv", contents);
+        } else {
+            return encloseContents("div", "refnamediv", contents);
+        }
+    }
+
+    /**
+     * Handle a refname
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefname(Map<String, String> attributes, String contents) throws SAXException {
+        refname = contents;
+        return encloseContents("h1", "refname", contents);
+    }
+
+    /**
+     * Handle a refpurpose
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefpurpose(Map<String, String> attributes, String contents) throws SAXException {
+        refpurpose = contents;
+        return encloseContents("p", "refpurpose", contents);
+    }
+
+    /**
+     * Handle a refsynopsisdiv
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefsynopsisdiv(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "refsynopsisdiv", contents);
+        } else {
+            return encloseContents("div", "refsynopsisdiv", contents);
+        }
+    }
+
+    /**
+     * Handle a synopsis
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleSynopsis(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        String str = encloseContents("div", "synopsis", encloseContents("pre", SynopsisLexer.convert(refname, contents)));
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + str;
+        } else {
+            return str;
+        }
+    }
+
+    /**
+     * Handle a info
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleInfo(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "info", contents);
+        } else {
+            return encloseContents("div", "info", contents);
+        }
+    }
+
+    /**
+     * Handle a refsection
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleRefsection(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "refsection", contents);
+        } else {
+            return encloseContents("div", "refsection", contents);
+        }
+    }
+
+    /**
+     * Handle a progamlisting
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleProgramlisting(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        String str = encloseContents("div", "programlisting", encloseContents("pre", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, mapId), contents)));
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + str;
+        } else {
+            return str;
+        }
+    }
+
+    /**
+     * Handle a pubdate
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handlePubdate(Map<String, String> attributes, String contents) throws SAXException {
+        return null;
+    }
+
+    /**
+     * Handle a simplelist
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleSimplelist(Map<String, String> attributes, String contents) throws SAXException {
+        String style = "simplelist";
+        String type = attributes.get("type");
+        if (type != null) {
+            style += " " + type + "-list";
+        }
+
+        return encloseContents("ul", style, contents);
+    }
+
+    /**
+     * Handle a member
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleMember(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("li", "member", contents);
+    }
+
+    /**
+     * Handle a link
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleLink(Map<String, String> attributes, String contents) throws SAXException {
+        String link = attributes.get("linkend");
+        if (link == null) {
+            throw new SAXException("No linkend attribute in tag link");
+        }
+
+        String id = mapId.get(link);
+        if (id == null) {
+            warnings++;
+            System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
+            return null;
+        }
+
+        return encloseContents("a", new String[]{"href", id, "class", "link"}, contents);
+    }
+
+    /**
+     * Handle an ulink
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleUlink(Map<String, String> attributes, String contents) throws SAXException {
+        String link = attributes.get("url");
+        if (link == null) {
+            throw new SAXException("No url attribute in tag ulink");
+        }
+
+        return encloseContents("a", new String[]{"href", link, "class", "ulink"}, contents);
+    }
+
+    /**
+     * Handle a xref
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleXref(Map<String, String> attributes, String contents) throws SAXException {
+        String link = attributes.get("linkend");
+        if (link == null) {
+            throw new SAXException("No linkend attribute in tag link");
+        }
+
+        String id = mapId.get(link);
+        if (id == null) {
+            warnings++;
+            System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
+            return null;
+        }
+
+        return encloseContents("a", new String[]{"href", id, "class", "xref"}, contents);
+    }
+
+    /**
+     * Handle a latex (not really a docbook tag...)
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleLatex(Map<String, String> attributes, String contents) throws SAXException {
+        File f = new File(outName + imageDir, LATEXBASENAME + (latexCompt++) + ".png");
+        String parent = getParentTagName();
+        if (parent.equals("para") && !attributes.containsKey("style")) {
+            attributes.put("style", "text");
+        }
+        String fs = attributes.get("fontsize");
+        if (fs == null) {
+            attributes.put("fontsize", "16");
+        }
+        return ImageConverter.getImageByCode(contents, attributes, "image/latex", f, imageDir + "/" + f.getName());
+    }
+
+    /**
+     * Handle a term
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTerm(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("span", "term", contents);
+    }
+
+    /**
+     * Handle a listitem
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleListitem(Map<String, String> attributes, String contents) throws SAXException {
+        String parent = getParentTagName();
+        if (parent.equals("varlistentry")) {
+            return encloseContents("dd", contents);
+        }
+        return encloseContents("li", contents);
+    }
+
+    /**
+     * Handle a varlistentry
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleVarlistentry(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("dt", contents);
+    }
+
+    /**
+     * Handle a variablelist
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleVariablelist(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("dl", contents);
+    }
+
+    /**
+     * Handle an itemizedlist
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleItemizedlist(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("ul", "itemizedlist", contents);
+        } else {
+            return encloseContents("ul", "itemizedlist", contents);
+        }
+    }
+
+    /**
+     * Handle an emphasis
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleEmphasis(Map<String, String> attributes, String contents) throws SAXException {
+        String role = attributes.get("role");
+        if (role != null) {
+            if (role.equals("bold")) {
+                return encloseContents("b", contents);
+            }
+            if (role.equals("italic")) {
+                return encloseContents("i", contents);
+            }
+        }
+
+        return encloseContents("em", contents);
+    }
+
+    /**
+     * Handle a tr
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTr(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("tr", contents);
+    }
+
+    /**
+     * Handle a td
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTd(Map<String, String> attributes, String contents) throws SAXException {
+        String align = attributes.get("align");
+        if (align == null) {
+            return encloseContents("td", new String[]{"align", align}, contents);
+        }
+        return encloseContents("td", contents);
+    }
+
+    /**
+     * Handle an informaltable
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleInformaltable(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        String border = attributes.get("border");
+        if (border == null) {
+            border = "";
+        }
+        String cellpadding = attributes.get("cellpadding");
+        if (cellpadding == null) {
+            cellpadding = "";
+        }
+        String width = attributes.get("width");
+        if (width == null) {
+            width = "";
+        }
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("table", new String[]{"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
+        } else {
+            return encloseContents("table", new String[]{"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
+        }
+    }
+
+    /**
+     * Handle an imagedata
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleImagedata(Map<String, String> attributes, String contents) throws SAXException {
+        String fileref = attributes.get("fileref");
+        if (fileref == null) {
+            if (contents == null || contents.length() == 0) {
+                throw new SAXException("No fileref attribute or no data in tag imagedata");
+            }
+
+            return contents;
+        }
+
+        try {
+           String path = new File(new URI(currentFileName)).getParent();
+           return ImageConverter.getImageByFile(attributes, path, fileref, outName, imageDir);
+        }  catch (URISyntaxException e) {
+            System.err.println(e);
+        }
+
+        return null;
+    }
+
+    /**
+     * Handle an imageobject
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleImageobject(Map<String, String> attributes, String contents) throws SAXException {
+        return contents;
+    }
+
+    /**
+     * Handle an inlinemediaobject
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleInlinemediaobject(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("span", contents);
+    }
+
+    /**
+     * Handle a mediaobject
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleMediaobject(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        contents = contents.replaceFirst("top:([0-9]+)px;", "");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "mediaobject", contents);
+        } else {
+            return encloseContents("div", "mediaobject", contents);
+        }
+    }
+
+    /**
+     * Handle an informalequation
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleInformalequation(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "informalequation", contents);
+        } else {
+            return encloseContents("div", "informalequation", contents);
+        }
+    }
+
+    /**
+     * Handle an orderedlist
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleOrderedlist(Map<String, String> attributes, String contents) throws SAXException {
+        String numeration = "1";
+        String numAttr = attributes.get("numeration");
+        if (numAttr != null) {
+            if (numAttr.equals("loweralpha")) {
+                numeration = "a";
+            } else if (numAttr.equals("upperalpha")) {
+                numeration = "A";
+            } else if (numAttr.equals("lowerroman")) {
+                numeration = "i";
+            } else if (numAttr.equals("upperroman")) {
+                numeration = "I";
+            }
+        }
+
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("ol", new String[]{"type", numeration}, contents);
+        } else {
+            return encloseContents("ol", new String[]{"type", numeration}, contents);
+        }
+    }
+
+    /**
+     * Handle a subscript
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleSubscript(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("sub", contents);
+    }
+
+    /**
+     * Handle a replaceable
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleReplaceable(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("span", "replaceable", contents);
+    }
+
+    /**
+     * Handle a question
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleQuestion(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("dt", encloseContents("strong", contents));
+    }
+
+    /**
+     * Handle an answer
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleAnswer(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("dd", contents);
+    }
+
+    /**
+     * Handle a qandaentry
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleQandaentry(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("dl", contents);
+    }
+
+    /**
+     * Handle a qandaset
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleQandaset(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("div", "qandaset", contents);
+    }
+
+    /**
+     * Handle a caption
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleCaption(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("caption", encloseContents("b", contents));
+    }
+
+    /**
+     * Handle a tbody
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTbody(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("tbody", "tbody", contents);
+    }
+
+    /**
+     * Handle a table
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTable(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("table", "doctable", contents);
+        } else {
+            return encloseContents("table", "doctable", contents);
+        }
+    }
+
+    /**
+     * Handle a surname
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleSurname(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("span", "surname", contents);
+    }
+
+    /**
+     * Handle a firstname
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleFirstname(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("span", "firstname", contents);
+    }
+
+    /**
+     * Handle a bibliomset
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleBibliomset(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "bibliomset", contents);
+        } else {
+            return encloseContents("div", "bibliomset", contents);
+        }
+    }
+
+    /**
+     * Handle a bibliomixed
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleBibliomixed(Map<String, String> attributes, String contents) throws SAXException {
+        String id = attributes.get("id");
+        if (id != null) {
+            return "<a name=\"" + id + "\"></a>" + encloseContents("div", "bibliomixed", contents);
+        } else {
+            return encloseContents("div", "bibliomixed", contents);
+        }
+    }
+
+    /**
+     * Handle a th
+     * @param attributes the tag attributes
+     * @param contents the tag contents
+     * @return the HTML code
+     * @throws SAXEception if an error is encountered
+     */
+    public String handleTh(Map<String, String> attributes, String contents) throws SAXException {
+        return encloseContents("th", contents);
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookElement.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookElement.java
new file mode 100644 (file)
index 0000000..3894f9d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.util.Map;
+
+public class JavaHelpDocbookElement extends DocbookElement {
+       
+    private StringBuilder mapIdContents;
+    private DocbookElement parent;
+       
+    /**
+     * {@inheritDoc}
+     */
+    protected JavaHelpDocbookElement(String name, Map attributes) {
+       super(name, attributes);
+       mapIdContents = new StringBuilder();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public DocbookElement getNewInstance(String name, Map attributes) {
+       return new JavaHelpDocbookElement(name, attributes);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void append(Object obj) {
+       if (obj instanceof String) {
+           mapIdContents.append((String) obj);
+       } else if (obj instanceof StringBuilder) {
+           mapIdContents.append((StringBuilder) obj);
+       }
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public Object get() {
+       return mapIdContents;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setParent(DocbookElement elem) {
+       parent = elem;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public DocbookElement getParent() {
+       return parent;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookTagConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookTagConverter.java
new file mode 100644 (file)
index 0000000..77cd74e
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.xml.sax.SAXException;
+
+/**
+ * Class to convert DocBook to JavaHelp
+ * @author Calixte DENIZET
+ */
+public class JavaHelpDocbookTagConverter extends HTMLDocbookTagConverter {
+
+    private static final String XMLSTRING = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n";
+
+    private StringBuilder buffer = new StringBuilder(8192);
+
+    /**
+     * Constructor
+     * @param inName the name of the input stream
+     * @param primConf the file containing the primitives of Scilab
+     * @param macroConf the file containing the macros of Scilab
+     * @param out the output stream
+     */
+    public JavaHelpDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, boolean checkLast) throws IOException, SAXException {
+        super(inName, outName, primConf, macroConf, template, version, imageDir, checkLast);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endDocument() throws SAXException {
+        try {
+            FileOutputStream outToc = new FileOutputStream("jhelptoc.xml");
+            FileOutputStream outMap = new FileOutputStream("jhelpmap.jhm");
+            FileOutputStream outSet = new FileOutputStream("jhelpset.hs");
+            FileOutputStream outIndex = new FileOutputStream("jhelpidx.xml");
+            OutputStreamWriter writerIndex = new OutputStreamWriter(outIndex);
+            OutputStreamWriter writerSet = new OutputStreamWriter(outSet);
+            OutputStreamWriter writerMap = new OutputStreamWriter(outMap);
+            OutputStreamWriter writerToc = new OutputStreamWriter(outToc);
+            writerMap.append(XMLSTRING);
+            writerMap.append("<!DOCTYPE map PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\" \"http://java.sun.com/products/javahelp/map_1_0.dtd\">\n");
+            writerMap.append(convertMapId());
+            writerMap.flush();
+            writerMap.close();
+            outMap.flush();
+            outMap.close();
+
+            writerToc.append(XMLSTRING);
+            writerToc.append("<!DOCTYPE toc PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN\" \"http://java.sun.com/products/javahelp/toc_1_0.dtd\">\n");
+            writerToc.append(convertTocItem());
+            writerToc.flush();
+            writerToc.close();
+            outToc.flush();
+            outToc.close();
+
+            writerSet.append(XMLSTRING);
+            String str = "<!DOCTYPE helpset\n  PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN\" \"http://java.sun.com/products/javahelp/helpset_1_0.dtd\">\n<helpset version=\"1.0\">\n<title>TITLE</title>\n<maps>\n<homeID>top</homeID>\n<mapref location=\"jhelpmap.jhm\"/>\n</maps>\n<view>\n<name>TOC</name>\n<label>Table Of Contents</label>\n<type>javax.help.TOCView</type>\n<data>jhelptoc.xml</data>\n</view>\n<view>\n<name>Index</name>\n<label>Index</label>\n<type>javax.help.IndexView</type>\n<data>jhelpidx.xml</data>\n</view>\n<view>\n<name>Search</name>\n<label>Search</label>\n<type>javax.help.SearchView</type>\n<data engine=\"com.sun.java.help.search.DefaultSearchEngine\">JavaHelpSearch</data>\n</view>\n</helpset>".replaceFirst("TITLE", bookTitle);
+            writerSet.append(str);
+            writerSet.flush();
+            writerSet.close();
+            outSet.flush();
+            outSet.close();
+
+            writerIndex.append(XMLSTRING);
+            writerIndex.append("<!DOCTYPE index PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN\" \"http://java.sun.com/products/javahelp/index_1_0.dtd\">\n<index version=\"1.0\"/>");
+            writerIndex.flush();
+            writerIndex.close();
+            outIndex.flush();
+            outIndex.close();
+        } catch (IOException e) {
+            exceptionOccured(e);
+        }
+    }
+
+    private String convertMapId() {
+        buffer.setLength(0);
+        buffer.append("<map version=\"1.0\">\n<mapID target=\"index\" url=\"index.html\"/>\n");
+        Iterator<String> iter = mapId.keySet().iterator();
+        while (iter.hasNext()) {
+            String id = iter.next();
+            buffer.append("<mapID target=\"");
+            buffer.append(id);
+            buffer.append("\" url=\"");
+            buffer.append(mapId.get(id));
+            buffer.append("\"/>\n");
+        }
+        buffer.append("</map>");
+
+        return buffer.toString();
+    }
+
+    private void convertTreeId(HTMLDocbookLinkResolver.TreeId leaf) {
+        if (leaf.children != null) {
+            for (HTMLDocbookLinkResolver.TreeId c : leaf.children) {
+                buffer.append("<tocitem target=\"");
+                buffer.append(c.id);
+                buffer.append("\" text=\"");
+                buffer.append(tocitem.get(c.id));
+                if (c.children == null) {
+                    buffer.append("\"/>\n");
+                } else {
+                    buffer.append("\">\n");
+                    convertTreeId(c);
+                    buffer.append("</tocitem>\n");
+                }
+            }
+        }
+    }
+
+    private String convertTocItem() {
+        buffer.setLength(0);
+        buffer.append("<toc version=\"1.0\">\n<tocitem target=\"index\" text=\"" + bookTitle + "\">\n");
+        convertTreeId(tree);
+        buffer.append("</tocitem>\n</toc>");
+
+        return buffer.toString();
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocMain.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocMain.java
new file mode 100644 (file)
index 0000000..b9891cd
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.scilab.modules.commons.ScilabConstants;
+import org.scilab.modules.helptools.BuildJavaHelp;
+import org.scilab.modules.helptools.Helpers;
+
+import org.scilab.forge.scidoc.external.HTMLMathMLHandler;
+import org.scilab.forge.scidoc.external.HTMLSVGHandler;
+
+/**
+ * Class to convert DocBook to HTML
+ * @author Calixte DENIZET
+ */
+public final class SciDocMain {
+
+    private String input;
+    private String outputDirectory;
+    private String language;
+    private String format;
+    private String template;
+    private String sciprim;
+    private String scimacro;
+    private String version;
+    private String imagedir;
+    private static final String SCI = ScilabConstants.SCI.getPath();
+
+
+    /**
+     * Set the directory where files must be exported
+     * Note that directory is created
+     *
+     * @param outputDirectoryectory The path to the directory
+     * @return If the directory exists
+     */
+    public boolean setOutputDirectory(String outputDirectory) {
+        File directory = new File(outputDirectory);
+        if (!directory.isDirectory()) {
+            if (!directory.mkdirs()) {
+                return false;
+            }
+        }
+        this.outputDirectory = outputDirectory;
+        return true;
+    }
+
+    /**
+     * Defines the language
+     *
+     * @param language the language (xx_XX ex: en_US, fr_FR)
+     */
+    public void setWorkingLanguage(String language) {
+        this.language = language;
+    }
+
+    /**
+     * Defines the export format
+     * @param format the format (among the list CHM, HTML, PDF, JH, PS)
+     */
+    public void setExportFormat(String format) {
+        this.format = format;
+    }
+
+    public static void main(String[] args) {
+        SciDocMain sciDoc = new SciDocMain();
+        sciDoc.buildDocumentationCommandLine(args);
+    }
+
+    public void buildDocumentationCommandLine(String[] args) {
+        Map<String, String> map = parseCommandLine(args);
+        if (map.containsKey("help")) {
+            System.out.println("Usage scidoc [OPTION]... file");
+            System.out.println("SciDoc is a tool to generate html or javahelp files from DocBook");
+            System.out.println("");
+            System.out.println("-input        Input DocBook file");
+            System.out.println("-output       The output directory");
+            System.out.println("-template     A template file used for the generation");
+            System.out.println("-imagedir     The directory which will contain the generated images");
+            System.out.println("              the path is relative to output");
+            System.out.println("-javahelp     No expected argument, just precise the kind of output");
+            System.out.println("-html         No expected argument, just precise the kind of output (default)");
+            System.out.println("-sciprim      A file containing the list of the Scilab primitives");
+            System.out.println("-scimacro     A file containing the list of the Scilab macros");
+            System.out.println("-version      A string with the version of Scilab");
+            //System.out.println("-checklast    true or false, just say if the date of the last generation");
+            //System.out.println("              must be checked, it could be useful to regenerate only the changed files");
+            System.out.println("");
+            System.out.println("Report bugs on: <http://bugzilla.scilab.org>");
+            System.out.println("Project page: <http://forge.scilab.org/index.php/p/scidoc>");
+            return;
+        }
+
+        if (!map.containsKey("input")) {
+            System.err.println("No input file");
+            System.err.println("Use the option -help");
+            return;
+        }
+
+        if (!map.containsKey("template")) {
+            System.err.println("No template to generate files");
+            System.err.println("Use the option -help");
+            return;
+        }
+
+        if (!map.containsKey("imagedir")) {
+            System.err.println("No image directory specified");
+            System.err.println("Use the option -help");
+            return;
+        }
+
+        input = map.get("input");
+        outputDirectory = map.get("output");
+        if (outputDirectory == null || outputDirectory.length() == 0) {
+            outputDirectory = ".";
+        }
+        template = map.get("template");
+        sciprim = map.get("sciprim");
+        scimacro = map.get("scimacro");
+        version = map.get("version");
+        imagedir = map.get("imagedir");
+
+        if (map.containsKey("javahelp")) {
+            process(input, "");
+        } else {
+            process(input, "");
+        }
+    }
+
+    /* Stylesheet is useless and just kept to keep the consistency with
+     * builddoc V1 */
+    public String process(String sourceDoc, String styleSheet)  {
+        template = SCI + "/modules/helptools/data/template/template_" + format.toLowerCase() + ".html";
+        /* TODO: make this file generated at build time of Scilab */
+        sciprim = SCI + "/modules/helptools/data/configuration/scilab_primitives.txt";
+        scimacro = SCI + "/modules/helptools/data/configuration/scilab_macros.txt";
+        /* Detect this somewhere */
+        version = "Scilab 5.3.0 beta4";
+        imagedir = ".";//the path must be relative to outputDirectory
+
+        if (!new File(sourceDoc).isFile()) {
+            //                  throw new FileNotFoundException("Could not find master document: " + sourceDoc);
+        }
+        boolean checkLast = false;//Boolean.parseBoolean(map.get("checklast"));
+        try {
+            DocbookTagConverter converter = null;
+            if (format.equalsIgnoreCase("javahelp")) {
+                converter = new JavaHelpDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast);
+            } else if (format.equalsIgnoreCase("html")) {
+                converter = new HTMLDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast);
+            } else if (format.equalsIgnoreCase("chm")) {
+                converter = new CHMDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast);
+            }
+
+            converter.registerExternalXMLHandler(new HTMLMathMLHandler(outputDirectory, imagedir));
+            converter.registerExternalXMLHandler(new HTMLSVGHandler(outputDirectory, imagedir));
+            converter.convert();
+            Helpers.copyFile(new File(SCI + "/modules/helptools/data/css/scilab_code.css"), new File(outputDirectory + "/scilab_code.css"));
+            Helpers.copyFile(new File(SCI + "/modules/helptools/data/css/style.css"), new File(outputDirectory + "/style.css"));
+            if (format.equalsIgnoreCase("javahelp")) {
+                BuildJavaHelp.buildJavaHelp(outputDirectory, language); // replace en_US by language
+            }
+
+        } catch (Exception e) {
+            System.err.println("An error occured during the conversion:\n");
+            e.printStackTrace();
+        }
+        return outputDirectory;
+    }
+
+
+    private static Map<String, String> parseCommandLine(String[] args) {
+        String option = null;
+        boolean in = false;
+        Map<String, String> map = new HashMap();
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].length() >= 2 && args[i].charAt(0) == '-') {
+                if (option != null) {
+                    map.put(option, "");
+                    option = null;
+                    option = args[i];
+                }
+                if (args[i].charAt(1) == '-') {
+                    option = args[i].substring(2);
+                } else {
+                    option = args[i].substring(1);
+                }
+            } else {
+                if (option != null) {
+                    map.put(option, args[i]);
+                    option = null;
+                } else if (!in) {
+                    map.put("input", args[i]);
+                    in = true;
+                } else {
+                    System.err.println("Not an argument " + args[i]);
+                    return null;
+                }
+            }
+        }
+        if (option != null) {
+            map.put(option, "");
+        }
+
+        return map;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SynopsisLexer.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SynopsisLexer.java
new file mode 100644 (file)
index 0000000..54f8678
--- /dev/null
@@ -0,0 +1,621 @@
+/* The following code was generated by JFlex 1.4.3 on 02/11/10 14:45 */
+
+//CHECKSTYLE:OFF
+
+package org.scilab.forge.scidoc ;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+
+/**
+ * This class is a scanner generated by 
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 02/11/10 14:45 from the specification file
+ * <tt>function.jflex</tt>
+ */
+public final class SynopsisLexer {
+
+  /** This character denotes the end of file */
+  public static final int YYEOF = -1;
+
+  /** initial size of the lookahead buffer */
+  private static final int ZZ_BUFFERSIZE = 16384;
+
+  /** lexical states */
+  public static final int YYINITIAL = 0;
+
+  /**
+   * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+   * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+   *                  at the beginning of a line
+   * l is of the form l = 2*k, k a non negative integer
+   */
+  private static final int ZZ_LEXSTATE[] = { 
+     0, 0
+  };
+
+  /** 
+   * Translates characters to character classes
+   */
+  private static final String ZZ_CMAP_PACKED = 
+    "\11\0\1\1\1\3\2\0\1\2\22\0\1\1\1\6\1\12\1\6"+
+    "\1\7\1\4\1\11\1\13\7\0\1\10\12\5\2\0\1\14\1\0"+
+    "\1\15\1\6\1\0\32\6\4\0\1\6\1\0\32\6\uff85\0";
+
+  /** 
+   * Translates characters to character classes
+   */
+  private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+  /** 
+   * Translates DFA states to action switch labels.
+   */
+  private static final int [] ZZ_ACTION = zzUnpackAction();
+
+  private static final String ZZ_ACTION_PACKED_0 =
+    "\1\0\1\1\1\2\2\3\1\4\2\1\1\5\1\6"+
+    "\1\7\1\10\1\11\1\4\1\12";
+
+  private static int [] zzUnpackAction() {
+    int [] result = new int[15];
+    int offset = 0;
+    offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackAction(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+
+  /* error codes */
+  private static final int ZZ_UNKNOWN_ERROR = 0;
+  private static final int ZZ_NO_MATCH = 1;
+  private static final int ZZ_PUSHBACK_2BIG = 2;
+
+  /* error messages for the codes above */
+  private static final String ZZ_ERROR_MSG[] = {
+    "Unkown internal scanner error",
+    "Error: could not match input",
+    "Error: pushback value was too large"
+  };
+
+  /** the input device */
+  private java.io.Reader zzReader;
+
+  /** the current state of the DFA */
+  private int zzState;
+
+  /** the current lexical state */
+  private int zzLexicalState = YYINITIAL;
+
+  /** this buffer contains the current text to be matched and is
+      the source of the yytext() string */
+  private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+  /** the textposition at the last accepting state */
+  private int zzMarkedPos;
+
+  /** the current text position in the buffer */
+  private int zzCurrentPos;
+
+  /** startRead marks the beginning of the yytext() string in the buffer */
+  private int zzStartRead;
+
+  /** endRead marks the last character in the buffer, that has been read
+      from input */
+  private int zzEndRead;
+
+  /** number of newlines encountered up to the start of the matched text */
+  private int yyline;
+
+  /** the number of characters up to the start of the matched text */
+  private int yychar;
+
+  /**
+   * the number of characters from the last newline up to the start of the 
+   * matched text
+   */
+  private int yycolumn;
+
+  /** 
+   * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+   */
+  private boolean zzAtBOL = true;
+
+  /** zzAtEOF == true <=> the scanner is at the EOF */
+  private boolean zzAtEOF;
+
+  /** denotes if the user-EOF-code has already been executed */
+  private boolean zzEOFDone;
+
+  /* user code: */
+    private static String currentName;
+    private static StringBuilder htmlBuffer = new StringBuilder(512);
+    private static SynopsisLexer lexer = new SynopsisLexer();
+
+    private SynopsisLexer() { }
+
+    public static String convert(String name, String str) {
+        currentName = name;
+        try {
+            lexer.yyreset(new StringReader(str.trim()));
+           lexer.yybegin(YYINITIAL);
+            htmlBuffer.setLength(0);
+           lexer.yylex();
+           
+           return htmlBuffer.toString();
+        } catch (IOException e) {
+            return null;
+        }
+    }
+
+
+
+  /**
+   * Creates a new scanner
+   * There is also a java.io.InputStream version of this constructor.
+   *
+   * @param   in  the java.io.Reader to read input from.
+   */
+  public SynopsisLexer(java.io.Reader in) {
+    this.zzReader = in;
+  }
+
+  /**
+   * Creates a new scanner.
+   * There is also java.io.Reader version of this constructor.
+   *
+   * @param   in  the java.io.Inputstream to read input from.
+   */
+  public SynopsisLexer(java.io.InputStream in) {
+    this(new java.io.InputStreamReader(in));
+  }
+
+  /** 
+   * Unpacks the compressed character translation table.
+   *
+   * @param packed   the packed character translation table
+   * @return         the unpacked character translation table
+   */
+  private static char [] zzUnpackCMap(String packed) {
+    char [] map = new char[0x10000];
+    int i = 0;  /* index in packed string  */
+    int j = 0;  /* index in unpacked array */
+    while (i < 58) {
+      int  count = packed.charAt(i++);
+      char value = packed.charAt(i++);
+      do map[j++] = value; while (--count > 0);
+    }
+    return map;
+  }
+
+
+  /**
+   * Refills the input buffer.
+   *
+   * @return      <code>false</code>, iff there was new input.
+   * 
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  private boolean zzRefill() throws java.io.IOException {
+
+    /* first: make room (if you can) */
+    if (zzStartRead > 0) {
+      System.arraycopy(zzBuffer, zzStartRead,
+                       zzBuffer, 0,
+                       zzEndRead-zzStartRead);
+
+      /* translate stored positions */
+      zzEndRead-= zzStartRead;
+      zzCurrentPos-= zzStartRead;
+      zzMarkedPos-= zzStartRead;
+      zzStartRead = 0;
+    }
+
+    /* is the buffer big enough? */
+    if (zzCurrentPos >= zzBuffer.length) {
+      /* if not: blow it up */
+      char newBuffer[] = new char[zzCurrentPos*2];
+      System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+      zzBuffer = newBuffer;
+    }
+
+    /* finally: fill the buffer with new input */
+    int numRead = zzReader.read(zzBuffer, zzEndRead,
+                                            zzBuffer.length-zzEndRead);
+
+    if (numRead > 0) {
+      zzEndRead+= numRead;
+      return false;
+    }
+    // unlikely but not impossible: read 0 characters, but not at end of stream    
+    if (numRead == 0) {
+      int c = zzReader.read();
+      if (c == -1) {
+        return true;
+      } else {
+        zzBuffer[zzEndRead++] = (char) c;
+        return false;
+      }     
+    }
+
+       // numRead < 0
+    return true;
+  }
+
+    
+  /**
+   * Closes the input stream.
+   */
+  public final void yyclose() throws java.io.IOException {
+    zzAtEOF = true;            /* indicate end of file */
+    zzEndRead = zzStartRead;  /* invalidate buffer    */
+
+    if (zzReader != null)
+      zzReader.close();
+  }
+
+
+  /**
+   * Resets the scanner to read from a new input stream.
+   * Does not close the old reader.
+   *
+   * All internal variables are reset, the old input stream 
+   * <b>cannot</b> be reused (internal buffer is discarded and lost).
+   * Lexical state is set to <tt>ZZ_INITIAL</tt>.
+   *
+   * @param reader   the new input stream 
+   */
+  public final void yyreset(java.io.Reader reader) {
+    zzReader = reader;
+    zzAtBOL  = true;
+    zzAtEOF  = false;
+    zzEOFDone = false;
+    zzEndRead = zzStartRead = 0;
+    zzCurrentPos = zzMarkedPos = 0;
+    yyline = yychar = yycolumn = 0;
+    zzLexicalState = YYINITIAL;
+  }
+
+
+  /**
+   * Returns the current lexical state.
+   */
+  public final int yystate() {
+    return zzLexicalState;
+  }
+
+
+  /**
+   * Enters a new lexical state
+   *
+   * @param newState the new lexical state
+   */
+  public final void yybegin(int newState) {
+    zzLexicalState = newState;
+  }
+
+
+  /**
+   * Returns the text matched by the current regular expression.
+   */
+  public final String yytext() {
+    return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+  }
+
+
+  /**
+   * Returns the character at position <tt>pos</tt> from the 
+   * matched text. 
+   * 
+   * It is equivalent to yytext().charAt(pos), but faster
+   *
+   * @param pos the position of the character to fetch. 
+   *            A value from 0 to yylength()-1.
+   *
+   * @return the character at position pos
+   */
+  public final char yycharat(int pos) {
+    return zzBuffer[zzStartRead+pos];
+  }
+
+
+  /**
+   * Returns the length of the matched text region.
+   */
+  public final int yylength() {
+    return zzMarkedPos-zzStartRead;
+  }
+
+
+  /**
+   * Reports an error that occured while scanning.
+   *
+   * In a wellformed scanner (no or only correct usage of 
+   * yypushback(int) and a match-all fallback rule) this method 
+   * will only be called with things that "Can't Possibly Happen".
+   * If this method is called, something is seriously wrong
+   * (e.g. a JFlex bug producing a faulty scanner etc.).
+   *
+   * Usual syntax/scanner level error handling should be done
+   * in error fallback rules.
+   *
+   * @param   errorCode  the code of the errormessage to display
+   */
+  private void zzScanError(int errorCode) {
+    String message;
+    try {
+      message = ZZ_ERROR_MSG[errorCode];
+    }
+    catch (ArrayIndexOutOfBoundsException e) {
+      message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+    }
+
+    throw new Error(message);
+  } 
+
+
+  /**
+   * Pushes the specified amount of characters back into the input stream.
+   *
+   * They will be read again by then next call of the scanning method
+   *
+   * @param number  the number of characters to be read again.
+   *                This number must not be greater than yylength()!
+   */
+  public void yypushback(int number)  {
+    if ( number > yylength() )
+      zzScanError(ZZ_PUSHBACK_2BIG);
+
+    zzMarkedPos -= number;
+  }
+
+
+  /**
+   * Resumes scanning until the next regular expression is matched,
+   * the end of input is encountered or an I/O-Error occurs.
+   *
+   * @return      the next token
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  public void yylex() throws java.io.IOException {
+    int zzInput;
+    int zzAction;
+
+    // cached fields:
+    int zzCurrentPosL;
+    int zzMarkedPosL;
+    int zzEndReadL = zzEndRead;
+    char [] zzBufferL = zzBuffer;
+    char [] zzCMapL = ZZ_CMAP;
+
+
+    while (true) {
+      zzMarkedPosL = zzMarkedPos;
+
+      yychar+= zzMarkedPosL-zzStartRead;
+
+      zzAction = -1;
+
+      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+  
+      zzState = ZZ_LEXSTATE[zzLexicalState];
+
+
+      zzForAction: {
+        while (true) {
+    
+          if (zzCurrentPosL < zzEndReadL)
+            zzInput = zzBufferL[zzCurrentPosL++];
+          else if (zzAtEOF) {
+            zzInput = YYEOF;
+            break zzForAction;
+          }
+          else {
+            // store back cached positions
+            zzCurrentPos  = zzCurrentPosL;
+            zzMarkedPos   = zzMarkedPosL;
+            boolean eof = zzRefill();
+            // get translated positions and possibly new buffer
+            zzCurrentPosL  = zzCurrentPos;
+            zzMarkedPosL   = zzMarkedPos;
+            zzBufferL      = zzBuffer;
+            zzEndReadL     = zzEndRead;
+            if (eof) {
+              zzInput = YYEOF;
+              break zzForAction;
+            }
+            else {
+              zzInput = zzBufferL[zzCurrentPosL++];
+            }
+          }
+          zzInput = zzCMapL[zzInput];
+
+          boolean zzIsFinal = false;
+          boolean zzNoLookAhead = false;
+
+          zzForNext: { switch (zzState) {
+            case 0:
+              switch (zzInput) {
+                case 1: zzIsFinal = true; zzState = 2; break zzForNext;
+                case 2: zzIsFinal = true; zzState = 3; break zzForNext;
+                case 3: zzIsFinal = true; zzState = 4; break zzForNext;
+                case 4: 
+                case 6: zzIsFinal = true; zzState = 5; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 6; break zzForNext;
+                case 8: zzIsFinal = true; zzState = 7; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 8; break zzForNext;
+                case 10: zzIsFinal = true; zzNoLookAhead = true; zzState = 9; break zzForNext;
+                case 11: zzIsFinal = true; zzNoLookAhead = true; zzState = 10; break zzForNext;
+                case 12: zzIsFinal = true; zzNoLookAhead = true; zzState = 11; break zzForNext;
+                case 13: zzIsFinal = true; zzNoLookAhead = true; zzState = 12; break zzForNext;
+                default: zzIsFinal = true; zzState = 1; break zzForNext;
+              }
+
+            case 1:
+              switch (zzInput) {
+                case 0: 
+                case 1: 
+                case 5: 
+                case 7: zzIsFinal = true; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 2:
+              switch (zzInput) {
+                case 0: 
+                case 5: 
+                case 7: zzIsFinal = true; zzState = 1; break zzForNext;
+                case 1: zzIsFinal = true; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 3:
+              switch (zzInput) {
+                case 1: 
+                case 3: zzIsFinal = true; zzState = 4; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 4:
+              switch (zzInput) {
+                case 1: zzIsFinal = true; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 5:
+              switch (zzInput) {
+                case 5: 
+                case 6: 
+                case 7: zzIsFinal = true; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 6:
+              switch (zzInput) {
+                case 0: 
+                case 1: zzIsFinal = true; zzState = 1; break zzForNext;
+                case 6: zzIsFinal = true; zzState = 5; break zzForNext;
+                case 5: 
+                case 7: zzIsFinal = true; zzState = 13; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 7:
+              switch (zzInput) {
+                case 8: zzIsFinal = true; zzState = 14; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 13:
+              switch (zzInput) {
+                case 0: 
+                case 1: zzIsFinal = true; zzState = 1; break zzForNext;
+                case 6: zzIsFinal = true; zzState = 5; break zzForNext;
+                case 5: 
+                case 7: zzIsFinal = true; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 14:
+              switch (zzInput) {
+                case 2: 
+                case 3: break zzForAction;
+                default: zzIsFinal = true; break zzForNext;
+              }
+
+            default:
+              // if this is ever reached, there is a serious bug in JFlex
+              zzScanError(ZZ_UNKNOWN_ERROR);
+              break;
+          } }
+
+          if ( zzIsFinal ) {
+            zzAction = zzState;
+            zzMarkedPosL = zzCurrentPosL;
+            if ( zzNoLookAhead ) break zzForAction;
+          }
+
+        }
+      }
+
+      // store back cached position
+      zzMarkedPos = zzMarkedPosL;
+
+      switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+        case 10: 
+          { htmlBuffer.append("<span class=\"comment\">");
+                                  htmlBuffer.append(yytext());
+                                  htmlBuffer.append("</span>");
+          }
+        case 11: break;
+        case 9: 
+          { htmlBuffer.append("&gt;");
+          }
+        case 12: break;
+        case 2: 
+          { htmlBuffer.append(" ");
+          }
+        case 13: break;
+        case 3: 
+          { htmlBuffer.append("\n");
+          }
+        case 14: break;
+        case 5: 
+          { htmlBuffer.append("&amp;");
+          }
+        case 15: break;
+        case 4: 
+          { String str = yytext();
+                                  if (str.equals(currentName)) {
+                                     htmlBuffer.append("<span class=\"functionid\">");
+                                  } else {
+                                     htmlBuffer.append("<span class=\"default\">");
+                                  }                            
+                                  htmlBuffer.append(str);
+                                  htmlBuffer.append("</span>");
+          }
+        case 16: break;
+        case 8: 
+          { htmlBuffer.append("&lt;");
+          }
+        case 17: break;
+        case 6: 
+          { htmlBuffer.append("&quot;");
+          }
+        case 18: break;
+        case 1: 
+          { htmlBuffer.append("<span class=\"default\">");
+                                  htmlBuffer.append(yytext());
+                                  htmlBuffer.append("</span>");
+          }
+        case 19: break;
+        case 7: 
+          { htmlBuffer.append("&apos;");
+          }
+        case 20: break;
+        default: 
+          if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+            zzAtEOF = true;
+              {   return;
+ }
+          } 
+          else {
+            zzScanError(ZZ_NO_MATCH);
+          }
+      }
+    }
+  }
+
+
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateFiller.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateFiller.java
new file mode 100644 (file)
index 0000000..f336a99
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+/**
+ * Class to convert DocBook to JavaHelp
+ * @author Calixte DENIZET
+ */
+public interface TemplateFiller {
+
+    /**
+     * Make a previous item for the current id
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makePrevious(String id);
+
+    /**
+     * Make a previous item for the current id
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makePath(String id);
+
+    /**
+     * Make a top item for the current id
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeTop(String id);
+
+    /**
+     * Make a next item for the current id
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeNext(String id);
+
+    /**
+     * Make a list of the tocs
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeTocList(String id);
+
+    /**
+     * Make the lastModified html
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeLastModified(String id);
+
+    /**
+     * Make the subtitle
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeSubtitle(String id);
+
+    /**
+     * Make the title
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeTitle(String id);
+
+    /**
+     * Make the generation date
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeGenerationDate(String id);
+
+    /**
+     * Make the version
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeVersion(String id);
+
+    /**
+     * Make the start tag
+     * @param current id
+     * @return the corresponding html
+     */
+    public String makeStart(String id);
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/TemplateHandler.java
new file mode 100644 (file)
index 0000000..3d0597c
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.BufferedReader;
+import java.io.FileReader;
+
+/**
+ * Class to handle a template
+ * @author Calixte DENIZET
+ */
+public class TemplateHandler {
+
+    private String[] array;
+    private TemplateFiller filler;
+
+    public TemplateHandler(TemplateFiller filler, File f) {
+        this.filler = filler;
+        parseFile(f);
+    }
+
+    public void generateFileFromTemplate(String fileName, String id, String contents) {
+        try {
+            OutputStream out = new FileOutputStream(fileName);
+            OutputStreamWriter writer = new OutputStreamWriter(out);
+
+            for (int i = 0; i < array.length; i += 2) {
+                writer.append(array[i]);
+                String str = "";
+                if (i + 1 < array.length) {
+                    if (array[i + 1].equals("content")) {
+                        str = contents;
+                    } else if (array[i + 1].equals("top")) {
+                        str = filler.makeTop(id);
+                    } else if (array[i + 1].equals("previous")) {
+                        str = filler.makePrevious(id);
+                    } else if (array[i + 1].equals("next")) {
+                        str = filler.makeNext(id);
+                    } else if (array[i + 1].equals("path")) {
+                        str = filler.makePath(id);
+                    } else if (array[i + 1].equals("title")) {
+                        str = filler.makeTitle(id);
+                    } else if (array[i + 1].equals("subtitle")) {
+                        str = filler.makeSubtitle(id);
+                    } else if (array[i + 1].equals("toclist")) {
+                        str = filler.makeTocList(id);
+                    } else if (array[i + 1].equals("lastmodified")) {
+                        str = filler.makeLastModified(id);
+                    } else if (array[i + 1].equals("generationdate")) {
+                        str = filler.makeGenerationDate(id);
+                    } else if (array[i + 1].equals("version")) {
+                        str = filler.makeVersion(id);;
+                    } else if (array[i + 1].equals("start")) {
+                        str = filler.makeStart(id);
+                    }
+                    writer.append(str);
+                }
+            }
+
+            writer.flush();
+            writer.close();
+            out.flush();
+            out.close();
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+    }
+
+    private void parseFile(File f) {
+        try {
+            BufferedReader reader = new BufferedReader(new FileReader(f));
+            String line = null;
+            StringBuilder stringBuilder = new StringBuilder();
+            while ((line = reader.readLine()) != null ) {
+                stringBuilder.append(line);
+                stringBuilder.append("\n");
+            }
+
+            array = stringBuilder.toString().split("(<!--<)|(>-->)");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/UnhandledDocbookTagException.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/UnhandledDocbookTagException.java
new file mode 100644 (file)
index 0000000..a416ef2
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import org.xml.sax.SAXException;
+
+public class UnhandledDocbookTagException extends SAXException {
+
+    public UnhandledDocbookTagException(String tag) {
+       super("The tag " + tag + " is not handled.");
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/ExternalXMLHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/ExternalXMLHandler.java
new file mode 100644 (file)
index 0000000..349faba
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.external;
+
+import org.xml.sax.Attributes;
+
+public abstract class ExternalXMLHandler {
+
+    public abstract StringBuilder startExternalXML(String localName, Attributes attributes);
+
+    public abstract String endExternalXML(String localName);
+
+    public abstract String getURI();
+
+    public void recreateTag(StringBuilder buf, String localName, Attributes attrs) {
+       if (attrs != null) {
+           buf.append("<");
+           buf.append(localName);
+           int len = attrs.getLength();
+           for (int i = 0; i < len; i++) {
+               String at = attrs.getLocalName(i);
+               if (at != null && at.length() > 0) {
+                   buf.append(" ");
+                   buf.append(at);
+                   buf.append("=\'");
+                   buf.append(attrs.getValue(i));
+                   buf.append("\'");
+               }
+           }
+       } else {
+           buf.append("</");
+           buf.append(localName);
+       }
+
+       buf.append(">");
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLMathMLHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLMathMLHandler.java
new file mode 100644 (file)
index 0000000..68f402e
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.external;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.xml.sax.Attributes;
+
+import org.scilab.forge.scidoc.image.ImageConverter;
+
+/**
+ * Handle the included SVG code
+ * @author Calixte DENIZET
+ */
+public class HTMLMathMLHandler extends ExternalXMLHandler {
+
+    private static final String MATH = "math";
+    private static final String BASENAME = "Equation_MathML_";
+
+    private int compt;
+    private StringBuilder buffer = new StringBuilder(8192);
+    private String baseDir;
+    private String outputDir;
+
+    /**
+     * Constructor
+     * @param baseDir the base directory where to put the generated images
+     */
+    public HTMLMathMLHandler(String outputDir, String baseDir) {
+        this.outputDir = outputDir + File.separator + baseDir;
+        this.baseDir = baseDir + "/";
+     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getURI() {
+        return "http://www.w3.org/1998/Math/MathML";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public StringBuilder startExternalXML(String localName, Attributes attributes) {
+        recreateTag(buffer, localName, attributes);
+        if (MATH.equals(localName)) {
+            return buffer;
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String endExternalXML(String localName) {
+        if (MATH.equals(localName)) {
+            recreateTag(buffer, localName, null);
+            File f = new File(outputDir, BASENAME + (compt++) + ".png");
+            Map<String, String> attributes = new HashMap();
+            attributes.put("fontsize", "16");
+
+            String ret = ImageConverter.getImageByCode(buffer.toString(), attributes, "image/mathml", f, baseDir + f.getName());
+            buffer.setLength(0);
+
+            return ret;
+        }
+
+        recreateTag(buffer, localName, null);
+
+        return null;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLSVGHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/external/HTMLSVGHandler.java
new file mode 100644 (file)
index 0000000..ede745b
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.external;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.xml.sax.Attributes;
+
+import org.scilab.forge.scidoc.image.ImageConverter;
+
+/**
+ * Handle the included SVG code
+ * @author Calixte DENIZET
+ */
+public class HTMLSVGHandler extends ExternalXMLHandler {
+
+    private static final String SVG = "svg";
+    private static final String BASENAME = "Equation_SVG_";
+
+    private int compt;
+    private StringBuilder buffer = new StringBuilder(8192);
+    private String baseDir;
+    private String outputDir;
+
+    /**
+     * Constructor
+     * @param baseDir the base directory where to put the generated images
+     */
+    public HTMLSVGHandler(String outputDir, String baseDir) {
+        this.outputDir = outputDir + File.separator + baseDir;
+        this.baseDir = baseDir + "/";
+     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getURI() {
+        return "http://www.w3.org/2000/svg";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public StringBuilder startExternalXML(String localName, Attributes attributes) {
+        recreateTag(buffer, localName, attributes);
+        if (SVG.equals(localName)) {
+            return buffer;
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String endExternalXML(String localName) {
+        if (SVG.equals(localName)) {
+            recreateTag(buffer, localName, null);
+            File f = new File(outputDir, BASENAME + (compt++) + ".png");
+            Map<String, String> attributes = new HashMap();
+
+            String ret = ImageConverter.getImageByCode(buffer.toString(), attributes, "image/svg", f, baseDir + f.getName());
+            buffer.setLength(0);
+
+            return ret;
+        }
+
+        recreateTag(buffer, localName, null);
+
+        return null;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ExternalImageConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ExternalImageConverter.java
new file mode 100644 (file)
index 0000000..8366278
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import java.io.File;
+import java.util.Map;
+
+public interface ExternalImageConverter {
+
+    public String getMimeType();
+
+    public String convertToImage(File f, Map<String, String> attributes, File imageFile, String imageName);
+
+    public String convertToImage(String str, Map<String, String> attributes, File imageFile, String imageName);
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/Image.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/Image.java
new file mode 100644 (file)
index 0000000..53cfe9b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import javax.swing.Icon;
+
+public class Image {
+
+    public Icon icon;
+    
+    public int width;
+    
+    public int height;
+    
+    public int ascent;
+
+    public int descent;
+
+    public Image(Icon icon, int width, int height, int ascent, int descent) {
+       this.icon = icon;
+       this.width = width;
+       this.height = height;
+       this.ascent = ascent;
+       this.descent = descent;
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ImageConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/ImageConverter.java
new file mode 100644 (file)
index 0000000..6f05adc
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.nio.channels.FileChannel;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.MimetypesFileTypeMap;
+import javax.imageio.ImageIO;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+
+/**
+ * Class to handle the image conversion
+ * @author Calixte DENIZET
+ */
+public final class ImageConverter {
+
+    private static Map<String, ExternalImageConverter> externalConverters = new HashMap();
+    private static MimetypesFileTypeMap mimeMap = new MimetypesFileTypeMap();
+
+    static {
+        mimeMap.addMimeTypes("type=image/latex exts=tex,latex");
+        mimeMap.addMimeTypes("type=image/mathml exts=mml,mathml");
+        mimeMap.addMimeTypes("type=image/svg exts=svg");
+    }
+
+    /**
+     * Register a new ExternalImageConverter
+     * @param c the converter to register
+     */
+    public static void registerExternalImageConverter(ExternalImageConverter c) {
+        if (c != null) {
+            externalConverters.put(c.getMimeType(), c);
+        }
+    }
+
+    /**
+     * @param attrs the attribute of the image
+     * @param path the current XML file which is parsed
+     * @param image the filename
+     * @param destDir the destination directory
+     * @return the HTML code to insert the image
+     */
+    public static String getImageByFile(Map<String, String> attrs, String path, String image, String outputDir, String destDir) {
+        File f = new File(image);
+        if (!f.isAbsolute()) {
+            f = new File(path + File.separator + image);
+        }
+
+        String destFile = outputDir + File.separator + destDir + File.separator + f.getName();
+
+        ExternalImageConverter conv = externalConverters.get(mimeMap.getContentType(f));
+        if (conv != null) {
+            destFile += ".png";
+        }
+        File imageFile = new File(destFile);
+        String imageName = destDir + "/" + imageFile.getName();
+
+        if (f.lastModified() > imageFile.lastModified()) {
+            if (conv != null) {
+                return conv.convertToImage(f, attrs, imageFile, imageName);
+            }
+            copyImageFile(f, destDir);
+        }
+
+        return "<img src=\'" + imageName + "\'/>";
+    }
+
+
+    /**
+     * @param code the code to translate
+     * @param attrs the attribute of the image
+     * @param mime type
+     * @param imageFile the filename
+     * @return the HTML code to insert the image
+     */
+    public static String getImageByCode(String code, Map<String, String> attrs, String mime, File imageFile, String imageName) {
+        ExternalImageConverter conv = externalConverters.get(mime);
+        if (conv != null) {
+            return conv.convertToImage(code, attrs, imageFile, imageName);
+        }
+        System.err.println("Code not handled:\n" + code);
+
+        return null;
+    }
+
+    /**
+     * @param code the code to translate
+     * @param img image informations
+     * @param fileName the filename
+     * @param attrs the attribute of the image
+     * @return the HTML code to insert the image
+     */
+    public static String generateCode(Image img, String fileName, Map<String, String> attrs) {
+        String style = (String) attrs.get("style");
+        String top = "";
+        boolean display = style != null && style.equals("display");
+
+        if (!display) {
+            top = "top:" + img.descent + "px;";
+        }
+
+        String alignAttr = (String) attrs.get("align");
+        String align = "";
+        String div = "div";
+        if (alignAttr != null) {
+            align = " style=\'text-align:" + alignAttr + "\'";
+        } else if (display) {
+            align = " style=\'text-align:center\'";
+        } else {
+            div = "span";
+        }
+
+        return "<" + div + align + "><img src=\'" + fileName + "\' style=\'position:relative;" + top  + "width:" + img.width + "px;height:" + img.height + "px\'/></" + div + ">";
+    }
+
+    /**
+     * @param f the file to copy
+     * @param destDir the destination directory
+     */
+    public static void copyImageFile(File f, String destDir) {
+        FileChannel src = null;
+        FileChannel dest = null;
+        try {
+            File destFile = new File(destDir + File.separator + f.getName());
+            if (!destFile.exists()) {
+                destFile.createNewFile();
+            } else if (f.lastModified() <= destFile.lastModified()) {
+                return;
+            }
+
+            src = new FileInputStream(f).getChannel();
+            dest = new FileOutputStream(destFile).getChannel();
+            dest.transferFrom(src, 0, src.size());
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+        finally {
+            try {
+                if (src != null) {
+                    src.close();
+                }
+                if (dest != null) {
+                    dest.close();
+                }
+            } catch (IOException e) {
+                System.err.println(e);
+            }
+        }
+    }
+
+    /**
+     * @param icon the icon to convert into PNG
+     * @param imageFile the destination file
+     * @return true if all is ok
+     */
+    public static boolean convertIconToPNG(Icon icon, File imageFile) {
+        BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g2d = image.createGraphics();
+        icon.paintIcon(null, g2d, 0, 0);
+
+        try {
+            ImageIO.write(image, "png", imageFile.getAbsoluteFile());
+        } catch (IOException ex) {
+            return false;
+        }
+
+        g2d.dispose();
+
+        return true;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/LaTeXImageConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/LaTeXImageConverter.java
new file mode 100644 (file)
index 0000000..7e9fae5
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.StringReader;
+import java.io.IOException;
+import java.util.Map;
+
+import javax.swing.JLabel;
+
+import org.scilab.forge.jlatexmath.TeXConstants;
+import org.scilab.forge.jlatexmath.TeXFormula;
+import org.scilab.forge.jlatexmath.TeXIcon;
+import org.scilab.forge.jlatexmath.ParseException;
+
+/**
+ * A LaTeX to PNG converter
+ * @author Calixte DENIZET
+ */
+public class LaTeXImageConverter implements ExternalImageConverter {
+
+    private static LaTeXImageConverter instance;
+
+    private LaTeXImageConverter() { }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getMimeType() {
+        return "image/latex";
+    }
+
+    /**
+     * Since it is a singleton class...
+     * @return this
+     */
+    public static ExternalImageConverter getInstance() {
+        if (instance == null) {
+             instance = new LaTeXImageConverter();
+        }
+        return instance;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(String latex, Map<String, String> attributes, File imageFile, String imageName) {
+        TeXIcon icon = null;
+        try {
+            TeXFormula formula = new TeXFormula(latex);
+            String display = attributes.get("style");
+            int style = TeXConstants.STYLE_DISPLAY;
+            if (display != null && display.equals("text")) {
+                style = TeXConstants.STYLE_TEXT;
+            }
+
+            icon = formula.createTeXIcon(style, Integer.parseInt(attributes.get("fontsize")));
+
+            Image img = new Image(icon, icon.getIconWidth(), icon.getIconHeight(), icon.getIconHeight() - icon.getIconDepth(), icon.getIconDepth());
+            if (img != null && ImageConverter.convertIconToPNG(img.icon, imageFile)) {
+                return ImageConverter.generateCode(img, imageName, attributes);
+            }
+
+            return null;
+
+        } catch (ParseException e) {
+            System.err.println(e);
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(File latex, Map<String, String> attributes, File imageFile, String imageName) {
+        BufferedReader input = null;
+        StringBuilder buffer = new StringBuilder();
+        boolean ok = false;
+        try {
+            input = new BufferedReader(new FileReader(latex));
+            String line = null;
+            while ((line = input.readLine()) != null) {
+                buffer.append(line);
+                buffer.append("\n");
+            }
+            ok = true;
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+        if (input != null) {
+            try {
+                input.close();
+            } catch (IOException e) {
+                System.err.println(e);
+            }
+        }
+
+        if (ok) {
+            return convertToImage(buffer.toString(), attributes, imageFile, imageName);
+        }
+
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/MathMLImageConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/MathMLImageConverter.java
new file mode 100644 (file)
index 0000000..0a7d95f
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import javax.swing.ImageIcon;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import net.sourceforge.jeuclid.MathMLParserSupport;
+import net.sourceforge.jeuclid.MutableLayoutContext;
+import net.sourceforge.jeuclid.layout.JEuclidView;
+import net.sourceforge.jeuclid.context.LayoutContextImpl;
+import net.sourceforge.jeuclid.context.Parameter;
+
+/**
+ * A MathML to PNG converter
+ * @author Calixte DENIZET
+ */
+public class MathMLImageConverter implements ExternalImageConverter {
+
+    private static final Graphics2D TEMPGRAPHIC = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
+    private static MathMLImageConverter instance;
+
+    private MathMLImageConverter() { }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getMimeType() {
+        return "image/mathml";
+    }
+
+    /**
+     * Since it is a singleton class...
+     * @return this
+     */
+    public static ExternalImageConverter getInstance() {
+        if (instance == null) {
+             instance = new MathMLImageConverter();
+        }
+        return instance;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(String mathml, Map<String, String> attributes, File imageFile, String imageName) {
+        Document doc = null;
+        try {
+            doc = MathMLParserSupport.parseString(mathml);
+        } catch (final SAXException e) {
+            return null;
+        } catch (final ParserConfigurationException e) {
+            return null;
+        } catch (final IOException e) {
+            return null;
+        }
+
+        String fontsize = attributes.get("fontsize");
+        int fs = 16;
+        if (fontsize != null) {
+            fs = Integer.parseInt(fontsize);
+        }
+
+        Image img = convertMathML(doc, fs);
+        if (img != null && ImageConverter.convertIconToPNG(img.icon, imageFile)) {
+            return ImageConverter.generateCode(img, imageName, attributes);
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(File mathml, Map<String, String> attributes, File imageFile, String imageName) {
+        Document doc = null;
+        try {
+            doc = MathMLParserSupport.parseFile(mathml);
+        } catch (final SAXException e) {
+            return null;
+        } catch (final IOException e) {
+            return null;
+        }
+
+        String fontsize = attributes.get("fontsize");
+        int fs = 16;
+        if (fontsize != null) {
+            fs = Integer.parseInt(fontsize);
+        }
+
+        Image img = convertMathML(doc, fs);
+        if (img != null && ImageConverter.convertIconToPNG(img.icon, imageFile)) {
+            return ImageConverter.generateCode(img, imageName, attributes);
+        }
+
+        return null;
+    }
+
+    /**
+     * @param mathml the document to convert
+     * @param fontSize the font size
+     * @return an image informations
+     */
+    private static Image convertMathML(Document mathml, int fontSize) {
+        LayoutContextImpl parameters = new LayoutContextImpl(LayoutContextImpl.getDefaultLayoutContext());
+        parameters.setParameter(Parameter.MATHSIZE, fontSize);
+        JEuclidView jev = new JEuclidView((Node) mathml, parameters, TEMPGRAPHIC);
+
+        int width = (int) Math.ceil(jev.getWidth());
+        int ascent = (int) Math.ceil(jev.getAscentHeight());
+        int height = (int) Math.ceil(jev.getDescentHeight()) + ascent;
+
+        if (width <= 0 || height <=0) {
+            return null;
+        }
+
+        BufferedImage bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g2d = bimg.createGraphics();
+        g2d.setColor(new Color(255, 255, 255, 0));
+        g2d.fillRect(0, 0, width, height);
+
+        jev.draw(g2d, 0, ascent);
+        g2d.dispose();
+
+        return new Image(new ImageIcon(bimg), width, height, ascent, height - ascent);
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/SVGImageConverter.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/image/SVGImageConverter.java
new file mode 100644 (file)
index 0000000..ec8ae17
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.image;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.util.Map;
+
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.Transcoder;
+import org.apache.batik.transcoder.image.ImageTranscoder;
+import org.apache.batik.transcoder.image.PNGTranscoder;
+
+/**
+ * SVG to PNG converter
+ */
+public class SVGImageConverter implements ExternalImageConverter {
+
+    private static SVGImageConverter instance;
+
+    private SVGImageConverter() { }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getMimeType() {
+        return "image/svg";
+    }
+
+    /**
+     * Since this a singleton class...
+     * @return this
+     */
+    public static ExternalImageConverter getInstance() {
+        if (instance == null) {
+             instance = new SVGImageConverter();
+        }
+
+        return instance;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(String svg, Map<String, String> attributes, File imageFile, String imageName) {
+        return convertToPNG(new TranscoderInput(new StringReader(svg)), imageFile, imageName);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String convertToImage(File svg, Map<String, String> attributes, File imageFile, String imageName) {
+        try {
+            return convertToPNG(new TranscoderInput(new FileInputStream(svg)), imageFile, imageName);
+        } catch (FileNotFoundException e) {
+            System.err.println("Problem when exporting SVG to " + imageFile + "!\n" + e.toString());
+        }
+
+        return null;
+    }
+
+    /**
+     * Make really the conversion from svg to png
+     */
+    private static String convertToPNG(TranscoderInput input, File imageFile, String imageName) {
+        Transcoder trans = new PNGTranscoder();
+        trans.addTranscodingHint(ImageTranscoder.KEY_FORCE_TRANSPARENT_WHITE, Boolean.TRUE);
+
+        try {
+            OutputStream os = new FileOutputStream(imageFile);
+            TranscoderOutput output = new TranscoderOutput(os);
+            trans.transcode(input, output);
+            os.flush();
+            os.close();
+            return "<img src=\'" + imageName + "\'/>";
+        } catch (Exception e) {
+            System.err.println("Problem when exporting SVG to " + imageFile + "!\n" + e.toString());
+        }
+
+        return null;
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/AbstractScilabCodeHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/AbstractScilabCodeHandler.java
new file mode 100644 (file)
index 0000000..d264bd6
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.scilab;
+
+import java.io.IOException;
+
+public abstract class AbstractScilabCodeHandler {
+
+    /**
+     * Handle default: when a char sequence is unidentified
+     * @param seq the sequence to append
+     */  
+    public void handleDefault(String seq) throws IOException { }
+
+    /**
+     * Handle operator: '+', '/', '*', ...
+     * @param seq the sequence to append
+     */  
+    public void handleOperator(String seq) throws IOException { }
+
+    /**
+     * Handle open/close: '(', ')', '[', ']', ...
+     * @param seq the sequence to append
+     */  
+    public void handleOpenClose(String seq) throws IOException { }
+
+    /**
+     * Handle function keywords: 'function' or 'endfunction' 
+     * @param seq the sequence to append
+     */  
+    public void handleFKeywords(String seq) throws IOException { }
+
+    /**
+     * Handle structure keywords: 'if', 'for', ...
+     * @param seq the sequence to append
+     */  
+    public void handleSKeywords(String seq) throws IOException { }
+
+    /**
+     * Handle control keywords: 'abort', 'return', ...
+     * @param seq the sequence to append
+     */  
+    public void handleCKeywords(String seq) throws IOException { }
+
+    /**
+     * Handle contants: '%pi', '%e', ...
+     * @param seq the sequence to append
+     */  
+    public void handleConstants(String seq) throws IOException { }
+
+    /**
+     * Handle command: 'sin', 'cos', ...
+     * @param seq the sequence to append
+     */  
+    public void handleCommand(String seq) throws IOException { }
+
+    /**
+     * Handle macro: 'cosh', 'sinh', ...
+     * @param seq the sequence to append
+     */  
+    public void handleMacro(String seq) throws IOException { }
+
+    /**
+     * Handle function identifier which appears in the code
+     * @param seq the sequence to append
+     */  
+    public void handleFunctionId(String seq) throws IOException { }
+
+    /**
+     * Handle function identifier: 'function identifier(...)'
+     * @param seq the sequence to append
+     */  
+    public void handleFunctionIdDecl(String seq) throws IOException { }
+
+    /**
+     * Handle a valid scilab identifier
+     * @param seq the sequence to append
+     */  
+    public void handleId(String seq) throws IOException { }
+
+    /**
+     * Handle in/out args: 'function [...,out,...]=id(...,in,...)'
+     * @param seq the sequence to append
+     */  
+    public void handleInputOutputArgsDecl(String seq) throws IOException { }
+
+    /**
+     * Handle in/out args which appears in the code
+     * @param seq the sequence to append
+     */  
+    public void handleInputOutputArgs(String seq) throws IOException { }
+
+    /**
+     * Handle number: 123, 123.4, 123e4...
+     * @param seq the sequence to append
+     */  
+    public void handleNumber(String seq) throws IOException { }
+
+    /**
+     * Handle special: '$', ':', '..' (break operator)
+     * @param seq the sequence to append
+     */  
+    public void handleSpecial(String seq) throws IOException { }
+
+    /**
+     * Handle string: "hello world"
+     * @param seq the sequence to append
+     */  
+    public void handleString(String seq) throws IOException { }
+
+    /**
+     * Handle nothing: when no particular formatting is required
+     * @param seq the sequence to append
+     */  
+    public void handleNothing(String seq) throws IOException { }
+
+    /**
+     * Handle field: 'foo.bar'
+     * @param seq the sequence to append
+     */  
+    public void handleField(String seq) throws IOException { }
+
+    /**
+     * Handle comment: '// comments...'
+     * @param seq the sequence to append
+     */  
+    public void handleComment(String seq) throws IOException { }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLScilabCodeHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLScilabCodeHandler.java
new file mode 100644 (file)
index 0000000..311c685
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.scilab;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class HTMLScilabCodeHandler extends AbstractScilabCodeHandler {
+
+    private static final int BUFCAPACITY = 8192;
+    private static HTMLScilabCodeHandler handler = new HTMLScilabCodeHandler();
+    
+    protected Map<String, String> mapId;
+    protected String currentCommand;
+    protected Appendable buffer;
+    
+    protected HTMLScilabCodeHandler() {
+       buffer = new StringBuilder(BUFCAPACITY);
+    }
+
+    public static AbstractScilabCodeHandler getInstance(String currentCommand, Map<String, String> mapId) {
+       handler.currentCommand = currentCommand;
+       handler.mapId = mapId;
+       ((StringBuilder) handler.buffer).setLength(0);
+       return handler;
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleDefault(String seq) throws IOException {
+       buffer.append("<span class=\"default\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleOperator(String seq) throws IOException {
+       buffer.append("<span class=\"operator\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleOpenClose(String seq) throws IOException {
+       buffer.append("<span class=\"openclose\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleFKeywords(String seq) throws IOException {
+       buffer.append("<span class=\"fkeyword\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleSKeywords(String seq) throws IOException {
+       buffer.append("<span class=\"skeyword\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleCKeywords(String seq) throws IOException {
+       buffer.append("<span class=\"ckeyword\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleConstants(String seq) throws IOException {
+       buffer.append("<span class=\"constants\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleCommand(String seq) throws IOException {
+       if (seq.equals(currentCommand)) {
+           buffer.append("<span class=\"command\">");
+           buffer.append(seq);
+           buffer.append("</span>");
+       } else {
+           buffer.append("<a class=\"command\" href=\"");
+           buffer.append(mapId.get(seq));
+           buffer.append("\">");
+           buffer.append(seq);
+           buffer.append("</a>");
+       }
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleMacro(String seq) throws IOException {
+       if (seq.equals(currentCommand)) {
+           buffer.append("<span class=\"macro\">");
+           buffer.append(seq);
+           buffer.append("</span>");
+       } else {
+           buffer.append("<a class=\"macro\" href=\"");
+           buffer.append(mapId.get(seq));
+           buffer.append("\">");
+           buffer.append(seq);
+           buffer.append("</a>");
+       }
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleFunctionId(String seq) throws IOException {
+       buffer.append("<span class=\"functionid\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleFunctionIdDecl(String seq) throws IOException {
+       buffer.append("<span class=\"functionid\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleId(String seq) throws IOException {
+       buffer.append("<span class=\"id\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleInputOutputArgs(String seq) throws IOException {
+       buffer.append("<span class=\"inputoutputargs\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleInputOutputArgsDecl(String seq) throws IOException {
+       buffer.append("<span class=\"inputoutputargs\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleNumber(String seq) throws IOException {
+       buffer.append("<span class=\"number\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleSpecial(String seq) throws IOException {
+       buffer.append("<span class=\"special\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleString(String seq) throws IOException {
+       buffer.append("<span class=\"string\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleNothing(String seq) throws IOException {
+       buffer.append(seq);
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleField(String seq) throws IOException {
+       buffer.append("<span class=\"field\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public void handleComment(String seq) throws IOException {
+       buffer.append("<span class=\"comment\">");
+       buffer.append(seq);
+       buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */  
+    public String toString() {
+       return buffer.toString();
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLWithStyleScilabCodeHandler.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLWithStyleScilabCodeHandler.java
new file mode 100644 (file)
index 0000000..de7b1ab
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.scilab;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+import java.util.Map;
+import java.util.Set;
+
+public class HTMLWithStyleScilabCodeHandler extends AbstractScilabCodeHandler {
+
+    public static final String OPENCLOSE = "<span style=\"font-style:normal;color:rgb(74,85,219)\">";
+    public static final String FIELD = "<span style=\"font-style:normal;color:rgb(170,170,170)\">";
+    public static final String FUNCTIONID = "<span style=\"font-weight:bold;color:rgb(0,0,0)\">";
+    public static final String INPUTOUTPUTARGS = "<span style=\"font-weight:bold;color:rgb(131,67,16)\">";
+    public static final String ID = "<span style=\"font-style:normal;color:rgb(0,0,0)\">";
+    public static final String STRING = "<span style=\"font-style:normal;color:rgb(188,143,143)\">";
+    public static final String MACRO = "<span style=\"font-style:normal;color:rgb(174,92,176)\">";
+    public static final String COMMAND = "<span style=\"font-style:normal;color:rgb(50,185,185)\">";
+    public static final String CKEYWORD = "<span style=\"font-style:normal;color:rgb(95,158,160)\">";
+    public static final String SKEYWORD = "<span style=\"font-style:normal;color:rgb(160,32,240)\">";
+    public static final String FKEYWORD = "<span style=\"font-style:normal;color:rgb(176,24,19)\">";
+    public static final String NUMBER = "<span style=\"font-style:normal;color:rgb(188,143,143)\">";
+    public static final String OPERATOR = "<span style=\"font-style:normal;color:rgb(92,92,92)\">";
+    public static final String CONSTANTS = "<span style=\"font-style:normal;color:rgb(218,112,214)\">";
+    public static final String SPECIAL = "<span style=\"font-style:normal;color:rgb(255,170,0)\">";
+    public static final String DEFAULT = "<span style=\"font-style:normal;color:rgb(0,0,0)\">";
+    public static final String COMMENT = "<span style=\"font-style:italic;color:rgb(1,168,1)\">";
+
+    private static final int BUFCAPACITY = 8192;
+
+    private Appendable buffer;
+    private ScilabLexer lexer;
+
+    /**
+     * Default constructor
+     * @param primFile the file containing the scilab primitives
+     * @param macroFile the file containing the scilab macros
+     **/
+    public HTMLWithStyleScilabCodeHandler(String primFile, String macroFile) {
+        this.lexer = new ScilabLexer(primFile, macroFile);
+    }
+
+    /**
+     * Default constructor
+     * @param primitives the set containing the scilab primitives
+     * @param macros the set containing the scilab macros
+     **/
+    public HTMLWithStyleScilabCodeHandler(Set primitives, Set macros) {
+        this.lexer = new ScilabLexer(primitives, macros);
+    }
+
+    /**
+     * @param scilabCode the code to convert
+     * @return a String containing the HTML
+     */
+    public void convert(Reader in, Writer out) throws IOException {
+        buffer = out;
+        buffer.append("<pre>\n");
+        String s = lexer.convert(this, in, false);
+        if (s == null) {
+            out.append("An error occured during the conversion");
+        }
+        buffer.append("\n</pre>\n");
+        out.flush();
+    }
+
+    /**
+     * @param scilabCode the code to convert
+     * @return a String containing the HTML
+     */
+    public String convert(String scilabCode) {
+        buffer = new StringBuilder(BUFCAPACITY);
+        ((StringBuilder) buffer).append("<pre>\n");
+        return lexer.convert(this, scilabCode) + "\n</pre>\n";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleDefault(String seq) throws IOException {
+        buffer.append(DEFAULT);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleOperator(String seq) throws IOException {
+        buffer.append(OPERATOR);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleOpenClose(String seq) throws IOException {
+        buffer.append(OPENCLOSE);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleFKeywords(String seq) throws IOException {
+        buffer.append(FKEYWORD);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleSKeywords(String seq) throws IOException {
+        buffer.append(SKEYWORD);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleCKeywords(String seq) throws IOException {
+        buffer.append(CKEYWORD);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleConstants(String seq) throws IOException {
+        buffer.append(CONSTANTS);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleCommand(String seq) throws IOException {
+        buffer.append(COMMAND);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleMacro(String seq) throws IOException {
+        buffer.append(MACRO);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleFunctionId(String seq) throws IOException {
+        buffer.append(FUNCTIONID);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleFunctionIdDecl(String seq) throws IOException {
+        buffer.append(FUNCTIONID);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleId(String seq) throws IOException {
+        buffer.append(ID);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleInputOutputArgs(String seq) throws IOException {
+        buffer.append(INPUTOUTPUTARGS);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleInputOutputArgsDecl(String seq) throws IOException {
+        buffer.append(INPUTOUTPUTARGS);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleNumber(String seq) throws IOException {
+        buffer.append(NUMBER);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleSpecial(String seq) throws IOException {
+        buffer.append(SPECIAL);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleString(String seq) throws IOException {
+        buffer.append(STRING);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleNothing(String seq) throws IOException {
+        buffer.append(seq);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleField(String seq) throws IOException {
+        buffer.append(FIELD);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleComment(String seq) throws IOException {
+        buffer.append(COMMENT);
+        buffer.append(seq);
+        buffer.append("</span>");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return buffer.toString();
+    }
+}
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/ScilabCodeServer.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/ScilabCodeServer.java
new file mode 100644 (file)
index 0000000..7330461
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc.scilab;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+/**
+ * Server to colorize Scilab code.
+ * The string passed to the server must be terminated with an EOF or a null char "\0".
+ */
+public final class ScilabCodeServer {
+
+    private static final int DEFAULTMAXHANDLERS = 5;
+
+    private Stack<HTMLWithStyleScilabCodeHandler> stack = new Stack();
+    private String prim;
+    private String macro;
+    private int maxHandler;
+
+    /**
+     * Main method
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+       Map<String, String> map = parseCommandLine(args);
+       if (map.containsKey("help")) {
+           System.out.println("Usage scicodeserver [OPTION]...");
+           System.out.println("Create a multi-thread server to colorize Scilab code");
+           System.out.println("");
+           System.out.println("-port          An integer giving the port where to listen to");
+           System.out.println("-sciprim       A file containing the list of the Scilab primitives");
+           System.out.println("-scimacro      A file containing the list of the Scilab macros");
+           System.out.println("-maxhandlers   An integer giving the maximum of Scilab code handlers");
+           System.out.println("               which must be kept in memory (5 by default)");
+           System.out.println("");
+           System.out.println("Report bugs on: <http://bugzilla.scilab.org>");
+           System.out.println("Project page: <http://forge.scilab.org/index.php/p/scidoc>");
+           return;
+       }
+
+       if (!map.containsKey("port")) {
+           System.err.println("No port");
+           System.err.println("Use the option -help");
+           return;
+       }
+
+       int max = DEFAULTMAXHANDLERS;
+       if (map.containsKey("maxhandlers")) {
+