Index: openacs-4/packages/xotcl-core/www/show-object.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/www/show-object.tcl,v
diff -u -r1.27 -r1.28
--- openacs-4/packages/xotcl-core/www/show-object.tcl 9 Sep 2018 13:11:39 -0000 1.27
+++ openacs-4/packages/xotcl-core/www/show-object.tcl 3 Sep 2024 15:37:54 -0000 1.28
@@ -1,7 +1,10 @@
ad_page_contract {
- Show an xotcl class or object
+ Show an XOTcl class or object
+ @param as_img do NOT include svg content in the HTML rendering
+
@author Gustaf Neumann
+
@cvs-id $Id$
} -query {
{object:nohtml,trim ::xotcl::Object}
@@ -202,7 +205,7 @@
}
# Display just up to two extra two levels of heritage to keep the
- # class in quesiton in focus.
+ # class in question in focus.
set heritage [DO xo::getObjectProperty $object heritage]
set subclasses [DO xo::getObjectProperty $object subclass]
@@ -236,6 +239,7 @@
}
}
set documented_only [expr {$show_methods < 2}]
+set hide_methods [expr {$show_methods == 0}]
if {[nsv_exists api_library_doc $index]} {
array set doc_elements [nsv_get api_library_doc $index]
@@ -244,7 +248,11 @@
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"
+ if {[regexp {^\s*(\S+)\s*(.*)$} $par . param desc]} {
+ append output "- $param
- $desc
\n"
+ } else {
+ ad_log warning "show_object: ignoring invalid parameter description <$par>"
+ }
}
append output "
"
}
@@ -258,7 +266,7 @@
append output "Created:\n[lindex $doc_elements(creation-date) 0]\n"
}
if { [info exists doc_elements(author)] } {
- append output "Author[ad_decode [llength $doc_elements(author)] 1 "" "s"]:\n"
+ append output "Author[expr {[llength $doc_elements(author)] > 1 ? "s" : ""}]:\n"
foreach author $doc_elements(author) {
append output "[::apidoc::format_author $author]\n"
}
@@ -399,55 +407,27 @@
}
}
+#
+# "as_img" true means: do not include SVG in the code.
+#
if {!$as_img} {
#
- # Construct the dot code from the provided classes.
+ # Construct the dot code from the provided classes as embedded svg
+ # code.
#
- # TODO: it would be nice to pass the selected options from the
- # 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 \
-with_children $with_children \
-with_instance_relations $with_instance_relations \
-omit_base_classes 0 \
-current_object $object \
-documented_methods $documented_only \
+ -hide_methods $hide_methods \
$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"
- ns_log warning "program 'dot' is not 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
-
- #ns_log notice "svg $tmpnam dot $tmpnam.dot"
- set f [open "|$dot -Tsvg -o $tmpfile" w]; puts $f $dot_code
- try {
- close $f
- } on error {errorMsg} {
- ns_log warning "dot returned $errorMsg"
- }
- 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 svg {width: 100%; margin: 0 auto;}
- }
- set svg ""
-
- file delete -- $tmpfile
- file delete -- $tmpnam.dot
- }
+ set svg [util::inline_svg_from_dot -css {
+ svg g a:link {text-decoration: none;}
+ div.inner svg {width: 100%; margin: 0 auto;}
+ } $dot_code]
}
if {$isclass} {