guide.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. \documentstyle[11pt,reduce]{article}
  2. \begin{document}
  3. \title{Guide to Writing \REDUCE Reference Documents}
  4. \date{}
  5. \author{H. Melenk \& R. Sch\"opf}
  6. \maketitle
  7. \section{Introduction}
  8. Since Version 3.5 of \REDUCE, the documentation of a package consists of two
  9. parts, a manual part that is used to introduce the user to the background
  10. and the functionality of the package in a textbook style, and a reference
  11. part to be used more like an encyclopedia for retrieving isolated items or
  12. relations\footnote{%
  13. At present most of the packages lack a special reference document and a
  14. plain text version of the manuals are browsed instead. One purpose of this
  15. text is to encourage package suppliers to add a better-suited reference
  16. material to their product}. Both parts need different formats. While the
  17. \REDUCE manual style was fixed some time ago, the \REDUCE reference style
  18. was developed from scratch for \REDUCE 3.5 and essentially unmodified for
  19. \REDUCE 3.6. This paper is intended as a guide to writing a document in
  20. the reference style.
  21. {\bf Note}: The case of the keywords used in this document is relevant. E.g.
  22. you must write {\bf Examples}, {\bf Operator} on one hand, but {\bf verbatim}
  23. on the other.
  24. \section{Media}
  25. A reference document source is a text in \LaTeX{} language following a
  26. specific set of rules. This source text is converted for two different
  27. target media:
  28. \begin{itemize}
  29. \item printed reference manual for the package and a printed extension of
  30. the \REDUCE reference manual
  31. \item on-line help for the package as an extension of the \REDUCE on-line
  32. help system.
  33. \end{itemize}
  34. The printed text is formatted by \LaTeX{} using the style specific file {\bf %
  35. redref.sty}. For the on-line help system a special translation mechanism is
  36. used that generates data structures for different target systems. A
  37. description of the transformation process is given below. At present the
  38. target systems are
  39. \begin{itemize}
  40. \item Microsoft Windows help format for MS WINHELP;
  41. \item GNU Info format, used by GNU Info, xinfo and the \REDUCE X interface
  42. program XR;
  43. \item WWW (world wide web)\footnote{%
  44. formatter contributed by A. Strotmann, Cologne}.
  45. \end{itemize}
  46. The reference format has been designed to serve both purposes with one
  47. unique source. However, the restrictions are much more rigid than with
  48. ordinary \TeX{} styles. These restrictions must be followed carefully,
  49. otherwise the translation to help files will fail. Please note that a
  50. successful translation by \LaTeX{} is necessary but not sufficient as a
  51. test, since not all restrictions are controlled in the environment
  52. established by the style file.
  53. \section{General Structure}
  54. The overall structure is given by the traditional \LaTeX{} hierarchy
  55. \begin{verbatim}
  56. \begin{document}{...}
  57. \chapter{ }
  58. \section{ }
  59. \subsection{ }
  60. \subsubsection{ }
  61. \end{document}
  62. \end{verbatim}
  63. where -- of course -- some or all of the inner levels may be omitted. The
  64. structure is automatically converted into a directory hierarchy using the
  65. given titles. These {\bf must} be unique in the whole document (not only in
  66. the local section).
  67. Informal guideline: the titles should be as short as possible.
  68. The bottom level information must be cut explicitly into pieces that are
  69. named $nodes$ throughout this paper. There must not be any text outside a
  70. node - any such text may either get lost or disturb the translation process.
  71. Typical nodes are: an operator, a variable, a switch etc. In the manual form
  72. a node is a graphically separated part of a page with an emphasized heading.
  73. In the help form a node is a separate page. In both forms the text for a
  74. node can (and should) contain references to other nodes. These are encoded
  75. either as printed references (manual) or as hypertext links (help) that you
  76. can follow by clicking the word with the mouse. In addition, there are
  77. directories and indexes that alternatively lead the user to the desired
  78. information, and which also use the nodes as reference points.
  79. Informal guideline: hierarchy entries and nodes may be mixed on each level.
  80. On the other hand such a mixture may be unpleasant for online use. Also, the
  81. structure should not be too deep, otherwise the user must click lots of
  82. items until he reaches the desired item.
  83. \section{Nodes}
  84. \subsection{Node Context}
  85. In the source language a node is encoded as \LaTeX{} environment
  86. \begin{verbatim}
  87. \begin{<node-type>}[<options>]{<node-name>}
  88. <line-1>
  89. . . . % the node body
  90. <line-n>
  91. \end{<node-type>}
  92. \end{verbatim}
  93. The third part of the header line \verb|[<options>]| is omitted except for
  94. very special cases.
  95. The leading \verb|<node-type>| describes the type of information that is
  96. given in the node. Specific for the type are the layout and especially the
  97. heading and directory enty. \verb|<node-type>| is one of the following
  98. \begin{itemize}
  99. \item {\bf Introduction}: typically a piece of text used at the beginning
  100. of a section to give general information for the whole section.
  101. \verb|<node-name>| is a free heading, which, however, should be as short as
  102. possible.
  103. \item {\bf Operator}: description of an operator. \verb|<node-name>| is the
  104. operator name. When the operator is represented by a special character
  105. symbol, \verb|<options>| is the (internal) alphanumeric name and \{%
  106. \verb|<node-name>|\} contains the special character equivalent. E.g.
  107. \begin{verbatim}
  108. \begin{Operator}[replace]{=>}
  109. \end{verbatim}
  110. References should then be directed towards the alphanumeric name.
  111. \item {\bf Function}: similar to Operator.
  112. \item {\bf Statement}: description of a syntax extension. \verb|<node-name>|
  113. is the leading keyword or the statement.
  114. \item {\bf Command}: description of a command type syntax extension.
  115. \verb|<node-name>| is the leading keyword or the command.
  116. \item {\bf Declaration}: description of a declaration type syntax
  117. extension. \verb|<node-name>| is the leading keyword or the declaration
  118. statement.
  119. \item {\bf Switch}: description of a switch. \verb|<node-name>| is the
  120. switch name. Note that the body of a Switch node must give information of
  121. the default setting.
  122. \item {\bf Variable}: description of a global (share) variable.
  123. \verb|<node-name>| is the variable name.
  124. \item {\bf Constant}: description of a Constant. \verb|<node-name>| is the
  125. constant name.
  126. \item {\bf Concept}: used to introduce a description of a term that does
  127. not fit into one of the other classes, E.g. ``kernel''. \verb|<node-name>|
  128. is the target keyword.
  129. \end{itemize}
  130. In all cases \verb|<node-name>| must be written exactly as used in all
  131. references (correct case, no additional blanks etc.). For \REDUCE 3.5 and
  132. later versions, this is lower case for most items. Special characters
  133. other than underscore should be avoided whenever possible because these
  134. are often not accepted by the target systems.
  135. \subsection{Node Structure}
  136. Inside a node the default state is ``normal text". Special environments (%
  137. \verb|\begin{..}| -- \verb|\end{..}| contexts) are supported that allow you
  138. to format text. These are
  139. \begin{itemize}
  140. \item {\bf Syntax}: description of the syntax for an operator, statement or
  141. command. This is translated into a fixed font. For special advice see below.
  142. \item {\bf Examples}: description of prototypical applications, including
  143. input and output. Here special formatting is performed - see below.
  144. \item {\bf verbatim}: text is printed unchanged in fixed font.
  145. \item {\bf Tex}: a text that allows full \LaTeX{} functionality; such a
  146. piece of information is ignored during compilation for help.
  147. \item {\bf Info}: a text which is processed when compiling for help and
  148. which is ignored during \LaTeX{} processing.
  149. \end{itemize}
  150. Typically \verb|Tex| and \verb|Info| are used one after the other in order
  151. to describe the same context in an advanced (Tex) and a simple (Info) style.
  152. \subsubsection{Normal Text}
  153. This is text translated to a proportional font (where applicable). An empty
  154. line causes a new paragraph to be started. Only a very limited \TeX{}
  155. compatibility is given: Use the backslash for protecting special characters
  156. like \{ and \}. Additionally formatting elements are available:
  157. \begin{itemize}
  158. \item \verb|\|verb
  159. \item \verb|\|ldots
  160. \item \verb|\|cdots
  161. \item \verb|\|pi
  162. \item \verb|\|em (may be without effect for some targets)
  163. \item \verb|\|meta\{x\}: write $x$ as meta symbol for a syntax
  164. description. In general this will lead to an output similar to $x$.
  165. \item \verb|\|name\{x\}: write $x$ as a \REDUCE symbol. This form should be
  166. used for all keywords, operator names etc.
  167. \item \verb|\|nameref\{x\}: write $x$ as a \REDUCE symbol and generate a
  168. reference to a node with the name $x$. This features is used to establish
  169. the cross links in the information structure.
  170. \item \verb|\|index\{x\}: generate an index entry. $x$ does not appear in
  171. the target text.
  172. \end{itemize}
  173. Additionally there is a new command
  174. \begin{quotation}
  175. \verb|\IFTEX{|\TeX{} text\verb|}{|info text\verb|}|
  176. \end{quotation}
  177. that allows you to write parts of the text in two forms, one fancy form for
  178. \LaTeX{} processing and a simpler form for the help environment. For
  179. example, a mathematical formula like $\exp (x)$ must be written as follows:
  180. \begin{verbatim}
  181. \IFTEX{$\exp(x)$}{exp(x)}
  182. \end{verbatim}
  183. Note: the \verb|*| variants of \verb|\verb| and \verb|verbatim| cannot be
  184. used. Informal guidelines:
  185. \begin{itemize}
  186. \item The text should have a nice structure. When the text has many lines
  187. insert paragraph breaks such that the eye of the reader finds fixing points.
  188. \item All \verb|\|index entries should follow immediately the header line
  189. of the node.
  190. \item Ensure that the spelling of index entries is unified, e.g. use only
  191. singular and lower case (except for proper names).
  192. \item Use \verb|\|nameref for as many names as possible. The
  193. interrelations help the user to navigate through your document. Mention
  194. every related node at least once in a \verb|\|nameref; if a related node
  195. does not have a ``natural'' place in the text add a ``See also'' paragraph
  196. at the end of the node.
  197. \item Don't repeat \verb|\|nameref for the same object in one node unless
  198. the distance between the citation points is rather big (nore than half a
  199. page) - use \verb|\|name for repeated occurrences.
  200. \end{itemize}
  201. \subsubsection{Syntax Context}
  202. This section contains the formal pattern of the introduced operator or
  203. statement. The following items must be preceded by a backslash: {\bf round
  204. brackets}, {\bf curly brackets}, {\bf underscore}, {\bf dollar}. Use
  205. \verb|\meta| in the description for the variable items and explain these
  206. using the same forms in the following plain text. The fixed items should be
  207. encoded using \verb|\name|.
  208. Examples:
  209. \begin{verbatim}
  210. \begin{Syntax}
  211. \meta{logical\_expression} \name{and} \meta{logical\_expression}
  212. \end{Syntax}
  213. \begin{Syntax}
  214. \name{<<}\meta{statement}\{; \meta{statement} \name{or}
  215. \$\meta{statement}\}\optional \name{>>}
  216. \end{Syntax}
  217. \end{verbatim}
  218. \subsubsection{Examples Context}
  219. This section gives prototypical application examples. The text here has to
  220. follow a special format where the line breaks in the input are unimportant
  221. (except in the multiline option):
  222. \begin{enumerate}
  223. \item Each example must be terminated by a double backslash. This signals
  224. that the next example starts (which should begin on the next line) or that
  225. the last example is complete.
  226. \item An example starts with the input line. This will be printed in
  227. verbatim style with fixed font.
  228. \item If the example has an associated output, this is started by an
  229. ampersand (\verb|&|) character. The output must be either coded as \TeX{}
  230. math line with restricted math facilities, using only
  231. \begin{itemize}
  232. \item \verb|^| for raised exponents and
  233. \item \verb|\rfrac| for fractions (similar to \verb|\frac| in \TeX{}),
  234. \end{itemize}
  235. or the output may be a sequence of several lines that are then printed in
  236. verbatim style. In the second case the lines must be enclosed in a pair
  237. \verb|\begin{multilineoutput}| \verb|\end{multilineoutput}|.
  238. \end{enumerate}
  239. Informal guidelines:
  240. Write short examples. Take into account that the space is very restricted
  241. when using an online help system. In particular, the lines are rather short.
  242. Examples:
  243. \begin{verbatim}
  244. \begin{Examples}
  245. alist := \{1,2,\{a,b\}\}; & ALIST := \{1,2,\{A,B\}\} \\
  246. blist := \{3,4,5,sin(y)\}; & BLIST := \{3,4,5,SIN(Y)\} \\
  247. append(alist,blist); & \{1,2,\{A,B\},3,4,5,SIN(Y)\} \\
  248. append(alist,\{\}); & \{1,2,\{A,B\}\} \\
  249. append(list z,blist); & \{Z,3,4,5,SIN(Y)\}
  250. \end{Examples}
  251. \begin{Examples}
  252. solve(log(sin(x+3)),x); &
  253. \begin{multilineoutput}{6cm}
  254. 4*arbint(1)*pi + pi - 6 4*arbint(1)*pi + pi - 6
  255. \{x=-------------------------,x=-------------------------\}
  256. 2 2
  257. \end{multilineoutput}
  258. \end{Examples}
  259. \end{verbatim}
  260. \section{\LaTeX{} Translation}
  261. This should not cause any difficulties as long as the style files accessible.
  262. \section{Help System Transformation}
  263. In the \REDUCE library a set of utilities is available that allow you to
  264. transform a reference style input file into an input to a target system.
  265. These are source files in \REDUCE syntax, and you need a \REDUCE 3.5 or later
  266. executable to use these. At present the source files are
  267. \begin{itemize}
  268. \item comphelp.red: driver and input analysis,
  269. \item helpwin.red: output for MS Windows syntax
  270. \item helpunx.tex: output for GNU Info format
  271. \item minitex.red: formula formatting
  272. \end{itemize}
  273. First you must compile these using the script file $compile$. The result
  274. will be binaries $cmphelpu.b$ and $cmphelpw.b$. For running these use
  275. scripts $mkhelpu$ or $mkhelpw$ that take the name of the input file as
  276. argument. This file may contain \verb|\include| or \verb|\input| statements
  277. for secondary sources. During processing a list of sections and nodes is
  278. printed to the standard output. The conversion process stops if a context
  279. error is found - then the actual context hierarchy is printed. When the
  280. analysis phase has been successful, in a second phase the target file is
  281. generated. This is either a file $*.x$ (Info), to be further processed by
  282. the GNU makeinfo, or a file $*.rtf$ that is input for the Microsoft help
  283. compiler HC.
  284. \end{document}