From: <ant...@us...> - 2008-02-21 22:42:15
|
Revision: 2375 http://oorexx.svn.sourceforge.net/oorexx/?rev=2375&view=rev Author: antiguru Date: 2008-02-21 14:42:13 -0800 (Thu, 21 Feb 2008) Log Message: ----------- General updates, some bug fixes, layout changes (looks much better now). Modified Paths: -------------- incubator/rexxdoc/frontend.rex incubator/rexxdoc/rexxdoc.cls incubator/rexxdoc/style.css Modified: incubator/rexxdoc/frontend.rex =================================================================== --- incubator/rexxdoc/frontend.rex 2008-02-21 22:11:53 UTC (rev 2374) +++ incubator/rexxdoc/frontend.rex 2008-02-21 22:42:13 UTC (rev 2375) @@ -46,13 +46,15 @@ use strict arg file parser = .FileParser~new(file) -parser~parse +parser~parse(.stream~new(file)~arrayIn) + + out = .stdout -- write to a file out = .stream~new("doc.html")~~command("open replace") -- write some header -out~say('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">') +out~say('<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">') out~say('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>') -- the title is the root file name out~say(parser~tree~name) @@ -75,14 +77,16 @@ ::REQUIRES "rexxdoc.cls" ::ROUTINE getMethodDetails - use arg method - mb = .mutableBuffer~new - if method~isAttribute then mb~append("Attribute ") + use strict arg method, mb = (.mutableBuffer~new) + if method~isInstanceOf(.SourceMethod) , , + method~isAttribute then mb~append("Attribute ") if method~isUnguarded then mb~append("Unguarded ") if method~isClassMethod then mb~append("Class ") if method~isPrivate then mb~append("Private ") if method~isProtected then mb~append("Protected ") - if method~isAbstract then mb~append("Abstract ") + if method~isInstanceOf(.SourceMethod) , , + method~isAbstract then mb~append("Abstract ") + if mb~length = 0 then mb~append("(default)") return mb~string @@ -91,9 +95,8 @@ * Line breakes are replaced by <br/> */ ::ROUTINE doc2string - use arg doc + use strict arg doc, accu = (.MutableBuffer~new) if doc~class \= .string then do - accu = .MutableBuffer~new lines = doc~makearray do i = 1 to lines~items d = lines[i] @@ -101,9 +104,11 @@ else accu~append(" "d) end if accu~length > 0 then accu~append('<br/>') - return accu~string end - else return doc'<br/>' + else do + accu~append(doc'<br/>') + end + return accu~string ::ROUTINE replaceSpecials use arg string @@ -111,6 +116,18 @@ string = string~changestr("<","<") string = string~changestr(">",">") return string + +::ROUTINE printCode + use strict arg source, mb = (.MutableBUffer~new) + mb~append('<pre class="rxsource">'||.EndOfLine) + do s over source + if s = "" then iterate + mb~append(replaceSpecials(s)) + mb~append(.EndOfLine) + end + mb~append("</pre>") + return mb~string + /** * Print a while file. */ @@ -118,14 +135,7 @@ use arg tree, out -- the file initialization code out~say(doc2string(tree~doc)) - -- this could be moved to some shared routine - out~say('<pre class="rxsource">') - do s over tree~source~source - if s = "" then iterate - out~say(s) - end - out~say("</pre>") - + out~say(printCode(tree~source~source)) -- get a list of classes classes = tree~classes @@ -165,50 +175,61 @@ constants = classes[o]~constants if constants~items > 0 then do out~say('<div class="constants" id="const_'o~name'"><h3>Constants</h3>') - out~say('<table class="table_constants"><tr><td>Name</td><td>Value</td></tr>') + out~say('<table class="srctable table_constants"><thead><tr><td>Name</td><td>Value</td><td>Description</td></tr></thead><tfoot><tr><td colspan="3"></td></tr></tfoot><tbody>') do constant over constants - out~say('<tr class="constant" id="const_'o~name'_'constant~name'"><td>'constant~name'</td><td>'constant~value'</td></tr>') + out~say('<tr class="constant" id="const_'o~name'_'constant~name'"><td>'constant~name'</td><td>'constant~value'</td><td>') + out~say(doc2string(constant~doc)) + out~say('Modifiers: ') + out~say(getMethodDetails(constant)) + out~say('</td></tr>') end - out~say('</table></div>') + out~say('</tbody></table></div>') end -- print the attributes attributes = classes[o]~attributes if attributes~items > 0 then do out~say('<div class="attributes" id="attr_'o~name'"><h3>Attributes</h3>') - out~say('<table class="table_attributes"><tr><td>Name</td><td>Access</td></tr>') + out~say('<table class="srctable table_attributes"><thead><tr><td>Name</td><td>Access</td><td>Description</td></tr></thead><tfoot><tr><td colspan="3"></td></tr></tfoot><tbody>') do attribute over attributes - out~say('<tr class="attribute" id="attr_'o~name'_'attribute~name'"><td>'attribute~name'</td><td>'attribute~getAccess'</td></tr>') + out~say('<tr class="attribute" id="attr_'o~name'_'attribute~name'"><td>'attribute~name'</td><td>'attribute~getAccess'</td><td>') + out~say(doc2string(attribute~doc)) + out~say('Modifiers: ') + out~say(getMethodDetails(attribute)) + out~say('</td></tr>') end - out~say('</table></div>') + out~say('</tbody></table></div>') end -- print the methods - out~say('<div class="methods" id="mth_'o~name'"><h3>Methods</h3>') - methods = classes[o]~methods - out~say('<table class="table_methods"><tr><td>name</td><td>Description</td></tr>') - do p over methods~makeArray~sort - out~say('<tr class="method" id="mth_'o~name'_'p~name'">') - out~say(' <td>'p~name"</td><td>") - out~say(replaceSpecials(doc2string(p~doc))) - out~say('Modifiers: ') - out~say(getMethodDetails(p)) - -- print the source - source = p~source~source - if source \= .nil , source~items > 0 & \p~isAbstract then do - out~say(' <div class="span_source">Show source') - out~say('<div class="rxsource_div">') - out~say('Source for <strong>'o~name||'~'||p~name||'</strong>') - out~say('<pre class="rxsource">') - do s over source - if s = "" then iterate - out~say(replaceSpecials(s)) + methods = classes[o]~methods~makeArray~sort + if methods~items > 0 then do + out~say('<div class="methods" id="mth_'o~name'"><h3>Methods</h3>') + out~say('<table class="srctable table_methods"><thead><tr><td>Name</td><td>Description</td></tr></thead><tfoot><tr><td colspan="2"></td></tr></tfoot>') + out~say('<tbody>') + do p over methods + out~say('<tr class="method" id="mth_'o~name'_'p~name'">') + out~say(' <td>'p~name) + if .true then do + -- print the source + source = p~source~source + if source \= .nil , source~items > 0 & \p~isAbstract then do + out~say('<div class="span_source">Show source') + out~say('<div class="rxsource_div">') + out~say('Source for <strong>'o~name||'~'||p~name||'</strong>') + out~say(printCode(source)) + out~say('</div></div>') + end end - out~say('</pre></div></div>') + out~say("</td><td>") + out~say(doc2string(p~doc)) + out~say('Modifiers: ') + out~say(getMethodDetails(p)) + out~say(' </td></tr>') end - out~say(' </td></tr>') + out~say('</tbody>') + out~say('</table></div>') end - out~say('</table>') -- methods, class -- TODO: add support for floating methods, routines... - out~say('</div></div>') + out~say('</div>') end return '' Modified: incubator/rexxdoc/rexxdoc.cls =================================================================== --- incubator/rexxdoc/rexxdoc.cls 2008-02-21 22:11:53 UTC (rev 2374) +++ incubator/rexxdoc/rexxdoc.cls 2008-02-21 22:42:13 UTC (rev 2375) @@ -44,13 +44,17 @@ if .environment~FileParser = .nil then .environment~FileParser = .FileParser /** This is the main class for parsing rexx source files. It produces a parse -* tree that can be used to create a visualisation of the source. +* tree that can be used to create a visualisation of the source. It is used +* both as the starting point to kick off the parsing process as well as for +* parsing required files. */ ::CLASS FileParser /** This method returns the default options. A parser can be created with * custom options, but they should be a modified copy of the default options. +* @returns a copy of the default options. */ ::METHOD defaultOptions CLASS +/* */ expose defaultOptions if var("defaultOptions") then return defaultOptions~copy @@ -83,16 +87,27 @@ */ ::METHOD Parse expose file state options tree source parent + use strict arg lines source = .SourceContainer~new tree = .SourceFile~new(file, source, "", parent, self~ParseState) expectDefinition = .false - fileStream = .stream~new(file) + +-- -- !!! this needs to be modified! +-- fileStream = .stream~new(file) + +-- lines = fileStream~arrayIn + -- line counter i = 0 + + -- not in append mode at the beginning append = .false + -- and nothing collected yet prefix = "" - do while fileStream~lines > 0 + + -- iterate over all lines in the input stream + do inLine over lines i+=1 - line = prefix||fileStream~lineIn + line = prefix||inLine -- handle continuation chars lastChars = line~right(2) lastChar = lastChars~right(1) @@ -118,8 +133,16 @@ -- this method is propagated through the whole tree if tree~parent = .nil then tree~resolve +/** The main parsing tree. This method exposes the tree gerated by the parsing +* process. +*/ ::ATTRIBUTE Tree Get +/** The current parse state. It always stores the current parsing details like +* line number and line content. It offers methods to print warnings and erros. +*/ ::ATTRIBUTE ParseState Get +/** The options for this FileParser. +*/ ::ATTRIBUTE Options Get /** Get the current RXDOC and reset it @@ -133,6 +156,12 @@ /** The main parsing method. It maintains a state for the current parsing * state. It creates parsers for source elements. +* Possible states are: +* UNDETERMINED: The current state is yet to be determined or there is nothing +* special on the line. +* DIRECTIVE: Parsing a directive. +* RXDOC: Collecting a documentation block. +* PROCEDURE: A procedure has been found. */ ::METHOD parseLine PRIVATE expose tree node state nextstate has accu rxdoc options source @@ -826,7 +855,7 @@ ::METHOD setAttribute expose attribute; attribute = .true -::CLASS SourceAttribute SUBCLASS SourceElement +::CLASS SourceAttribute SUBCLASS SourceAbstractMethod ::METHOD Init expose access access = "SET/GET" @@ -838,7 +867,7 @@ expose access; return access ::METHOD resolve -::CLASS SourceConstant SUBCLASS SourceElement +::CLASS SourceConstant SUBCLASS SourceAbstractMethod ::METHOD resolve ::METHOD setValue expose value; use strict arg value @@ -872,7 +901,8 @@ ::METHOD resolve expose options sourceFile if options~follow.requires then do - sourceFile = .FileParser~new(self~name,options,self~parent)~~parse~tree + stream = .stream~new(self~name) + sourceFile = .FileParser~new(self~name,options,self~parent)~~parse(stream~arrayIn)~tree -- the fileParse does not do this automatically here sourceFile~resolve end Modified: incubator/rexxdoc/style.css =================================================================== --- incubator/rexxdoc/style.css 2008-02-21 22:11:53 UTC (rev 2374) +++ incubator/rexxdoc/style.css 2008-02-21 22:42:13 UTC (rev 2375) @@ -34,15 +34,37 @@ /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*----------------------------------------------------------------------------*/ -body {background-color:#FFF;} -pre {font-family:courier;} -table.table_methods td {border-width: 0px 0px 1px 0px; +body { + background-color:#FFF; +} +pre { + font-family: monospace; +} +table.srctable thead td { + font-weight: bolder; +} + +table.srctable tbody td { + border-width: 1px 0px 0px 0px; border-style: solid; border-color: black; padding: 0px; - vertical-align: top;} -table.table_methods {width:100%;} + vertical-align: top; +} +table.srctable tbody td:first-child { + width: 20%; + font-weight: bold; + font-family: monospace; +} +table.srctable.table_attributes td:first-child + td { + width: 20%; +} + +table.srctable { + width:100%; +} + div.rxsource_div { display:none; font-weight: normal; @@ -51,23 +73,29 @@ left:10px; top:10px; height: 80%; - width: 80%; + width: auto; background-color:white; border: green 3px dotted; overflow:auto; } -div.span_source {font-weight: bold; display: inline;} -div.span_source:hover {background-color: red;} +div.span_source { + font-weight: normal; + display: block; +} +div.span_source:hover { + background-color: red; +} div.span_source:hover div.rxsource_div { display:block; } pre.rxsource { - display:block; - position:relative; + display: block; + position: relative; max-height: 95%; height: auto; + min-width: 40em; margin: 0px; padding: 0px; overflow:auto; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |