#!/bin/sh # \ exec $CCP4I_TCLTK/tclsh "$0" -- ${1+"$@"} # Copyright (C) 1999-2004 Liz Potterton, Peter Briggs # # This code is distributed under the terms and conditions of the # CCP4 Program Suite Licence Agreement as a CCP4 Library. # A copy of the CCP4 licence can be obtained by writing to the # CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK. # #CCP4i_cvs_Id $Id$ # Source startup.tcl appropriate for operating system set system(OPSYS) [string toupper $tcl_platform(platform)] source [file join $env(CCP4I_TOP) bin $system(OPSYS) startup.tcl] # Source the useful utils source [file join $env(CCP4I_TOP) src system.tcl] source [file join $env(CCP4I_TOP) src utils.tcl] #---------------------------------------------------------------------- # The following declarations are liable to change #---------------------------------------------------------------------- # list of files to be processed - the inner loop is. # - a name for the output html file # - the ccp4i subdirectory containing files to be processed # - list of files set doclist [list [list system src system utils] \ [list taskbrowser src task taskbrowser browser_utils] \ [list modules_utils src modules_utils] \ [list CCP4_utils src CCP4_utils ] \ [list local src local ] \ [list database src database runjob projectdirs projectdb ] \ [list windows src window taskwindow exframe varmenu] \ [list mega_widgets src util_windows fileselect directories ] \ [list plugins src fileviewer plugins ] \ [list execute src execute job_utils ] \ [list utilities utils map_utils pdb_utils phasing_utils amore_utils] \ [list install_utils utils CCP4i_packages_utils] \ [list xml_utils utils xml_utils] \ [list maths src vectors] ] set htmlHeader " CCP4I Documentation for Programmers: Core Documentation

CCP4i Documentation for Programmers: Core Documentation

Contents

\n" set htmlFooter " \n" #---------------------------------------------------------------------- #---------------------------------------------------------------------- # By default create docs for the current $CCP4I_TOP and place the # docs in $CCP4I_TOP/help/programmers/progdocs. Beware that if you change # these the default paths for html links defined below may need changing. set srcPath [GetEnvPath CCP4I_TOP] set docPath [file join $srcPath help programmers progdocs] puts "docPath = $docPath" set indexFile index.html # Parse any command line input set nargs [llength $argv]; set n 0 while { $n < $nargs } { set cmd [string tolower [lindex $argv $n]] switch -regexp -- $cmd \ src { incr n; set srcPath [lindex $argv $n] } doc { incr n; set docPath [lindex $argv $n] } index { incr n; set indexFile [lindex $argv $n] } incr n } # Set up an index html file set contentsText $htmlHeader set indexText "

The Procedures

\n" # Loop through every document on the doclist and create text for a new # html file foreach doc $doclist { set htmlFile [lindex $doc 0].html # set htmlText {} set htmlText $htmlHeader set modulePath [file join $srcPath [lindex $doc 1]] puts "Reading source file.." # # Loop over all specified source files - read the contents with # lines split into a list foreach file [lrange $doc 2 end] { set filePath [file join $modulePath $file.tcl] puts "..$filePath" if { ![ReadFile $filePath srctext -split] } { puts "ABORTING: Can not read file $filePath" exit } # # Loop over every line looking for the #d_ at start of line which indicates # a documentation tag. If a documentation line ends in continuation character # then you need to append the next line from the file (and get rid of the # continuation character. set l 0; set lmax [llength $srctext] while { $l < $lmax } { set line0 [lindex $srctext $l] if [regexp {^#d_} $line0] { set ll [string wordend $line0 1] set cmd [string range $line0 3 [expr $ll -1]] set line [string range $line0 [expr $ll + 1] end] while { [ regexp {\\$} $line] } { set line [string trimright $line \\ ] incr l; append line [lindex $srctext $l] } # # Handle the documentation line according to the tag # switch $cmd \ intro_title { set target [RemoveMetaChars $line] append htmlText "

$line

\n" append indexText "
$line
\n" } intro { append htmlText

$line

\n } index_title { set target [RemoveMetaChars $line] append contentsText "

$line
" append indexText "
$line
\n" append htmlText "

$line

\n" } sum { append indexText "
$procName $line
\n" append htmlText "

$procName $line

\n" append htmlText "

Argument list: $argList

\n" } desc { append htmlText

$line

\n } arg { append htmlText "

[lindex $line 0] [lrange $line 1 end]

\n" } opt0 { if { [llength $line] > 1 } { append htmlText "

[lindex $line 0] [lrange $line 1 end]

\n" } else { append htmlText "

$line

\n" } } opt1 { append htmlText "

$line

\n" } ref { set mode file set path {} switch [lindex $line 0] \ PROGRAMS { set path [file join "../../../../html/" [lindex $line 1]] } CCP4I { set path [file join "../../../help/" [lindex $line 1]] } PROGDOCS { set path [file join "./" [lindex $line 1]] } REMOTE { set path "http://[lindex $line 1]" set mode http } CURRENT { set path "#[lindex $line 1]" } append htmlText "[lrange $line 2 end]" } doc { append htmlText \ "See Programmers Documentation" } # # If find a procedure declaration in file then save the procedure name } elseif { [regexp {^proc } $line0] } { # remove the open/close brace from the line or it might be mishandled by lindex regsub -all {\{|\}} $line0 {} procLine set procName [lindex $procLine 1] # Create a formatted argument list for writing out later set argList "" for {set i 2} {$i<[llength $procLine]} {incr i} { append argList " <[lindex $procLine $i]>" } if {$argList == ""} { set argList "None" } } incr l } } # Write out the html file for this document puts "Writing docs to [file join $docPath $htmlFile]" append htmlText $htmlFooter WriteFile [file join $docPath $htmlFile] $htmlText -overwrite } puts "Writing list of procedures to [file join $docPath $indexFile]" append contentsText \n $indexText $htmlFooter WriteFile [file join $docPath $indexFile] $contentsText -overwrite exit