Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346<Chapter Label="Distributing">1<Heading>Distributing a Document into Several Files</Heading>23In &GAPDoc; there are facilities to distribute a single document over4several files. This is for example interesting, if one wants to store the5documentation of some code in the same file as the code itself. Or, if one6just wants to store chapters of a document in separate files. There is7a set of conventions how this is done and some tools to collect the text8for further processing. <P/>910The technique can also be used to distribute and collect other types of11documents into respectively from several files (e.g., source code, examples).12<P/>1314<Section Label="DistrConv">15<Index Key="Include"><C><#Include></C></Index>16<Index Key="GAPDoc"><C><#GAPDoc></C></Index>1718<Heading>The Conventions</Heading>1920In this description we use the string <C>GAPDoc</C> for marking pieces21of a document to collect.22<P/>2324Pieces of documentation that shall be incorporated into another document25are marked as follows:2627<Listing Type="Example">28<![CDATA[## <#GAPDoc Label="MyPiece">29## <E>This</E> is the piece.30## The hash characters are removed.31## <#/GAPDoc>]]>32</Listing>3334This piece is then included into another file by a statement like:35<!-- <Listing Type="Example"> -->36<C><#Include Label="MyPiece"></C>37<!--</Listing> -->3839Here are the exact rules, how pieces are gathered:4041<List>42<Item>43All lines up to a line containing the character sequence44<Q><C><#GAPDoc Label="</C></Q> (exactly one space45character) are ignored. The characters46on the same line before this sequence are stored as <Q>prefix</Q>.47The characters after the sequence up to the next double quotes character48(which should not contain whitespace) are stored as <Q>label</Q>.49All other characters in the line are ignored.50</Item>5152<Item>53The following lines up to a line containing the character sequence54<Q><C><#/GAPDoc></C></Q> are stored under the label.55These lines are processed as follows: The longest possible56substring from the beginning of the line that equals the corresponding57substring of the prefix is removed.58</Item>59</List>6061Having stored a list of labels and pieces of text gathered as above this can62be used as follows.6364<List>65<Item>66In &GAPDoc; documentation files all statements67of the form <Q><C><#Include Label="Key"></C></Q> are68replaced by the69sequence of lines stored under the label <C>Key</C>.70</Item>7172<Item>73Additionally, every occurrence of a statement of the form74<Q><C><#Include SYSTEM "Filename"></C></Q> is replaced by the75whole file stored under the name <C>Filename</C> in the file system.76</Item>7778<Item>79These substitutions are done recursively (although one should probably avoid to use this extensively).80</Item>81</List>8283Here is another example:8485<Listing Type="Example">86<![CDATA[# # <#GAPDoc Label="AnotherPiece"> some characters87# # This text is not indented.88# This text is indented by one blank.89#Not indented.90#<#/GAPDoc>]]>91</Listing>9293replaces <C><#Include Label="AnotherPiece"></C> by9495<Listing Type="Example">96<![CDATA[This text is not indented.97This text is indented by one blank.98Not indented.]]>99</Listing>100101Since these rules are very simple it is quite easy to write a program in102almost any programming language which does this gathering of text pieces103and the substitutions. In &GAPDoc; there is the &GAP; function <Ref104Func="ComposedDocument"/> which does this.<P/>105106Note that the XML-tag-like markup we have used here is not a legal XML107markup, since the hash character is not allowed in element names. The108mechanism described here is a preprocessing step which composes a109document.110111</Section>112113<Section >114<Heading>A Tool for Collecting a Document</Heading>115116<#Include Label="ComposedDocument">117118<#Include Label="OriginalPositionDocument">119120<#Include Label="FilenameGAP">121122</Section>123124</Chapter>125126127128