summaryrefslogtreecommitdiffstats
path: root/tools/man2help.tcl
diff options
context:
space:
mode:
authorstanton <stanton>1998-04-28 18:53:49 (GMT)
committerstanton <stanton>1998-04-28 18:53:49 (GMT)
commit7a698c0488d99c0af42022714638ae1ba2afaa49 (patch)
treeb25713e341ff09e21fb10bf1c3cd36c481067e3c /tools/man2help.tcl
parent72d823b9193f9ee2b0318563b49363cd08c11f24 (diff)
downloadtcl-7a698c0488d99c0af42022714638ae1ba2afaa49.zip
tcl-7a698c0488d99c0af42022714638ae1ba2afaa49.tar.gz
tcl-7a698c0488d99c0af42022714638ae1ba2afaa49.tar.bz2
Initial revision
Diffstat (limited to 'tools/man2help.tcl')
-rw-r--r--tools/man2help.tcl129
1 files changed, 129 insertions, 0 deletions
diff --git a/tools/man2help.tcl b/tools/man2help.tcl
new file mode 100644
index 0000000..daaefca
--- /dev/null
+++ b/tools/man2help.tcl
@@ -0,0 +1,129 @@
+# man2help.tcl --
+#
+# This file defines procedures that work in conjunction with the
+# man2tcl program to generate a Windows help file from Tcl manual
+# entries.
+#
+# Copyright (c) 1996 by Sun Microsystems, Inc.
+#
+# SCCS: %Z% $Id: man2help.tcl,v 1.1 1998/04/28 18:53:50 stanton Exp $
+#
+
+#
+# PASS 1
+#
+
+proc generateContents {basename version files} {
+ global curID topics
+ set curID 0
+ foreach f $files {
+ regsub -all -- {-} [file tail $f] {} curFile
+ puts "Pass 1 -- $f"
+ flush stdout
+ doFile $f
+ }
+ set fd [open "$basename$version.cnt" w]
+ puts $fd ":Base $basename$version.hlp"
+ foreach package [getPackages] {
+ foreach section [getSections $package] {
+ puts $fd "1 $section"
+ set lastTopic {}
+ foreach topic [getTopics $package $section] {
+ if {[string compare $lastTopic $topic] != 0} {
+ set id $topics($package,$section,$topic)
+ puts $fd "2 $topic=$id"
+ set lastTopic $topic
+ }
+ }
+ }
+ }
+ close $fd
+}
+
+
+#
+# PASS 2
+#
+
+proc generateHelp {basename files} {
+ global curID topics keywords file id_keywords
+ set curID 0
+
+ foreach key [array names keywords] {
+ foreach id $keywords($key) {
+ lappend id_keywords($id) $key
+ }
+ }
+
+ set file [open "$basename.rtf" w]
+ puts $file "\{\\rtf1\\ansi \\deff0\\deflang1033\{\\fonttbl\{\\f0\\froman\\fcharset0\\fprq2 Times New Roman\;\}\}"
+ foreach f $files {
+ regsub -all -- {-} [file tail $f] {} curFile
+ puts "Pass 2 -- $f"
+ flush stdout
+ initGlobals
+ doFile $f
+ pageBreak
+ }
+ puts $file "\}"
+ close $file
+}
+
+# doFile --
+#
+# Given a file as argument, translate the file to a tcl script and
+# evaluate it.
+#
+# Arguments:
+# file - Name of file to translate.
+
+proc doFile {file} {
+ if [catch {eval [exec man2tcl [glob $file]]} msg] {
+ global errorInfo
+ puts stderr $msg
+ puts "in"
+ puts $errorInfo
+ exit 1
+ }
+}
+
+# doDir --
+#
+# Given a directory as argument, translate all the man pages in
+# that directory.
+#
+# Arguments:
+# dir - Name of the directory.
+
+proc doDir dir {
+ puts "Generating man pages for $dir..."
+ foreach f [lsort [glob [file join $dir *.\[13n\]]]] {
+ do $f
+ }
+}
+
+# process command line arguments
+
+if {$argc < 3} {
+ puts stderr "usage: $argv0 projectName version manFiles..."
+ exit 1
+}
+
+set baseName [lindex $argv 0]
+set version [lindex $argv 1]
+set files {}
+foreach i [lrange $argv 2 end] {
+ set i [file join $i]
+ if [file isdir $i] {
+ foreach f [lsort [glob [file join $i *.\[13n\]]]] {
+ lappend files $f
+ }
+ } elseif [file exists $i] {
+ lappend files $i
+ }
+}
+
+source [file join [file dir $argv0] index.tcl]
+generateContents $baseName $version $files
+source [file join [file dir $argv0] man2help2.tcl]
+generateHelp $baseName $files