htmlrexxprogram.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 --  HTML page output static classes
00042 --
00043 --  These could be recast as routines, but making them class methods keeps them
00044 --  out of the namespace
00045 --
00046  
00047   -- html components
00048 ::REQUIRES 'fsobjects.cls'
00049   -- html components
00050 ::REQUIRES 'nodes.cls'
00051   -- html utility
00052 ::REQUIRES 'htmlutil.cls'
00053   -- rexx class html 
00054 ::REQUIRES 'htmlrexxclass.cls'
00055  
00056 -- static class to emit html pages for a rexx program
00057 -- all methods are class methods
00058 ::CLASS htmlrexxprogram PUBLIC
00059  
00060  
00061 ::METHOD xref CLASS
00062  
00063  
00064 -- emit html pages for rexx program
00065 -- @param htmlout - .htmlout object
00066 -- @param folder - the folder of the file
00067 -- @param file - the file
00068 -- @param globalix - global index
00069 ::METHOD emit CLASS
00070   use arg htmlout, folder, file, globalix
00071  
00072   tp = .head_html~new~text
00073   tp~queue('<title>'file~filename'</title>')
00074   tp~queue(.nodes~prodssheet)
00075   tp~queue('<link rel="stylesheet" href="tabs.css">')
00076   -- head is complete
00077   tp~queue('</head>')
00078   tp~queue('<body>')
00079  
00080   -- set up menus
00081   .htmlutil~tabshead(tp, htmlout~topmenu, 'petprograms')
00082  
00083   menuq = .queue~new
00084   menuq~queue(.array~of('ooRexx', 'programs_oorexx.html', 'petoorexx'))
00085   menuq~queue(.array~of('rexx',   'programs_rexx.html',   'petrexx'))
00086   menuq~queue(.array~of('all',    'programs_all.html',    'petall' ))
00087   .htmlutil~tabshead(tp, menuq, 'petall')
00088  
00089  
00090   tp~queue('<h1>'file~document~relpath' File Reference</h2>')
00091   if file~document~isoo
00092     then type = .nodes~rsorex'OORexx'
00093     else type = .nodes~rscrex'Classic Rexx'
00094  
00095   tp~queue('<h3>'type'</h3>')
00096  
00097   tp~queue('<hr size="1"/>')
00098  
00099   -- note anyone requiring this file
00100   if file~document~reqrefs~items > 0
00101     then do
00102             tp~queue('<h2>Required by</h2>')
00103             do r over file~document~reqrefs
00104               tp~queue('<a href = "'r~rdatom~hdocurl'#'r~rdatom~hdocanchor'">'r~rdatom~document~filename'</a><br/>')
00105             end
00106          end
00107  
00108   if file~document~proclist~items > 0
00109     then self~featsumm(sortq(file~document~proclist), 'Procedures', tp)
00110  
00111  
00112   if file~document~procexpose~items > 0
00113     then do
00114             tp~queue('<h2>Exposed variables</h2>')
00115             do r over file~document~procexpose
00116               rq = file~document~procexpose[r]
00117               self~exposesumm(rq, r, tp)
00118 --              tp~queue('<a href = "'r~rdatom~hdocurl'#'r~rdatom~hdocanchor'">'r~rdatom~document~filename'</a><br/>')
00119             end
00120          end
00121  
00122  
00123  
00124  
00125   tp~queue('<h2>Detailed Description</h2>')
00126  
00127   blocko = htmlout~noprefix(file~document~getfirstblock)
00128   do i over blocko~text
00129     if i~words = 0
00130       then tp~queue('<br/>')
00131       else tp~queue(i)
00132   end
00133  
00134   tp~queue('<hr size="1"/>')
00135  
00136   features = file~document~featurelist
00137   nolabels = .false
00138   do i over features
00139     type = ''
00140     visib = ''
00141     parms = ''
00142     exposes = ''
00143     select
00144       when i~type = 'PROC'
00145         then do
00146                 parms = i~arglist
00147                 exposes = i~exposelist
00148              end
00149       when i~type = 'LABL'
00150         then do
00151                if nolabels
00152                  then iterate
00153              end
00154       when i~type = 'CLAS'
00155         then do
00156                -- emit page for class
00157                .htmlrexxclass~emit(htmlout, i)
00158                nolabels = .true
00159              end
00160       when i~type = 'METH'
00161         then do
00162                 iterate
00163              end
00164       when i~type = 'ATTR'
00165         then do
00166                 iterate
00167              end
00168       when i~type = 'ROUT'
00169         then do
00170                 parms = i~arglist
00171                 exposes = i~exposelist
00172              end
00173       when i~type = 'REQU'
00174         then do
00175                nop
00176              end
00177       when i~type = 'OPTS'
00178         then do
00179                nop
00180              end
00181       when i~type = 'CONS'
00182         then do
00183                nop
00184              end
00185       otherwise do
00186                   say 'unknown feature' i~type
00187                   exit
00188                 end
00189     end
00190  
00191    tp~queue('<p><a name="'i~hdocanchor'"></a></p>')
00192  
00193    tp~queue('<div class="memitem">')
00194    tp~queue('<div class="memproto">')
00195    tp~queue('<table class="memname"><tbody><tr><td class="memname">')
00196  
00197    if i~type = 'PROC' & i~rexxname = '--entry_proc'
00198      then src = 'Entry procedure'
00199      else do
00200              -- unavoidable filechunk here? could make function in hrdocument
00201              clause = i~document~featureclause(i~feature)
00202              src = ''
00203              clauseq = i~document~getsource(clause)
00204              do c over clauseq
00205                if c~right(1) = ','
00206                  then c = c~left(c~length-1)
00207                src = src c
00208              end
00209           end
00210  
00211    if i~type = 'REQU'
00212      then do
00213             f = globalix~filix[i~rexxname]
00214             parse var src w1 w2 w3
00215             if f <> .nil
00216               then do
00217                      src = w1 '<a href="'f~document~hdocurl'">'w2'</a>' w3
00218                    end
00219           end
00220  
00221    if i~type = 'CLAS'
00222      then do
00223              parse var src w1 w2 rest
00224              -- rdc is set up above
00225              tp~queue(i~smallicon'<span class="keywordflow">'w1 '<a class="el" href="'i~hdocurl'#'i~hdocanchor'">'w2'</a>' rest)
00226           end
00227      else tp~queue(i~smallicon src)
00228    tp~queue('</td></tr></tbody></table>')
00229    tp~queue('</div>')
00230  
00231    tp~queue('<div class="memdoc">')
00232    tp~queue('<p>')
00233    -- get any block documents
00234    blocko = htmlout~noprefix(file~document~getprevblock(i~feature))
00235    do b over blocko~text
00236      tp~queue(b'<br/>')
00237    end
00238  
00239    .htmlutil~callableexpand(htmlout, i, blocko, tp)
00240  
00241    tp~queue('<span class="paramname">Definition at line</span>')
00242    tp~queue('<a class="el" href="'file~document~hsrcurl'#'i~hsrcanchor'">'i~startline'</a> of')
00243    tp~queue('<a class="el" href="'file~document~hsrcurl'">'file~filename'</a><br/>')
00244  
00245    tp~queue('</p>')
00246    tp~queue('</div>')
00247    tp~queue('</div>')
00248  
00249   end
00250  
00251   -- insert trailer
00252   .htmlutil~trailer(htmlout, tp)
00253   -- all done
00254   tp~queue('</body></html>')
00255  
00256   -- write page
00257   towrite = htmlout~hdest||file~document~hdocurl
00258   .htmlutil~writepage(tp, towrite)
00259  
00260 -- produce titled summary table of exposing methods
00261 -- @param rdfeatures - queue of rdfeature
00262 -- @param exposedvar - name of exposed variable
00263 -- @param tp - queue to receive output
00264 ::METHOD exposesumm CLASS PRIVATE
00265   use arg rdfeatures, exposedvar, tp
00266  
00267   if rdfeatures~items < 1
00268     then return
00269  
00270   tp~queue('<table cellspacing="0" cellpadding="0" border="0">')
00271   tp~queue('<tbody>')
00272   tp~queue('<tr>')
00273   tp~queue('<td colspan="2">')
00274   tp~queue('<span class="paramkey">'exposedvar'</span> <span class="paramname">exposed by</span>')
00275   tp~queue('</td>')
00276   tp~queue('</tr>')
00277  
00278   do m over rdfeatures
00279  
00280     bc = m~document~getanycomment(m~feature)
00281     if bc~text~items > 0
00282       then oneliner = .classfinder~classnames(m~document, bc~text[1])
00283       else oneliner = 'no comment'
00284  
00285     returns = '&nbsp;'
00286  
00287     tp~queue('<tr>')
00288     tp~queue('<td class="memItemLeft" valign="top" nowrap="" align="right">')
00289     tp~queue(returns)
00290     tp~queue('</td>')
00291     tp~queue('<td class="memItemRight" valign="bottom">')
00292     tp~queue('<a class="e1" href="'m~hdocurl'#'m~hdocanchor'">'m~rexxname'</a>')
00293     if m~type = 'METH'
00294       then tp~queue('('self~commad(m~arglist)')')
00295       else tp~queue(' ')
00296     tp~queue('</td>')
00297     tp~queue('</tr>')
00298  
00299     tp~queue('<tr>')
00300     tp~queue('<td class="mdescLeft"/>')
00301     tp~queue('<td class="mdescRight">')
00302     tp~queue(oneliner)
00303     tp~queue('</td>')
00304     tp~queue('</tr>')
00305   end
00306  
00307   tp~queue('</tbody>')
00308   tp~queue('</table>')
00309  
00310 ::METHOD commad CLASS PRIVATE
00311  
00312   use arg args
00313  
00314   if args~words < 2
00315     then return args
00316  
00317   coms = ''
00318   do j = 1 to words(args)
00319     arg = args~word(j)
00320     if j <> words(args)
00321       then arg = arg','
00322     coms = coms arg
00323   end
00324   return coms~strip
00325  
00326 -- produce titled summary table of features
00327 -- @param rdfeatures - queue of rdfeature
00328 -- @param title - table title
00329 -- @param tp - queue to receive output
00330 ::METHOD featsumm CLASS PRIVATE
00331   use arg rdfeatures, title, tp
00332  
00333   if rdfeatures~items < 1
00334     then return
00335  
00336   tp~queue('<table cellspacing="0" cellpadding="0" border="0">')
00337   tp~queue('<tbody>')
00338   tp~queue('<tr>')
00339   tp~queue('</td>')
00340   tp~queue('</tr>')
00341  
00342   tp~queue('<tr>')
00343   tp~queue('<td colspan="2">')
00344   tp~queue('<br/><h2>'title'</h2>')
00345   tp~queue('</td>')
00346   tp~queue('</tr>')
00347  
00348   do m over rdfeatures
00349  
00350     bc = m~document~getanycomment(m~feature)
00351     if bc~text~items > 0
00352       then oneliner = .classfinder~classnames(m~document, bc~text[1])
00353       else oneliner = 'no comment'
00354  
00355     if bc~returns~items > 0
00356       then returns = bc~returns[1]
00357       else returns = '&nbsp;'
00358  
00359     tp~queue('<tr>')
00360     tp~queue('<td class="memItemLeft" valign="top" nowrap="" align="right">')
00361     tp~queue(returns)
00362     tp~queue('</td>')
00363     tp~queue('<td class="memItemRight" valign="bottom">')
00364     tp~queue('<a class="e1" href="'m~hdocurl'#'m~hdocanchor'">'m~rexxname'</a>')
00365     if m~type = 'PROC'
00366       then tp~queue('('self~commad(m~arglist)')')
00367       else tp~queue(' ')
00368     tp~queue('</td>')
00369     tp~queue('</tr>')
00370  
00371     tp~queue('<tr>')
00372     tp~queue('<td class="mdescLeft"/>')
00373     tp~queue('<td class="mdescRight">')
00374     tp~queue(oneliner)
00375     tp~queue('</td>')
00376     tp~queue('</tr>')
00377   end
00378  
00379   tp~queue('</tbody>')
00380   tp~queue('</table>')
00381  

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