Index: openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 29 Sep 2008 08:42:06 -0000 1.26 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 7 Feb 2009 20:32:54 -0000 1.27 @@ -859,6 +859,28 @@ } { + if {[info command ::xotcl::api] ne ""} { + set scope [::xotcl::api scope_from_proc_index $proc_name] + } else { + set scope "" + } + + set proc_namespace "" + regexp {^(::)?(.*)::[^:]+$} $proc_name match colons proc_namespace + + return [api_tclcode_to_html -scope $scope -proc_namespace $proc_namespace [api_get_body $proc_name]] +} + +ad_proc -private api_tclcode_to_html {{-scope ""} {-proc_namespace ""} script} { + + Given a script, this proc formats it as HTML, including highlighting syntax in + various colors and creating hyperlinks to other proc definitions.
+ The inspiration for this proc was the tcl2html script created by Jeff Hobbs. + + @param script script to be formated in HTML + +} { + # Returns length of a variable name proc length_var {data} { if {[regexp -indices {^\$\{[^\}]+\}} $data found]} { @@ -970,15 +992,13 @@ {gets puts socket tell format scan} \ ] - if {"" ne [info command ::xotcl::api] } { + if {[info command ::xotcl::api] ne ""} { set XOTCL_KEYWORDS [list self my next] # only command names are highlighted, otherwise we could add xotcl method # names by [lsort -unique [concat [list self my next] .. # [::xotcl::Object info methods] [::xotcl::Class info methods] ]] - set scope [::xotcl::api scope_from_proc_index $proc_name] } else { set XOTCL_KEYWORDS {} - set scope "" } # Returns a list of the commands from all namespaces. @@ -991,16 +1011,8 @@ } set COMMANDS [list_all_procs] + set data [string map [list & "&" < "<" > ">"] \n$script] - set proc_namespace "" - regexp {^(::)?(.*)::[^:]+$} $proc_name match colons proc_namespace - - set data \n[api_get_body $proc_name] - - regsub -all {&} $data {\&} data - regsub -all {<} $data {\<} data - regsub -all {>} $data {\>} data - set in_comment 0 set in_quotes 0 set proc_ok 1 @@ -1151,6 +1163,7 @@ } + #################### # # Linking to api-documentation