htmlrexxclass.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  
00054 -- static class to emit html page for a rexx class
00055 -- all methods are class methods
00056 ::CLASS htmlrexxclass PUBLIC
00057 ::ATTRIBUTE htmlout CLASS
00058  
00059 -- emit html page for rexx class
00060 -- @param htmlout - .htmlout object
00061 -- @param rdc - the rdclass object for the class
00062 ::METHOD emit CLASS
00063   use arg htmlout, rdc
00064   self~htmlout = htmlout
00065  
00066   tp = .head_html~new~text
00067   tp~queue('<title>'rdc~rexxname'</title>')
00068   tp~queue(.nodes~prodssheet)
00069   tp~queue('<link rel="stylesheet" href="tabs.css">')
00070   -- head is complete
00071   tp~queue('</head>')
00072   tp~queue('<body>')
00073  
00074   -- set up menus
00075   .htmlutil~tabshead(tp, htmlout~topmenu, 'petclasses')
00076  
00077   clause = rdc~document~featureclause(rdc~feature)
00078   src = rdc~document~getsource(clause)[1]
00079  
00080   tp~queue('<h2><span class="keywordflow">'rdc~smallicon||self~dirxref(rdc, src)'</span></h2>')
00081  
00082   blocko = self~htmlout~noprefix(rdc~document~getprevblock(rdc~feature))
00083   do i over blocko~text
00084     tp~queue(.classfinder~classnames(rdc~document, i)'<br/>')
00085   end
00086  
00087   if rdc~document~requires~items > 0
00088     then do
00089            tp~queue('<h3>Requires</h3>')
00090            do i over rdc~document~requires
00091              comq = rdc~document~getanycomment(i)
00092              comment = ''
00093              if comq~text~items > 0
00094                then comment = .classfinder~classnames(rdc~document, comq~text[1])
00095  
00096              tp~queue(i~rname comment'<br/>')
00097            end
00098          end
00099  
00100   tp~queue('<span class="paramname">Definition at line ')
00101   tp~queue('<a class="el" href="'rdc~document~hsrcurl'#'rdc~hsrcanchor'">'rdc~startline'</a> of')
00102   tp~queue('<a class="el" href="'rdc~document~hsrcurl'">'rdc~document~relpath'</a></span><br/>')
00103  
00104   -- produce summaries
00105   -- local features
00106   self~featsumms(rdc, '', tp)
00107  
00108   -- inherited features
00109   self~getinheritance(rdc, tp)
00110  
00111   if rdc~exposedvars~items > 0
00112     then do
00113            tp~queue('<h3>Exposed variables</h3>')
00114            do r over rdc~exposedvars
00115              mq = rdc~exposedvars[r]
00116              self~exposesumm(mq, rdc, r, tp)
00117            end
00118          end
00119  
00120   if rdc~instrefs~items > 0
00121     then do
00122            tp~queue('<h3>Instantiated by</h3>')
00123            do r over rdc~instrefs
00124              tp~queue('<a href = "'r~rdatom~document~hsrcurl'#'r~rdatom~hsrcanchor'">',
00125                        r~rdatom~document~filename'</a> line' r~rdatom~feature~startline'<br/>')
00126            end
00127          end
00128  
00129   if rdc~subclassedby~items > 0
00130     then do
00131            tp~queue('<h3>Subclassed by</h3>')
00132            do r over rdc~subclassedby
00133              tp~queue('<a href="'r~hdocurl'">'r~feature~rname'</a> <br/>')
00134            end
00135          end
00136  
00137   if rdc~inheritedby~items > 0
00138     then do
00139            tp~queue('<h3>Inherited by</h3>')
00140            do r over rdc~inheritedby
00141              tp~queue('<a href="'r~hdocurl'">'r~feature~rname'</a> <br/>')
00142            end
00143          end
00144  
00145   if rdc~mixedinby~items > 0
00146     then do
00147            tp~queue('<h3>Mixed in by</h3>')
00148            do r over rdc~mixedinby
00149              tp~queue('<a href="'r~hdocurl'">'r~feature~rname'</a> <br/>')
00150            end
00151          end
00152  
00153   tp~queue('<h3>Feature Detail</h3>')
00154  
00155   do m over rdc~methods
00156  
00157     if m~type = 'LABL'
00158       then iterate
00159  
00160     clause = m~document~featureclause(m~feature)
00161     src = m~document~getsource(clause)[1]
00162  
00163     tp~queue('<p><a name='m~hdocanchor'></a></p>')
00164     tp~queue('<div class="memitem">')
00165     tp~queue('<div class="memproto">')
00166     tp~queue('<table class="memname"><tbody><tr><td class="memname">')
00167     tp~queue('<span class="keywordflow">'m~smallicon src'</span>')
00168     tp~queue('</td></tr></tbody></table>')
00169     tp~queue('</div>')
00170  
00171     bc = rdc~document~getanycomment(m~feature)
00172     do t over bc~text
00173       tp~queue(.classfinder~classnames(m~document, t)'</br>')
00174     end
00175  
00176     if m~type = 'METH'
00177       then do
00178              -- expanded method docs
00179              .htmlutil~callableexpand(self~htmlout, m, bc, tp)
00180            end
00181  
00182     tp~queue('<div class="paramname">Definition at line')
00183     tp~queue('<a class="el" href="'rdc~document~hsrcurl'#'m~hsrcanchor'">'m~startline'</a> of')
00184     tp~queue('<a class="el" href="'rdc~document~hsrcurl'">'rdc~document~relpath'</a></div>')
00185  
00186     if m~type = 'METH' | m~type = 'ATTR'
00187       then do
00188              -- expanded reference docs
00189              .htmlutil~referrableexpand(self~htmlout, m, tp)
00190            end
00191  
00192     tp~queue('</div>')
00193   end
00194  
00195   .htmlutil~trailer(self~htmlout, tp)
00196   tp~queue('</body></html>')
00197  
00198   -- write page as html
00199   towrite = self~htmlout~hdest||rdc~hdocurl
00200   .htmlutil~writepage(tp, towrite)
00201  
00202 -- cross reference CLASS directive
00203 ::METHOD dirxref CLASS PRIVATE
00204   use arg rdc, src
00205  
00206   newsrc = ''
00207  
00208   checkwords = .false
00209   do j = 1 to words(src)
00210     w = src~word(j)
00211     wt = w~translate
00212     select
00213       when wt = 'METACLASS' | wt = 'MIXINCLASS' | wt = 'SUBCLASS'
00214         then do
00215                newsrc = newsrc w
00216                j = j + 1
00217                w = src~word(j)
00218                xrdc = .classfinder~findclass(w~translate, rdc~document, rdc~document~reqfiles)
00219                if xrdc <> .nil
00220                  then do
00221                         newsrc = newsrc '<a href="'xrdc~hdocurl'">'w'</a>'
00222                       end
00223                  else newsrc = newsrc w
00224              end
00225  
00226       when w~translate = 'INHERIT'
00227         then do
00228                newsrc = newsrc w
00229                -- all further words might be class names
00230                checkwords = .true
00231              end
00232  
00233       when checkwords
00234         then do
00235                xrdc = .classfinder~findclass(w~translate, rdc~document, rdc~document~reqfiles)
00236                if xrdc <> .nil
00237                  then do
00238                         newsrc = newsrc '<a href="'xrdc~hdocurl'">'w'</a>'
00239                       end
00240                  else newsrc = newsrc w
00241              end
00242  
00243       otherwise newsrc = newsrc w
00244     end
00245   end
00246  
00247   return newsrc
00248  
00249 -- recursively produce summaries for all inherited features
00250 -- @param rdc - rdclass for which to produce summaries
00251 -- @param tp - queue to which to add summaries
00252 ::method getinheritance class private
00253   use arg rdc, tp
00254   if rdc~subclass <> ''
00255     then do
00256            self~getsuper(rdc~subclass, tp)
00257          end
00258  
00259   if rdc~mixinclass <> ''
00260     then do
00261            self~getsuper(rdc~mixinclass, tp)
00262          end
00263  
00264   mixins = rdc~inherit~space(1)~makearray(' ')
00265   do m over mixins
00266     self~getmixins(m, tp)
00267   end
00268  
00269 -- report on inherited methods, recurse up inheritance tree
00270 -- @param supername - name of superclass
00271 -- @param tp - queue to which to add summaries
00272 ::METHOD getsuper CLASS PRIVATE
00273   use arg supername, tp
00274  
00275   rdc = self~htmlout~rexxliterate~globalix~classix~at(supername~translate)
00276   if rdc = .nil
00277     then do
00278            return
00279          end
00280  
00281   classdoc = 'inherited from <a class="el" href="'rdc~hdocurl'">'rdc~rexxname'</a>'
00282   self~featsumms(rdc, classdoc, tp)
00283  
00284   self~getinheritance(rdc, tp)
00285  
00286   return
00287  
00288 -- report on mixed-in methods, recurse up inheritance tree
00289 -- @param mixname - name of mixin class
00290 -- @param tp - queue to which to add summaries
00291 ::METHOD getmixins CLASS PRIVATE
00292   use arg mixname, tp
00293  
00294   rdc = self~htmlout~rexxliterate~globalix~classix~at(mixname~translate)
00295   if rdc = .nil
00296     then do
00297            return
00298          end
00299  
00300   classdoc = 'mixed in from <a class="el" href="'rdc~hdocurl'">'rdc~rexxname'</a>'
00301   self~featsumms(rdc, classdoc, tp)
00302  
00303   self~getinheritance(rdc, tp)
00304  
00305   return
00306  
00307 -- produce feature summaries for an rdclass
00308 -- @param rdc - the rdclass for which to produce summaries
00309 -- @param tag - additional string for summary title
00310 -- @param tp - queue to which to add summaries
00311 ::METHOD featsumms CLASS PRIVATE
00312   use arg rdc, tag, tp
00313  
00314   self~featsumm(sortq(rdc~cpubmethods), rdc, 'Public Class Methods' tag, tp)
00315   self~featsumm(sortq(rdc~cpubattribs), rdc, 'Public Class Attributes' tag, tp)
00316   self~featsumm(sortq(rdc~pubmethods), rdc, 'Public Methods' tag, tp)
00317   self~featsumm(sortq(rdc~pubattribs), rdc, 'Public Attributes' tag, tp)
00318  
00319   self~featsumm(sortq(rdc~cprimethods), rdc, 'Private Class Methods' tag, tp)
00320   self~featsumm(sortq(rdc~cpriattribs), rdc, 'Private Class Attributes' tag, tp)
00321   self~featsumm(sortq(rdc~primethods), rdc, 'Private Methods' tag, tp)
00322   self~featsumm(sortq(rdc~priattribs), rdc, 'Private Attributes' tag, tp)
00323  
00324 -- produce titled summary table of features
00325 -- @param rdfeatures - queue of rdfeature
00326 -- @param rdc - rdclass object owning method
00327 -- @param title - table title
00328 -- @param tp - queue to receive output
00329 ::METHOD featsumm CLASS PRIVATE
00330   use arg rdfeatures, rdc, title, tp
00331  
00332   if rdfeatures~items < 1
00333     then return
00334  
00335   tp~queue('<table cellspacing="0" cellpadding="0" border="0">')
00336   tp~queue('<tbody>')
00337   tp~queue('<tr>')
00338   tp~queue('</td>')
00339   tp~queue('</tr>')
00340  
00341   tp~queue('<tr>')
00342   tp~queue('<td colspan="2">')
00343   tp~queue('<br/><h3>'title'</h3>')
00344   tp~queue('</td>')
00345   tp~queue('</tr>')
00346  
00347   do m over rdfeatures
00348  
00349     bc = rdc~document~getanycomment(m~feature)
00350     if bc~text~items > 0
00351       then oneliner = .classfinder~classnames(m~document, bc~text[1])
00352       else oneliner = 'no comment'
00353  
00354     if bc~returns~items > 0
00355       then returns = bc~returns[1]
00356       else returns = '&nbsp;'
00357  
00358     tp~queue('<tr>')
00359     tp~queue('<td class="memItemLeft" valign="top" nowrap="" align="right">')
00360     tp~queue(returns)
00361     tp~queue('</td>')
00362     tp~queue('<td class="memItemRight" valign="bottom">')
00363     tp~queue('<a class="e1" href="'rdc~hdocurl'#'m~hdocanchor'">'m~rexxname'</a>')
00364     if m~type = 'METH'
00365       then tp~queue('('self~commad(m~arglist)')')
00366       else tp~queue(' ')
00367     tp~queue('</td>')
00368     tp~queue('</tr>')
00369  
00370     tp~queue('<tr>')
00371     tp~queue('<td class="mdescLeft"/>')
00372     tp~queue('<td class="mdescRight">')
00373     tp~queue(oneliner)
00374     tp~queue('</td>')
00375     tp~queue('</tr>')
00376   end
00377  
00378   tp~queue('</tbody>')
00379   tp~queue('</table>')
00380  
00381 -- produce titled summary table of exposing methods
00382 -- @param rdfeatures - queue of rdfeature
00383 -- @param rdc - rdclass object owning method
00384 -- @param exposedvar - name of exposed variable
00385 -- @param tp - queue to receive output
00386 ::METHOD exposesumm CLASS PRIVATE
00387   use arg rdfeatures, rdc, exposedvar, tp
00388  
00389   if rdfeatures~items < 1
00390     then return
00391  
00392   tp~queue('<table cellspacing="0" cellpadding="0" border="0">')
00393   tp~queue('<tbody>')
00394   tp~queue('<tr>')
00395   tp~queue('<td colspan="2">')
00396   tp~queue('<span class="paramkey">'exposedvar'</span> <span class="paramname">exposed by</span>')
00397   tp~queue('</td>')
00398   tp~queue('</tr>')
00399  
00400   do m over rdfeatures
00401  
00402     bc = rdc~document~getanycomment(m~feature)
00403     if bc~text~items > 0
00404       then oneliner = .classfinder~classnames(m~document, bc~text[1])
00405       else oneliner = 'no comment'
00406  
00407     returns = '&nbsp;'
00408  
00409     tp~queue('<tr>')
00410     tp~queue('<td class="memItemLeft" valign="top" nowrap="" align="right">')
00411     tp~queue(returns)
00412     tp~queue('</td>')
00413     tp~queue('<td class="memItemRight" valign="bottom">')
00414     tp~queue('<a class="e1" href="'rdc~hdocurl'#'m~hdocanchor'">'m~rexxname'</a>')
00415     if m~type = 'METH'
00416       then tp~queue('('self~commad(m~arglist)')')
00417       else tp~queue(' ')
00418     tp~queue('</td>')
00419     tp~queue('</tr>')
00420  
00421     tp~queue('<tr>')
00422     tp~queue('<td class="mdescLeft"/>')
00423     tp~queue('<td class="mdescRight">')
00424     tp~queue(oneliner)
00425     tp~queue('</td>')
00426     tp~queue('</tr>')
00427   end
00428  
00429   tp~queue('</tbody>')
00430   tp~queue('</table>')
00431  
00432 ::METHOD commad CLASS PRIVATE
00433  
00434   use arg args
00435  
00436   if args~words < 2
00437     then return args
00438  
00439   coms = ''
00440   do j = 1 to words(args)
00441     arg = args~word(j)
00442     if j <> words(args)
00443       then arg = arg','
00444     coms = coms arg
00445   end
00446   return coms~strip

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