3 # This file defines procedures that work in conjunction with the
4 # man2tcl program to generate a Windows help file from Tcl manual
7 # Copyright (c) 1996 by Sun Microsystems, Inc.
16 proc generateContents {basename version files} {
24 set fd [open "$basename$version.cnt" w]
25 fconfigure $fd -translation crlf
26 puts $fd ":Base $basename$version.hlp"
27 foreach package [getPackages] {
28 foreach section [getSections $package] {
31 foreach topic [getTopics $package $section] {
32 if {[string compare $lastTopic $topic]} {
33 set id $topics($package,$section,$topic)
34 puts $fd "2 $topic=$id"
48 proc generateHelp {basename files} {
49 global curID topics keywords file id_keywords
52 foreach key [array names keywords] {
53 foreach id $keywords($key) {
54 lappend id_keywords($id) $key
58 set file [open "$basename.rtf" w]
59 fconfigure $file -translation crlf
60 puts $file "\{\\rtf1\\ansi \\deff0\\deflang1033\{\\fonttbl\{\\f0\\froman\\fcharset0\\fprq2 Times New Roman\;\}\}"
74 # Given a file as argument, translate the file to a tcl script and
78 # file - Name of file to translate.
81 if {[catch {eval [exec man2tcl [glob $file]]} msg] &&
82 [catch {eval [exec ./man2tcl [glob $file]]} msg]} {
93 # Given a directory as argument, translate all the man pages in
97 # dir - Name of the directory.
100 puts "Generating man pages for $dir..."
101 foreach f [lsort [glob [file join $dir *.\[13n\]]]] {
106 # process command line arguments
109 puts stderr "usage: $argv0 projectName version manFiles..."
113 set baseName [lindex $argv 0]
114 set version [lindex $argv 1]
116 foreach i [lrange $argv 2 end] {
118 if {[file isdir $i]} {
119 foreach f [lsort [glob [file join $i *.\[13n\]]]] {
122 } elseif {[file exists $i]} {
127 source [file join [file dir $argv0] index.tcl]
128 generateContents $baseName $version $files
129 source [file join [file dir $argv0] man2help2.tcl]
130 generateHelp $baseName $files