htmlout.cls source

00001 /*----------------------------------------------------------------------------*/
00002 /*                                                                            */
00003 /*   Copyright (c) 2004-2009 William  Data  Systems Ltd. and Geoff Stevens.   */
00004 /*   All rights reserved.                                                     */
00005 /*                                                                            */
00006 /*   This program and the  accompanying  materials are made available under   */
00007 /*   the terms of the  Common  Public  License  v1.0 which accompanies this   */
00008 /*   distribution. A  copy  is  also  available  at  the following address:   */
00009 /*   http://www.opensource.org/licenses/cpl1.0.php                            */
00010 /*                                                                            */
00011 /*   Redistribution and use in  source  and  binary  forms, with or without   */
00012 /*   modification, are  permitted  provided  that  the following conditions   */
00013 /*   are met:                                                                 */
00014 /*                                                                            */
00015 /*   Redistributions  of  source  code  must  retain  the  above  copyright   */
00016 /*   notice, this list of conditions and the following disclaimer.            */
00017 /*                                                                            */
00018 /*   Redistributions in  binary  form  must  reproduce  the above copyright   */
00019 /*   notice, this list of  conditions  and  the following disclaimer in the   */
00020 /*   documentation and/or other materials provided with the distribution.     */
00021 /*                                                                            */
00022 /*   Neither the name or trademarks  of  William Data Systems nor the names   */
00023 /*   of its  contributors  may  be  used  to  endorse  or  promote products   */
00024 /*   derived from this software without specific prior written permission.    */
00025 /*                                                                            */
00026 /*   DISCLAIMER                                                               */
00027 /*                                                                            */
00028 /*   THIS SOFTWARE IS PROVIDED  BY  THE  COPYRIGHT HOLDERS AND CONTRIBUTORS   */
00029 /*   "AS IS" AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT   */
00030 /*   LIMITED TO, THE IMPLIED WARRANTIES  OF MERCHANTABILITY AND FITNESS FOR   */
00031 /*   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT   */
00032 /*   OWNER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL,   */
00033 /*   SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL  DAMAGES  (INCLUDING,  BUT NOT   */
00034 /*   LIMITED TO, PROCUREMENT OF SUBSTITUTE  GOODS OR SERVICES; LOSS OF USE,   */
00035 /*   DATA, OR PROFITS; OR BUSINESS  INTERRUPTION) HOWEVER CAUSED AND ON ANY   */
00036 /*   THEORY OF LIABILITY, WHETHER  IN  CONTRACT,  STRICT LIABILITY, OR TORT   */
00037 /*   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN  ANY WAY OUT OF THE USE   */
00038 /*   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
00039 /*                                                                            */
00040 /*----------------------------------------------------------------------------*/
00041 --  convert parsed rexx to HTML pages
00042 --
00043 --
00044  
00045 -- for all the boilerplate
00046 ::REQUIRES 'fsobjects.cls'
00047  
00048 -- files, folders, rexx and text documents
00049 ::REQUIRES 'documents.cls'
00050  
00051 -- html images to build the tree view
00052 ::REQUIRES 'nodes.cls'
00053  
00054 -- html page builders
00055 ::REQUIRES 'htmlrexxprogram.cls'
00056 ::REQUIRES 'htmlrexxclass.cls'
00057 ::REQUIRES 'htmlrexxsource.cls'
00058 ::REQUIRES 'htmltext.cls'
00059  
00060 -- build tree html
00061  
00062 -- render a series of parsed rexx documents as HTML
00063 -- this class exists to aggregate the knowledge of the html renderers
00064 ::CLASS htmlout PUBLIC
00065 ::ATTRIBUTE hdest  --
00066 ::ATTRIBUTE pversion  -- 
00067 ::ATTRIBUTE title  -- name of report
00068 ::ATTRIBUTE prefixcomment -- remove from comment prefix
00069 ::ATTRIBUTE trailericon -- tag to add to to left of trailer pages
00070 ::ATTRIBUTE topmenu  -- top menu structure
00071 ::ATTRIBUTE rexxliterate -- owner rexxliterate
00072 ::ATTRIBUTE pwrongdoc   -- queue of messages describing parameter docs not matching code
00073 ::ATTRIBUTE pmissingdoc -- queue of messages describing parameters with no  docs
00074  
00075 -- 
00076 --
00077 ::METHOD init
00078   use strict arg rexxliterate, hdest, pversion, title, prefixcomment, trailericon
00079  
00080   self~rexxliterate = rexxliterate
00081   self~hdest = hdest
00082   self~pversion = pversion
00083   self~title = title
00084   self~prefixcomment = prefixcomment
00085   self~trailericon = trailericon
00086   self~topmenu = .queue~new
00087  
00088   self~pmissingdoc = .queue~new
00089   self~pwrongdoc = .queue~new
00090  
00091   self~topmenu~queue(.array~of('main',       'main.html',       'petmain'))
00092   if rexxliterate~modules~items > 0
00093     then self~topmenu~queue(.array~of('documents',    'documents.html',    'petdocuments'))
00094   self~topmenu~queue(.array~of('programs',   'programs.html',   'petprograms'))
00095   self~topmenu~queue(.array~of('classes',    'classes.html',    'petclasses'))
00096   self~topmenu~queue(.array~of('methods',    'methods.html',    'petmethods'))
00097   self~topmenu~queue(.array~of('attributes', 'attributes.html', 'petattributes'))
00098   self~topmenu~queue(.array~of('procedures', 'procedures.html', 'petprocedures'))
00099   self~topmenu~queue(.array~of('routines',   'routines.html',   'petroutines'))
00100   self~topmenu~queue(.array~of('constants',  'constants.html',  'petconstant'))
00101   self~topmenu~queue(.array~of('options',    'options.html',    'petoptions'))
00102   self~topmenu~queue(.array~of('text',       'text.html',       'pettext'))
00103   self~topmenu~queue(.array~of('files',      'files.html',      'petfiles'))
00104  
00105 ::METHOD modules
00106   use arg modules
00107  
00108   mh = .head_html~new~text
00109   mh~queue('<title>'self~title 'Documents</title>')
00110  
00111   mh~queue(.nodes~prodssheet)
00112   mh~queue('<link rel="stylesheet" href="tabs.css">')
00113   mh~queue('</head>')
00114   self~tabshead(mh, self~topmenu, 'petdocuments')
00115   mh~queue('<hr size="1"/>')
00116   mh~queue('<h1>'self~title' Documents</h1>')
00117   mh~queue('Here is a list of document sections')
00118   mh~queue('<ul>')
00119   do i over modules
00120     o = modules[i]
00121     mh~queue('<li><a class="el" href="MOD_'o~modname'.html">'o~modname'</a>'o~description'</li>')
00122     -- write the page
00123     self~modpage(o)
00124   end
00125   mh~queue('</ul>')
00126  
00127   .htmlutil~trailer(self, mh)
00128   -- write modules page
00129   towrite = self~hdest||'documents.html'
00130   .htmlutil~writepage(mh, towrite)
00131  
00132 ::METHOD modpage
00133   use arg module
00134  
00135   mh = .head_html~new~text
00136   mh~queue('<title>'module~modname'</title>')
00137  
00138   mh~queue(.nodes~prodssheet)
00139   mh~queue('<link rel="stylesheet" href="tabs.css">')
00140   mh~queue('</head>')
00141   self~tabshead(mh, self~topmenu, 'petdocuments')
00142   mh~queue('<hr size="1"/>')
00143   mh~queue('<h1>'module~modname module~description'</h1>')
00144   do i over module~text
00145     mh~queue(self~repcode(i))
00146   end
00147   .htmlutil~trailer(self, mh)
00148   -- write modules page
00149   towrite = self~hdest||'MOD_'module~modname'.html'
00150   .htmlutil~writepage(mh, towrite)
00151  
00152 ::METHOD repcode PRIVATE
00153   parse arg text
00154  
00155   text = text~changestr('@code', '<pre class="fragment">')
00156   text = text~changestr('@endcode', '</pre>')
00157  
00158   return text
00159  
00160  
00161 ::METHOD firstpage
00162   use arg docs, treeframe
00163  
00164   -- prepare main.html, or index.html if no tree
00165   mh = .head_html~new~text
00166   mh~queue('<title>'self~title'</title>')
00167   mh~queue(.nodes~prodssheet)
00168   mh~queue('<link rel="stylesheet" href="tabs.css">')
00169   mh~queue('</head>')
00170   self~tabshead(mh, self~topmenu, 'petmain')
00171   mh~queue('<hr size="1"/>')
00172   mh~queue('<h1>'self~title'</h1>')
00173   do i over docs
00174     mh~queue(i)
00175   end
00176   .htmlutil~trailer(self, mh)
00177  
00178   -- build in one of two ways, depending on treeframe spec
00179   if treeframe
00180    then do
00181           say 'building tree'
00182           -- build the frameset as index.html
00183           fs = .head_html~new~text
00184           fs~queue('<title>'self~title'</title>')
00185           fs~queue('</head>')
00186           do i over .frameset_html~new~text
00187             fs~queue(i)
00188           end
00189           fs~queue('</html>')
00190           rc = SysFileDelete(self~hdest'index.html')
00191           s = .stream~new(self~hdest'index.html')
00192           rc = s~arrayout(fs)
00193           s~close
00194  
00195           -- write main page
00196           towrite = self~hdest||'main.html'
00197           .htmlutil~writepage(mh, towrite)
00198  
00199         end
00200    else do
00201           -- write main page as index.html
00202           towrite = self~hdest||'index.html'
00203           .htmlutil~writepage(mh, towrite)
00204         end
00205  
00206 -- emit html pages for rexx program
00207 -- @param folder - the folder object for the rexx program
00208 -- @param file - the file object for the rexx program
00209 -- @param globalix - global index
00210 ::METHOD rhtmlpage
00211   use arg folder, file, globalix
00212   -- emit summary page
00213   .htmlrexxprogram~emit(self, folder, file, globalix)
00214   -- emit source page
00215   .htmlrexxsource~emit(self, file, globalix)
00216  
00217 -- emit html page for text file
00218 -- @param folder - the folder object for the text file
00219 -- @param file - the file object for the text file
00220 ::METHOD thtmlpage
00221   use arg folder, file
00222   -- emit text page
00223   .htmltext~emit(self, folder, file)
00224  
00225 -- remove prefix from block comment
00226 -- @param bc - a block comment
00227 -- @return block comment with prefix removed
00228 ::METHOD noprefix
00229   use strict arg bc
00230   if self~prefixcomment = .nil
00231     then return bc
00232  
00233   do j = 1 to bc~text~items
00234     if bc~text[j] <> self~prefixcomment[j]
00235       then leave
00236   end
00237  
00238   if j = 1
00239     then return bc
00240  
00241   ntext = .queue~new
00242   ntext~queue('prefix comment removed<br>')
00243   do j = j to bc~text~items
00244     ntext~queue(bc~text[j])
00245   end
00246   bc~text = ntext
00247  
00248   return bc
00249  
00250 -- add a tabs header to a queue
00251 -- @param outq - the queue to which to add tabs
00252 -- @param tablist - queue of three-element queues
00253 --                element 1 : display name of tab
00254 --                element 2 : url to associate with tab
00255 --                element 3 : selector name
00256 -- @param selector - tab selector to set active
00257 ::METHOD tabshead
00258   use strict arg outq, tablist, selector
00259  
00260   outq~queue('<div class="tabs">')
00261     outq~queue('<ul>')
00262  
00263   do i over tablist
00264     if i[3] = selector
00265       then outq~queue('<li class="current">')
00266       else outq~queue('<li>')
00267     outq~queue('<a href="'i[2]'">')
00268     outq~queue('<span>'i[1]'</span>')
00269     outq~queue('</a>')
00270   end
00271  
00272   outq~queue('</ul>')
00273   outq~queue('</div>')
00274  

Get RexxLiterate at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated on 31 Aug 2010 05:20:25 for RexxLiterate by rexxliterate  0.0.1