- Publicity: Public Only All
doc-procs.tcl
Documentation procedures for the ArsDigita Templating System
- Location:
- packages/acs-templating/tcl/doc-procs.tcl
- Author:
- Karl Goldstein <karlg@arsdigita.com>
- CVS Identification:
$Id: doc-procs.tcl,v 1.13 2024/09/11 06:15:48 gustafn Exp $
Procedures in this file
- template::get_datasources (public)
- template::parse_directives (public)
- template::verify_datasources (public)
Detailed information
template::get_datasources (public)
template::get_datasources code
Assemble directives into data source(s) for presentation.
- Parameters:
- code (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::parse_directives (public)
template::parse_directives code
Parse out directives embedded in the code parameter.
- Parameters:
- code (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::verify_datasources (public)
template::verify_datasources
- Returns:
- True (1)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Content File Source
ad_library { Documentation procedures for the ArsDigita Templating System @author Karl Goldstein (karlg@arsdigita.com) @cvs-id $Id: doc-procs.tcl,v 1.13 2024/09/11 06:15:48 gustafn Exp $ } # Copyright (C) 1999-2000 ArsDigita Corporation # This is free software distributed under the terms of the GNU Public # License. Full text of the license is available from the GNU Project: # http://www.fsf.org/copyleft/gpl.html # Data source comments have the following form: # @datasource foo multirow # Output info about a foo. # @param column name The name of the foo. # @param id The ID of the foo passed with the request. namespace eval template {} d_proc -public template::parse_directives { code } { Parse out directives embedded in the code parameter. } { # remove carriage returns if present regsub -all -- {\r|\r\n} $code {\n} code # remove extra blank lines regsub -all -- {(\n)\n} $code {\1} code set lines [split $code "\n"] # regular expression for match directive comments set direxp {^\#[\s]*@([a-zA-Z0-9\-_]+)[\s]+(.*)$} set directives [list] foreach line $lines { if { [regexp $direxp $line x next_directive next_comment] } { # start a new directive if { [info exists directive] } { # finish last directive lappend directives [list $directive $comment] } set directive $next_directive set comment $next_comment } elseif { [info exists directive] } { if { [regexp {^\#\s*(.*)$} $line x add_comment] } { # append this line to the current directive append comment " $add_comment" } else { # finish directive lappend directives [list $directive $comment] unset directive unset comment } } } if { [info exists directive] } { lappend directives [list $directive $comment] } return $directives } ad_proc -public template::get_datasources { code } { Assemble directives into data source(s) for presentation. } { upvar datasources:rowcount rowcount set rowcount 0 #for debugging purposes upvar output text set text [parse_directives $code] foreach directive [parse_directives $code] { switch -exact [lindex $directive 0] { datasource { # directive is a new datasource set info [lindex $directive 1] # Assign the first elements of $info to 'name' and 'structure', # and the rest to 'comment' set comment [lassign $info name structure] if { [string match "one*" $structure] } { # directive is a onevalue or onelist. add a row and move on incr rowcount upvar datasources:$rowcount datasource set datasource(rownum) $rowcount set datasource(name) $name set datasource(structure) $structure set datasource(comment) $comment } } data_input { # directive is a new form set info [lindex $directive 1] # Assign the first elements of $info to 'name' and 'structure', # and the rest to 'comment' set comment [lassign $info name structure] } input { set info [lindex $directive 1] # Assign the first elements of $info to 'input_name' and # 'input_type', and the rest to 'input_comment' set input_comment [lassign $info input_name input_type] incr rowcount upvar datasources:$rowcount datasource set datasource(rownum) $rowcount set datasource(structure) $structure set datasource(comment) $comment set datasource(name) $name set datasource(input_name) $input_name set datasource(input_type) $input_type set datasource(input_comment) $input_comment } column { set info [lindex $directive 1] # Assign the first element of $info to 'column_name', and the # rest to 'column_comment' set column_comment [lassign $info column_name] incr rowcount upvar datasources:$rowcount datasource set datasource(rownum) $rowcount set datasource(name) $name set datasource(structure) $structure set datasource(comment) $comment set datasource(column_name) $column_name set datasource(column_comment) $column_comment } } } } ad_proc -public template::verify_datasources {} { @return True (1) } { return 1 } # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: