template::parse_directives (public)

 template::parse_directives code

Defined in packages/acs-templating/tcl/doc-procs.tcl

Parse out directives embedded in the code parameter.

Parameters:
code (required)

Partial Call Graph (max 5 caller/called nodes):
%3 doc::parse_comment_text doc::parse_comment_text (private) template::parse_directives template::parse_directives doc::parse_comment_text->template::parse_directives doc::parse_namespace doc::parse_namespace (private) doc::parse_namespace->template::parse_directives template::get_datasources template::get_datasources (public) template::get_datasources->template::parse_directives

Testcases:
No testcase defined.
Source code:

    # 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
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: