$html" + lappend lines $l } + set string [join $lines \n] + set html [ns_quotehtml $string] + regsub -all {(\n[\t ]*)(\#[^\n]*)} $html \\1
$html" + } + :public object method get_doc_block {text {restVar ""}} { + set lines [split $text \n] + set docBlock "" + set i 0 + set nrLines [llength $lines] + while {[string trim [lindex $lines $i]] eq "" && $i < $nrLines} {incr i} + while {$i < $nrLines} { + set line [string trim [lindex $lines $i]] + incr i + if {[string index $line 0] ne "#"} break + append docBlock [string range $line 1 end] \n + } + if {$restVar ne ""} { + upvar $restVar rest + set rest [join [lrange $lines $i end] \n] + } + #ns_log notice "=================== get_doc_block RETURNS <$docBlock>" + return $docBlock + } + :public object method update_object_doc {scope obj doc_string} { + # + # Update the api browser informatio nsvs with information about + # the provided object. + # + # If no doc string is provided, try to get it from the object + # definition. + # + if {$doc_string eq ""} { + set doc_string [:get_doc_block [:get_init_block $scope $obj]] + } -::xotcl::Object instproc __api_make_doc {inst proc_name} { - upvar doc doc private private public public deprecated deprecated - if {$doc eq ""} { - set doc_elements(main) "" - } else { - ad_parse_documentation_string $doc doc_elements + ad_parse_documentation_string $doc_string doc_elements + # + # Initialize dictionary with default values and update it with the + # information from parsing the doc string. + # + set doc [dict create \ + param "" \ + protection public \ + varargs_p false \ + deprecated_p false \ + warn_p false \ + script [::xo::api script_name $scope] \ + ] + set doc [dict replace $doc {*}[array get doc_elements]] + + # + # TODO: add actual parameters to flags and defaults (also required, ...) + # + set switches {}; set flags {} + foreach l [dict get $doc param] { + if {[regexp {^([^ ]+)\s} $l . word]} { + lappend switches $word + lappend flags $word "" + } + } + set proc_index [::xo::api object_index $scope $obj] + set doc [dict replace $doc \ + default_values "" \ + switches $switches \ + positionals "" \ + flags $flags \ + ] + nsv_set api_proc_doc $proc_index $doc + nsv_set api_library_doc $proc_index $doc + + set file_index [dict get $doc script] + if {[nsv_exists api_library_doc $file_index]} { + array set elements [nsv_get api_library_doc $file_index] + } + set oldDoc [expr {[info exists elements(main)] ? \ + [lindex $elements(main) 0] : ""}] + set prefix "This file defines the following Objects and Classes" + set entry [::xo::api object_link $scope $obj] + if {![string match "*$prefix*" $oldDoc]} { + append oldDoc "
$prefix: $entry" + } else { + append oldDoc ", $entry" + } + set elements(main) [list $oldDoc] + #my log "elements = [array get elements]" + nsv_set api_library_doc $file_index [array get elements] + + if {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Class]} { + # + # nx classes + # + foreach protection {public protected private} { + foreach m [::nsf::dispatch $obj ::nsf::methods::class::info::methods \ + -callprotection $protection -type scripted] { + set docBlock [:get_doc_block \ + [::nsf::dispatch $obj ::nsf::methods::class::info::method body $m]] + ::xo::api update_method_doc \ + -protection $protection \ + -deprecated=false \ + -debug=false \ + $scope $obj \ + inst $m $docBlock + } + } + } + if {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Object]} { + # + # nx objects + # + foreach protection {public protected private} { + foreach m [::nsf::dispatch $obj ::nsf::methods::object::info::methods \ + -callprotection $protection -type scripted] { + set docBlock [:get_doc_block \ + [::nsf::dispatch $obj ::nsf::methods::object::info::method body $m]] + ::xo::api update_method_doc \ + -protection $protection \ + -deprecated=false \ + -debug=false \ + $scope $obj \ + "" $m $docBlock + } + } + } + } - set defaults [list] - foreach a [::xo::getObjectProperty [self] ${inst}args $proc_name] { - if {[::xo::getObjectProperty [self] ${inst}argdefault $proc_name $a d]} {lappend defaults $a $d} + + :public object method update_method_doc { + {-protection "public"} + {-deprecated:switch false} + {-debug:switch false} + {-warn:switch false} + scope obj inst proc_name + docString + } { + set varargs_p [expr {"args" in [::xo::getObjectProperty $obj ${inst}args $proc_name]}] + + set doc [dict create \ + param "" \ + protection $protection \ + varargs_p $varargs_p \ + deprecated_p false \ + warn_p false \ + script [::xo::api script_name $scope] \ + main "" \ + flags "" \ + switches "" \ + ] + + if {$docString ne ""} { + ad_parse_documentation_string $docString doc_elements + set doc [dict replace $doc {*}[array get doc_elements]] + } + + set defaults [list] + foreach a [::xo::getObjectProperty $obj ${inst}args $proc_name] { + if {[::xo::getObjectProperty $obj ${inst}argdefault $proc_name $a d]} { + lappend defaults $a $d + } + } + + foreach def [::xo::getObjectProperty $obj ${inst}methodparameter $proc_name] { + lassign $def f default + set pair [split [lindex $f 0 0] :] + lassign $pair flaggedName flags + if {[string range $flaggedName 0 0] eq "-"} { + set isFlag 1 + set name [string range $flaggedName 1 end] + } else { + set isFlag 0 + set name $flaggedName + } + if {$isFlag} { + dict lappend doc switches $name + dict lappend doc flags $name $flags + #my log "default_value $proc_name: $sw -> '[lindex $f 1]' <$pair/$f>" + if {$flags eq "switch" && $default eq ""} { + set default "false" + } + } + #my log "default_value $proc_name: $sw -> 'default' <$pair/$f>" + if {[llength $def] > 1} {lappend defaults $name $default} + } + dict set doc default_values $defaults + dict set doc positionals [::xo::getObjectProperty $obj ${inst}args $proc_name] + + # argument documentation finished + set proc_index [::xo::api proc_index $scope $obj ${inst}proc $proc_name] + if {![nsv_exists api_proc_doc $proc_index]} { + nsv_lappend api_proc_doc_scripts [dict get $doc script] $proc_index + } + #ns_log notice "SETTING api_proc_doc '$proc_index' <$doc>" + nsv_set api_proc_doc $proc_index $doc + } + + :public object method get_init_block {scope obj} { + # + # Get the init block of an object/class or return empty + # + if {$scope eq ""} { + if {[::nsf::var::exists $obj __cmd(__initblock)]} { + return [::nsf::var::set $obj __cmd(__initblock)] + } + } else { + if {[$scope do ::nsf::var::exists $obj __cmd(__initblock)]} { + return [$scope do [::nsf::var::exists $obj __cmd(__initblock)]] + } + } + return "" } - set public [expr {$private ? false : true}] - set doc_elements(public_p) $public - set doc_elements(private_p) $private - set doc_elements(deprecated_p) $deprecated - set doc_elements(warn_p) $deprecated - set doc_elements(varargs_p) [expr {"args" in [::xo::getObjectProperty [self] ${inst}args $proc_name]}] - set doc_elements(flags) [list] - set doc_elements(switches) [list] - foreach f [my info ${inst}nonposargs $proc_name] { - set pair [split [lindex $f 0 0] :] - set sw [string range [lindex $pair 0] 1 end] - lappend doc_elements(switches) $sw - lappend doc_elements(flags) $sw [lindex $pair 1] - #my log "default_value $proc_name: $sw -> '[lindex $f 1]' <$pair/$f>" - if {[lindex $pair 1] eq "switch" && [lindex $f 1] eq ""} { - set default "false" + + :public object method get_object_source {scope obj} { + set init_block [:get_init_block $scope $obj] + if {$init_block ne ""} { + set dummy [:get_doc_block $init_block body] + return $body } else { - set default [lindex $f 1] + if {$scope eq ""} { + return [$obj serialize] + } else { + return [$scope do $obj serialize] + } } - #my log "default_value $proc_name: $sw -> 'default' <$pair/$f>" - lappend defaults $sw $default } - set doc_elements(default_values) $defaults - set doc_elements(positionals) [::xo::getObjectProperty [self] ${inst}args $proc_name] - # argument documentation finished - set scope [::xotcl::api scope] - set doc_elements(script) [::xotcl::api script_name $scope] - set proc_index [::xotcl::api proc_index $scope [self] ${inst}proc $proc_name] - if {![nsv_exists api_proc_doc $proc_index]} { - nsv_lappend api_proc_doc_scripts $doc_elements(script) $proc_index + + :public object method get_method_source {scope obj prefix method} { + if {$scope eq ""} { + return [::Serializer methodSerialize $obj $method $prefix] + } else { + return [$scope do ::Serializer methodSerialize $obj $method $prefix] + } } - #my log "doc_elements=[array get doc_elements]" - #my log "SETTING api_proc_doc '$proc_index'" - nsv_set api_proc_doc $proc_index [array get doc_elements] + + :public object method update_nx_docs {{objects ""}} { + if {[llength $objects] == 0} { + set objects [nx::Object info instances -closure] + } + + foreach o $objects { + # + # check general per-object documentation + # + if {[string match ::nx::* $o]} continue + ::xo::api update_object_doc "" $o "" + } + + } } +::nx::Class public method init {} { + set r [next] + # + # When loading the blueprint, ::xo::api might not be available yet + # + if {[info commands ::xo::api] ne ""} { + ::xo::api update_object_doc "" [self] "" + #ns_log notice "METHODS [self] <[:info methods]>" + } else { + #ns_log notice "[self] init: no <::xo::api> available" + } + return $r +} + ::xotcl::Object instproc __api_make_forward_doc {inst method_name} { upvar doc doc private private public public deprecated deprecated if {$doc eq ""} { @@ -197,9 +536,7 @@ #my log "doc_elements=[array get doc_elements]" } set defaults [list] - set public [expr {$private ? false : true}] - set doc_elements(public_p) $public - set doc_elements(private_p) $private + set doc_elements(protection) [expr {$private ? "protected" : "public"}] set doc_elements(deprecated_p) $deprecated set doc_elements(warn_p) $deprecated set doc_elements(varargs_p) false @@ -208,9 +545,9 @@ set doc_elements(default_values) [list] set doc_elements(positionals) [list] # argument documentation finished - set scope [::xotcl::api scope] - set doc_elements(script) [::xotcl::api script_name $scope] - set proc_index [::xotcl::api proc_index $scope [self] ${inst}forward $method_name] + set scope [::xo::api scope] + set doc_elements(script) [::xo::api script_name $scope] + set proc_index [::xo::api proc_index $scope [self] ${inst}forward $method_name] if {![nsv_exists api_proc_doc $proc_index]} { nsv_lappend api_proc_doc_scripts $doc_elements(script) $proc_index } @@ -219,55 +556,42 @@ nsv_set api_proc_doc $proc_index [array get doc_elements] } -if {[info commands ::nx::Object] ne ""} { +::xotcl::Object instproc ad_proc { + {-private:switch false} + {-deprecated:switch false} + {-warn:switch false} + {-debug:switch false} + proc_name + arguments:parameter,0..* + doc + body +} { + uplevel [list [self] proc $proc_name $arguments $body] + ::xo::api update_method_doc \ + -protection [expr {$private ? "private" : "public"}] \ + -deprecated=$deprecated \ + -debug=$private \ + [::xo::api scope] [self] \ + "" $proc_name $doc +} - ::xotcl::Object instproc ad_proc { - {-private:switch false} - {-deprecated:switch false} - {-warn:switch false} - {-debug:switch false} - proc_name - arguments:parameter,0..* - doc - body - } { - uplevel [list [self] proc $proc_name $arguments $body] - my __api_make_doc "" $proc_name - } - - ::xotcl::Class instproc ad_instproc { - {-private:switch false} - {-deprecated:switch false} - {-warn:switch false} - {-debug:switch false} - proc_name - arguments:parameter,0..* - doc - body - } { - uplevel [list [self] instproc $proc_name $arguments $body] - my __api_make_doc inst $proc_name - } -} else { - ::xotcl::Object instproc ad_proc { - {-private:switch false} - {-deprecated:switch false} - {-warn:switch false} - {-debug:switch false} - proc_name arguments doc body} { - uplevel [list [self] proc $proc_name $arguments $body] - my __api_make_doc "" $proc_name - } - - ::xotcl::Class instproc ad_instproc { - {-private:switch false} - {-deprecated:switch false} - {-warn:switch false} - {-debug:switch false} - proc_name arguments doc body} { - uplevel [list [self] instproc $proc_name $arguments $body] - my __api_make_doc inst $proc_name - } +::xotcl::Class instproc ad_instproc { + {-private:switch false} + {-deprecated:switch false} + {-warn:switch false} + {-debug:switch false} + proc_name + arguments:parameter,0..* + doc + body +} { + uplevel [list [self] instproc $proc_name $arguments $body] + ::xo::api update_method_doc \ + -protection [expr {$private ? "private" : "public"}] \ + -deprecated=$deprecated \ + -debug=$private \ + [::xo::api scope] [self] \ + inst $proc_name $doc } ::xotcl::Object instproc ad_forward { @@ -290,51 +614,10 @@ my __api_make_forward_doc inst $method_name } - - ::xotcl::Object instproc ad_doc {doc_string} { - ad_parse_documentation_string $doc_string doc_elements - set scope [::xotcl::api scope] - set doc_elements(script) [::xotcl::api script_name $scope] - set proc_index [::xotcl::api object_index $scope [self]] - - #if {![nsv_exists api_proc_doc $proc_index]} { - # nsv_lappend api_proc_doc_scripts $doc_elements(script) $proc_index - #} - set doc_elements(public_p) true - set doc_elements(private_p) false - set doc_elements(varargs_p) false - set doc_elements(deprecated_p) false - set doc_elements(warn_p) false - set doc_elements(default_values) "" - set doc_elements(switches) "" - set doc_elements(positionals) "" - set doc_elements(flags) "" - nsv_set api_proc_doc $proc_index [array get doc_elements] - nsv_set api_library_doc \ - $proc_index \ - [array get doc_elements] - - set file_index $doc_elements(script) - - if {[nsv_exists api_library_doc $file_index]} { - array set elements [nsv_get api_library_doc $file_index] - } - set oldDoc [expr {[info exists elements(main)] ? \ - [lindex $elements(main) 0] : ""}] - set prefix "This file defines the following Objects and Classes" - set entry [::xotcl::api object_link $scope [self]] - if {![string match "*$prefix*" $oldDoc]} { - append oldDoc "
$prefix: $entry"
- } else {
- append oldDoc ", $entry"
- }
- set elements(main) [list $oldDoc]
- #my log "elements = [array get elements]"
- nsv_set api_library_doc $file_index [array get elements]
+ ::xo::api update_object_doc "" [self] $doc_string
}
-
# Class ::Test -ad_doc {
# Test Class for the documentation of
# Classes
,
Index: openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl,v
diff -u -r1.31.2.1 -r1.31.2.2
--- openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 2 Dec 2015 08:30:11 -0000 1.31.2.1
+++ openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 30 Dec 2015 18:09:14 -0000 1.31.2.2
@@ -194,7 +194,7 @@
# compatibility, but complain in ns_log.
#
# (E.g. hypermail2xowiki uses this)
- ns_log notice "Could not find ::xo::Package with key $package_key ($package_id)"
+ ns_log warning "Could not find ::xo::Package with key $package_key ($package_id)"
set package_class [self]
}
Index: openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl,v
diff -u -r1.49.2.2 -r1.49.2.3
--- openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 3 Oct 2015 18:28:39 -0000 1.49.2.2
+++ openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 30 Dec 2015 18:09:14 -0000 1.49.2.3
@@ -124,7 +124,7 @@
}
}
fileSpooler proc tick {} {
- if {[catch {my cleanup} errorMsg]} {ns_log notice "Error during filespooler cleanup: $errorMsg"}
+ if {[catch {my cleanup} errorMsg]} {ns_log error "Error during filespooler cleanup: $errorMsg"}
my set to [after [my set tick_interval] [list [self] tick]]
}
fileSpooler tick
@@ -344,7 +344,7 @@
set subs1 [list]
foreach s $subscriptions($key) {
if {[catch {$s $method $argument} errMsg]} {
- ns_log notice "error in $method to subscriber $s (key=$key): $errMsg"
+ ns_log error "error in $method to subscriber $s (key=$key): $errMsg"
$s destroy
} else {
lappend subs1 $s
Index: openacs-4/packages/xotcl-core/tcl/context-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/context-procs.tcl,v
diff -u -r1.65.2.3 -r1.65.2.4
--- openacs-4/packages/xotcl-core/tcl/context-procs.tcl 7 Dec 2015 16:58:07 -0000 1.65.2.3
+++ openacs-4/packages/xotcl-core/tcl/context-procs.tcl 30 Dec 2015 18:09:14 -0000 1.65.2.4
@@ -12,7 +12,7 @@
namespace eval ::xo {
- Class create Context -ad_doc {
+ ::xotcl::Class create Context -ad_doc {
This class provides a context for evaluation, somewhat similar to an
activation record in programming languages. It combines the parameter
declaration (e.g. of a page, an includelet) with the actual parameters
@@ -26,7 +26,8 @@
locale
}
- # syntactic sugar for includelets, to allow the same syntax as
+ #
+ # Syntactic sugar for includelets, to allow the same syntax as
# for "Package initialize ...."; however, we do not allow currently
# do switch user or package id etc., just the parameter declaration
Context instproc initialize {{-parameter ""}} {
Index: openacs-4/packages/xotcl-core/tcl/doc-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/doc-procs.tcl,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/xotcl-core/tcl/doc-procs.tcl 10 Sep 2015 08:10:45 -0000 1.1.2.1
+++ openacs-4/packages/xotcl-core/tcl/doc-procs.tcl 30 Dec 2015 18:09:14 -0000 1.1.2.2
@@ -1,9 +1,9 @@
ad_library {
- generic doc procs
+ generic doc procs
- @creation-date 2015-04-30
- @author Gustaf Neumann
- @cvs-id $Id$
+ @creation-date 2015-04-30
+ @author Gustaf Neumann
+ @cvs-id $Id$
}
namespace eval ::xo {
@@ -23,18 +23,19 @@
upvar $methods_ref methods
set infokind $kind
if {$kind eq "instproc"} {append infokind s}
- ::xotcl::api scope_from_object_reference scope e
- foreach method [xo::getObjectProperty $e $kind] {
+ ::xo::api scope_from_object_reference scope e
+ if {$kind eq "proc"} {set prefix "→ "} {set prefix ""}
+ foreach methodName [xo::getObjectProperty $e $kind] {
if {$documented_methods} {
- set proc_index [::xotcl::api proc_index $scope $e $kind $method]
- #my msg "check $method => [nsv_exists api_proc_doc $proc_index]"
- if {[nsv_exists api_proc_doc $proc_index]} {
- lappend methods $method
- }
- } else {
- lappend methods $method
- }
- }
+ set proc_index [::xo::api proc_index $scope $e $kind $methodName]
+ #my msg "check $methodName => [nsv_exists api_proc_doc $proc_index]"
+ if {[nsv_exists api_proc_doc $proc_index]} {
+ lappend methods $prefix$methodName
+ }
+ } else {
+ lappend methods $prefix$methodName
+ }
+ }
}
ad_proc dotclass {{-is_focus 0} {-documented_methods 1} e} {
@@ -55,9 +56,10 @@
}
}
append definition "|"
- ::xotcl::api scope_from_object_reference scope e
+ ::xo::api scope_from_object_reference scope e
set methods [list]
- dot_append_method -documented_methods $documented_methods $e methods instproc
+ dot_append_method -documented_methods $documented_methods $e methods proc
+ dot_append_method -documented_methods $documented_methods $e methods instproc
dot_append_method -documented_methods $documented_methods $e methods instforward
foreach method [lsort $methods] {append definition "$method\\l" }
append definition "\}\"\];\n"
@@ -85,98 +87,94 @@
set mclasses {}
foreach e $things {
- if {![::xotcl::Object isobject $e]} continue
- if {$omit_base_classes && ($e eq "::xotcl::Object" || $e eq "::xotcl::Class")} continue
- lappend [expr {[::xotcl::Object isclass $e] ? "classes" : "objects"}] $e
+ if {![::nsf::is object $e] || ($omit_base_classes && [::nsf::is baseclass $e])} continue
+ lappend [expr {[::nsf::is class $e] ? "classes" : "objects"}] $e
}
set instances ""
if {$with_instance_relations} {
- foreach e $things {
- if {![::xotcl::Object isobject $e]} continue
- if {$omit_base_classes && ($e eq "::xotcl::Object" || $e eq "::xotcl::Class")} continue
- set c [$e info class]
- if {$omit_base_classes && ($c eq "::xotcl::Object" || $c eq "::xotcl::Class")} continue
- if {$c ni $things} {lappend iclasses $c}
- append instances "[dotquote $e]->[dotquote $c];\n"
- }
+ foreach e $things {
+ if {![::nsf::is object $e] || ($omit_base_classes && [::nsf::is baseclass $e])} continue
+ set c [$e info class]
+ if {$omit_base_classes && [::nsf::is baseclass $c]} continue
+ if {$c ni $things} {lappend iclasses $c}
+ append instances "[dotquote $e]->[dotquote $c];\n"
+ }
}
set superclasses ""
foreach e $classes {
- if {![::xotcl::Object isobject $e]} continue
- if {$e eq "::xotcl::Object"} continue
- set reduced_sc [list]
- foreach sc [::xo::getObjectProperty $e superclass] {
- if {$omit_base_classes && ($sc eq "::xotcl::Object" || $sc eq "::xotcl::Class")} continue
- lappend reduced_sc $sc
- }
- if {$reduced_sc eq {}} continue
- foreach sc $reduced_sc {
- if {$sc in $things} {
- append superclasses "[dotquote $e]->[dotquotel $sc];\n"
- }
- }
+ if {![::nsf::is object $e]} continue
+ set reduced_sc [list]
+ foreach sc [::xo::getObjectProperty $e superclass] {
+ if {$omit_base_classes && [::nsf::is baseclass $sc]} continue
+ lappend reduced_sc $sc
+ }
+ if {$reduced_sc eq {}} continue
+ foreach sc $reduced_sc {
+ if {$sc in $things} {
+ append superclasses "[dotquote $e]->[dotquotel $sc];\n"
+ }
+ }
}
- set children ""
- set mixins ""
- foreach e $things {
- if {![::xotcl:::Object isobject $e]} continue
- if {$omit_base_classes && ($e eq "::xotcl::Object" || $e eq "::xotcl::Class")} continue
- if {$with_children} {
- foreach c [$e info children] {
- if {$c ni $things} continue
- append children "[dotquote $c]->[dotquote $e];\n"
- }
- }
- set m [xo::getObjectProperty $e mixin]
- #puts "-- $e mixin $m"
- if {$m eq ""} continue
- foreach mixin $m {
- if {$mixin ni $things} {lappend mclasses $m}
- append mixins "[dotquote $e]->[dotquotel $mixin];\n"
- }
- }
- set tclasses ""
- set instmixins ""
- foreach e $classes {
- set m [xo::getObjectProperty $e instmixin]
- #puts "-- $e instmixin $m"
- if {$m eq ""} continue
- #foreach mixin $m {
- # append tclasses [dotclass -documented_methods $documented_methods $mixin]
- #}
+ set children ""
+ set mixins ""
+ foreach e $things {
+ if {![::nsf::is object $e] || ($omit_base_classes && [::nsf::is baseclass $e])} continue
+ if {$with_children} {
+ foreach c [$e info children] {
+ if {$c ni $things} continue
+ append children "[dotquote $c]->[dotquote $e];\n"
+ }
+ }
+ set m [xo::getObjectProperty $e mixin]
+ #puts "-- $e mixin $m"
+ if {$m eq ""} continue
+ foreach mixin $m {
+ if {$mixin ni $things} {lappend mclasses $m}
+ append mixins "[dotquote $e]->[dotquotel $mixin];\n"
+ }
+ }
+ set tclasses ""
+ set instmixins ""
+ foreach e $classes {
+ set m [xo::getObjectProperty $e instmixin]
+ #puts "-- $e instmixin $m"
+ if {$m eq ""} continue
+ #foreach mixin $m {
+ # append tclasses [dotclass -documented_methods $documented_methods $mixin]
+ #}
- foreach mixin $m {
- if {$mixin ni $things} {lappend mclasses $mixin}
- append instmixins "[dotquote $e]->[dotquotel $mixin];\n"
- }
- }
+ foreach mixin $m {
+ if {$mixin ni $things} {lappend mclasses $mixin}
+ append instmixins "[dotquote $e]->[dotquotel $mixin];\n"
+ }
+ }
- foreach e $classes {
- append tclasses [dotclass -is_focus [expr {$e eq $current_object}] -documented_methods $documented_methods $e]
- }
- set tobjects {}
- foreach e $objects {
- append tobjects [dotobject $e]
- }
- set tmclasses {}
- foreach e $mclasses {
- append tmclasses [dotobject $e]
- }
- set ticlasses {}
- foreach e $iclasses {
- append ticlasses [dotobject $e]
- }
+ foreach e $classes {
+ append tclasses [dotclass -is_focus [expr {$e eq $current_object}] -documented_methods $documented_methods $e]
+ }
+ set tobjects {}
+ foreach e $objects {
+ append tobjects [dotobject $e]
+ }
+ set tmclasses {}
+ foreach e $mclasses {
+ append tmclasses [dotobject $e]
+ }
+ set ticlasses {}
+ foreach e $iclasses {
+ append ticlasses [dotobject $e]
+ }
+
+ #label = \".\\n.\\nObject relations of [self]\"
+ #edge \[dir=back, constraint=0\] \"::Decorate_Action\" -> \"::Action\";
+ set objects [join [dotquotel $objects] {; }]
+ #set classes [join [dotquotel $classes] {; }]
+ set imcolor hotpink4
- #label = \".\\n.\\nObject relations of [self]\"
- #edge \[dir=back, constraint=0\] \"::Decorate_Action\" -> \"::Action\";
- set objects [join [dotquotel $objects] {; }]
- #set classes [join [dotquotel $classes] {; }]
- set imcolor hotpink4
-
- set font "fontname = \"Helvetica\",fontsize = 8,"
- #set font "fontname = \"Bitstream Vera Sans\",fontsize = 8,"
- # rankdir = BT; labeldistance = 20;
- return "digraph {
+ set font "fontname = \"Helvetica\",fontsize = 8,"
+ #set font "fontname = \"Bitstream Vera Sans\",fontsize = 8,"
+ # rankdir = BT; labeldistance = 20;
+ return "digraph {
dpi = $dpi;
rankdir = BT;
node \[$font shape=record\]; $tclasses
@@ -196,6 +194,6 @@
# Local variables:
# mode: tcl
-# tcl-indent-level: 2
+# tcl-indent-level: 4
# indent-tabs-mode: nil
# End:
Index: openacs-4/packages/xotcl-core/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/www/index.tcl,v
diff -u -r1.8.2.1 -r1.8.2.2
--- openacs-4/packages/xotcl-core/www/index.tcl 10 Sep 2015 08:10:45 -0000 1.8.2.1
+++ openacs-4/packages/xotcl-core/www/index.tcl 30 Dec 2015 18:09:14 -0000 1.8.2.2
@@ -26,7 +26,7 @@
proc local_link cl {
upvar all_classes all_classes
- if {$all_classes || ![string match "::xotcl::*" $cl]} {
+ if {$all_classes || (![string match "::xotcl::*" $cl] && ![string match "::nx::*" $cl])} {
return "$cl"
} else {
return $cl
@@ -57,10 +57,11 @@
lappend classes {*}[nx::Class info instances -closure]
}
foreach cl [lsort $classes] {
- if {!$all_classes && [string match "::xotcl::*" $cl]} \
- continue
+ if {!$all_classes && ([string match "::xotcl::*" $cl] || [string match "::nx::*" $cl])} {
+ continue
+ }
- append output "
[join $pretty {, }]\n" } - return $s + + return "$line" } # # document the class or the object" # -set index [::xotcl::api object_index $scope $object] -append output "
\n" +set index [::xo::api object_index $scope $object] set class_hierarchy [list] if {$isclass} { - set hierarchy 0 - if {$hierarchy} { - append output "\n" - append output "Class Hierarchy of $object
" - append output [draw_as_tree [superclass_hierarchy $object $scope]] - } else { - append output "
\n" - append output [class_summary $object $scope] - } + append output "Class $object
" + append output "\n" + append output [class_summary $object $scope] + # # compute list of classes with siblings foreach c [DO xo::getObjectProperty $object superclass] { - if {$c eq "::xotcl::Object"} {continue} + if {[DO xo::getObjectProperty $object isbaseclass]} continue lappend class_hierarchy {*}[DO xo::getObjectProperty $c subclass] } - if {[llength $class_hierarchy]>5} {set class_hierarchy {}} + if {[llength $class_hierarchy]>5} { + set class_hierarchy {} + } # Display just up to two extra two levels of heritage to keep the # class in quesiton in focus. @@ -224,10 +217,11 @@ } lappend class_hierarchy {*}$heritage - if {$object ni $class_hierarchy} {lappend class_hierarchy $object} + if {$object ni $class_hierarchy} { + lappend class_hierarchy $object + } if {$below > 0} { - for {set level 1} {$level < $below} {incr level} { foreach sc $subclasses { foreach c [DO xo::getObjectProperty $sc subclass] { @@ -246,7 +240,7 @@ array set doc_elements [nsv_get api_library_doc $index] append output [lindex $doc_elements(main) 0] append output "\n"\n" - if { [info exists doc_elements(param)] } { + if { [info exists doc_elements(param)] && [llength $doc_elements(param)] > 0} { append output "
- Documented Parameters:\n" foreach par $doc_elements(param) { append output "
- -[lindex $par 0] [lrange $par 1 end]\n" @@ -285,6 +279,7 @@ if {$isclass} { append obj_create_source \ + [info_option $scope $object class] \ [info_option $scope $object superclass] \ [info_option $scope $object instmixin] \ [info_option $scope $object subclass 1] @@ -298,46 +293,54 @@ } if {$show_source} { - append output [::xotcl::api source_to_html $obj_create_source] \n + append output [::xo::api source_to_html $obj_create_source] \n } proc api_src_doc {out show_source scope object proc m} { set output "
- $out" if { $show_source } { append output \ "
" \ - [::apidoc::tcl_to_html [::xotcl::api proc_index $scope $object $proc $m]] \ + [::apidoc::tcl_to_html [::xo::api proc_index $scope $object $proc $m]] \} return $output } if {$show_methods} { - append output "Methods
\n"\n - foreach m [lsort [DO ::xo::getObjectProperty $object proc]] { - set out [api_documentation $scope $object proc $m] - if {$out ne ""} { - append output [api_src_doc $out $show_source $scope $object proc $m] + # + # per-object methods + # + set methods [lsort [DO ::xo::getObjectProperty $object command]] + if {[llength $methods] > 0} { + append output "
Methods (to be applied on the object)
\n"\n + foreach m $methods { + set type [DO ::xo::getObjectProperty $object methodtype $m] + set out [local_api_documentation -proc_type $type $show_methods $scope $object proc $m] + if {$out ne ""} { + append output [api_src_doc $out $show_source $scope $object proc $m] + } } } - foreach m [lsort [DO ::xo::getObjectProperty $object forward]] { - set out [api_documentation $scope $object forward $m] - if {$out ne ""} { - append output [api_src_doc $out $show_source $scope $object forward $m] - } - } if {$isclass} { - set cls [lsort [DO ::xo::getObjectProperty $object instproc]] - foreach m $cls { - set out [api_documentation $scope $object instproc $m] - if {$out ne ""} { - append output "
- $out" - if { $show_source } { - append output \ - "
" \ - [::apidoc::tcl_to_html [::xotcl::api proc_index $scope $object instproc $m]] \ -+ # + # instance methods + # + set methods [lsort [DO ::xo::getObjectProperty $object instcommand]] + if {[llength $methods] > 0} { + append output "Methods (to be applied on instances)
\n"\n + foreach m $methods { + set type [DO ::xo::getObjectProperty $object instmethodtype $m] + set out [local_api_documentation -proc_type $type $show_methods $scope $object instproc $m] + if {$out ne ""} { + append output "
- $out" + if { $show_source } { + append output \ + "
" \ + [::apidoc::tcl_to_html [::xo::api proc_index $scope $object instproc $m]] \ ++ } } } } @@ -356,14 +359,14 @@ } if {$vars ne ""} { append output "Variables
\n" \ - [::xotcl::api source_to_html $vars] \n + [::xo::api source_to_html $vars] \n } } if {$isclass} { set instances "" foreach o [lsort [DO $object info instances]] { - append instances [::xotcl::api object_link $scope $o] ", " + append instances [::xo::api object_link $scope $o] ", " } set instances [string trimright $instances ", "] if {$instances ne ""} { @@ -379,7 +382,7 @@ # Construct the dot code from the provided classes. # # TODO: it would be nice to pass the selected options from the - # dimensional slide to dotcode, since with svg, the dot code + # dimensional slider to dotcode, since with svg, the dot code # constructs URLS for navigation in the class tree. # set dot_code [::xo::dotcode -dpi 72 \ @@ -389,31 +392,35 @@ -current_object $object \ -documented_methods $documented_only \ $class_hierarchy] - set dot "" catch {set dot [::util::which dot]} # final ressort for cases, where ::util::which is not available if {$dot eq "" && [file executable /usr/bin/dot]} {set dot /usr/bin/dot} - if {$dot eq ""} {ns_return 404 plain/text "dot not found"; ad_script_abort} + if {$dot eq ""} { + #ns_return 404 plain/text "dot not found" + ns_log warning "no dot available" + #ad_script_abort + } else { - set tmpnam [ad_tmpnam] - set tmpfile $tmpnam.svg - set f [open $tmpnam.dot w]; puts $f $dot_code; close $f + set tmpnam [ad_tmpnam] + set tmpfile $tmpnam.svg + set f [open $tmpnam.dot w]; puts $f $dot_code; close $f - #ns_log notice "svg $tmpnam dot $tmpnam.dot" - set f [open "|$dot -Tsvg -o $tmpfile" w]; puts $f $dot_code; close $f - set f [open $tmpfile]; set svg [read $f]; close $f + #ns_log notice "svg $tmpnam dot $tmpnam.dot" + set f [open "|$dot -Tsvg -o $tmpfile" w]; puts $f $dot_code; close $f + set f [open $tmpfile]; set svg [read $f]; close $f - # delete the first three lines generated from dot - regsub {^[^\n]+\n[^\n]+\n[^\n]+\n} $svg "" svg - set css { - svg g a:link {text-decoration: none;} - div.inner {width: 100%; margin: 0 auto;} - } - set svg "" + # delete the first three lines generated from dot + regsub {^[^\n]+\n[^\n]+\n[^\n]+\n} $svg "" svg + set css { + svg g a:link {text-decoration: none;} + div.inner svg {width: 100%; margin: 0 auto;} + } + set svg "$svg" - file delete $tmpfile - file delete $tmpnam.dot + file delete $tmpfile + file delete $tmpnam.dot + } } append output "$svg