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.76 -r1.77 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 20 Oct 2024 10:09:06 -0000 1.76 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 20 Oct 2024 15:23:13 -0000 1.77 @@ -394,6 +394,31 @@ return $result } +ad_proc -private api_proc_pretty_param_details {-flags:required -default_value} { + @return string with details about a parameter +} { + set param_details {} + if {"required" in $flags} { + lappend param_details required + } else { + lappend param_details optional + } + if {"boolean" in $flags} { + lappend param_details boolean + } elseif {"int" in $flags || "integer" in $flags} { + lappend param_details integer + } + if {"0..1" in $flags} { + lappend param_details "accept empty" + } + + if { [info exists default_value] && $default_value ne ""} { + lappend param_details "defaults to \"[ns_quotehtml $default_value]\"" + } + return [expr {[llength $param_details]>0 ? "([join $param_details {, }])" : ""}] +} + + ad_proc -public api_proc_documentation { -format -script:boolean @@ -554,25 +579,15 @@ if { [llength $switches] > 0 } { append blocks_out "
Switches:
\n" foreach switch $switches { - set param_details "" - if {"required" in $flags($switch)} { - lappend param_details required - } else { - lappend param_details optional - } - if {"boolean" in $flags($switch)} { - lappend param_details boolean - } + set details [api_proc_pretty_param_details \ + -flags $flags($switch) \ + {*}[expr {[info exists default_values($switch)] + ? [list -default_value $default_values($switch)] + : {}}] \ - if { [info exists default_values($switch)] - && $default_values($switch) ne "" - } { - lappend param_details "defaults to \"[ns_quotehtml $default_values($switch)]\"" - } + ] append blocks_out \ - "
-$switch " \ - ([join $param_details {, }]) \ - "
" + "
-$switch $details
" if { [info exists params($switch)] } { append blocks_out "
$params($switch)
" } @@ -583,18 +598,18 @@ if { [llength $doc_elements(positionals)] > 0 } { append blocks_out "
Parameters:
\n" foreach positional $doc_elements(positionals) { - set param_details "" - if { [info exists default_values($positional)] } { - if { $default_values($positional) eq "" } { - lappend param_details "optional" - } else { - lappend param_details "defaults to \"$default_values($positional)\"" - } + set pflags $flags($positional) + if {![info exists default_values($positional)]} { + lappend pflags required } + set details [api_proc_pretty_param_details \ + -flags $pflags \ + {*}[expr {[info exists default_values($positional)] + ? [list -default_value $default_values($positional)] + : {}}] \ + ] append blocks_out \ - "
$positional " \ - [expr {[llength $param_details]>0 ? "([join $param_details {, }])" : ""}] \ - "
" + "
$positional $details
" if { [info exists params($positional)] } { append blocks_out $params($positional) }