]>
git.ipfire.org Git - thirdparty/gcc.git/blob - texinfo/util/gen-dir-node
2 # $Id: gen-dir-node,v 1.1 1997/08/21 22:58:12 jason Exp $
3 # Generate the top-level Info node, given a directory of Info files
4 # and (optionally) a skeleton file. The output will be suitable for a
5 # top-level dir file. The skeleton file contains info topic names in the
6 # order they should appear in the output. There are three special
7 # lines that alter the behavior: a line consisting of just "--" causes
8 # the next line to be echoed verbatim to the output. A line
9 # containing just "%%" causes all the remaining filenames (wildcards
10 # allowed) in the rest of the file to be ignored. A line containing
11 # just "!!" exits the script when reached (unless preceded by a line
12 # containing just "--"). Once the script reaches the end of the
13 # skeleton file, it goes through the remaining files in the directory
14 # in order, putting their entries at the end. The script will use the
15 # ENTRY information in each info file if it exists. Otherwise it will
16 # make a minimal entry.
18 # sent by Jeffrey Osier <jeffrey@cygnus.com>, who thinks it came from
19 # zoo@winternet.com (david d `zoo' zuhn)
21 # modified 7 April 1995 by Joe Harrington <jh@tecate.gsfc.nasa.gov> to
33 if [ $# -gt 2 ] ; then
34 echo usage
: $0 info-directory
[ skeleton-file
] 1>&2
40 if [ ! -d ${INFODIR} ] ; then
41 echo "$0: first argument must specify a directory"
45 ### output the dir header
47 echo "This file was generated automatically by $0."
48 echo "This version was generated on `date`"
49 echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`"
53 This is the file .../info/dir, which contains the topmost node of the
54 Info hierarchy. The first time you invoke Info you start off
55 looking at that node, which is (dir)Top.
57 File: dir Node: Top This is the top of the INFO tree
58 This (the Directory node) gives a menu of major topics.
59 Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h"
60 gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
62 Or click mouse button 2 on a menu item or cross reference to select it.
63 --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---
65 * Menu: The list of major topics begins on the next line.
69 ### go through the list of files in the skeleton. If an info file
70 ### exists, grab the ENTRY information from it. If an entry exists
71 ### use it, otherwise create a minimal dir entry.
73 ### Then remove that file from the list of existing files. If any
74 ### additional files remain (ones that don't have a skeleton entry),
75 ### then generate entries for those in the same way, putting the info for
76 ### those at the end....
78 infofiles
=`(cd ${INFODIR}; ls | egrep -v '\-|^dir$|^dir\.info$|^dir\.orig$')`
80 # echoing gets clobbered by backquotes; we do it the hard way...
81 lines
=`wc $SKELETON | awk '{print $1}'`
83 while [ $lines -ge $line ] ; do
84 # Read one line from the file. This is so that we can echo lines with
85 # whitespace and quoted characters in them.
86 fileline
=`awk NR==$line $SKELETON`
89 if [ ! -z "$echoline" ] ; then # echo line
93 elif [ "${fileline}" = "--" ] ; then # should we echo the next line?
95 elif [ "${fileline}" = "%%" ] ; then # eliminate remaining files from dir?
97 elif [ "${fileline}" = "!!" ] ; then # quit now
101 # handle files if they exist
102 for file in $fileline"" ; do # expand wildcards ("" handles blank lines)
106 if [ -z "$echoline" -a ! -z "$file" ] ; then
108 # Find the file to operate upon. Check both possible names.
109 infoname
=`echo $file | sed 's/\.info$//'`
112 if [ -f ${INFODIR}/$infoname ] ; then
115 if [ -f ${INFODIR}/${infoname}.info
] ; then
119 # If it exists with both names take what was said in the file.
120 if [ ! -z "$ext" -a ! -z "$noext" ]; then
122 warn
="### Warning: $ext and $noext both exist! Using ${file}. ###"
123 elif [ ! \
( -z "$ext" -a -z "$noext" \
) ]; then
124 # just take the name if it exists only once
128 # if we found something and aren't skipping, do the entry
129 if [ ! -z "$fname" ] ; then
130 if [ -z "$skip" ] ; then
132 if [ ! -z "$warn" ] ; then # issue any warning
137 entry
=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
138 -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$fname`
139 if [ ! -z "${entry}" ] ; then
142 echo "* ${infoname}: (${fname})."
146 # remove the name from the directory listing
147 infofiles
=`echo ${infofiles} | sed -e "s/ ${fname} / /" \
148 -e "s/^${fname} //" \
157 line
=`expr $line + 1`
160 if [ -z "${infofiles}" ] ; then
166 for file in ${infofiles}; do
167 infoname
=`echo $file | sed 's/\.info$//'`
168 entry
=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
169 -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}`
171 if [ ! -z "${entry}" ] ; then
174 echo "* ${infoname}: (${file})."