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="Comments">1<Heading>&AutoDoc; documentation comments</Heading>23You can document declarations of global functions and variables, operations,4attributes etc. by inserting <E>&AutoDoc;</E> comments into your sources before these declaration.5An &AutoDoc; comment always starts with <C>#!</C>. This is also the smallest possible6&AutoDoc; command. If you want your declaration documented, just write7<C>#!</C> at the line before the documentation. For example:89<Listing><![CDATA[10#!11DeclareOperation( "AnOperation",12[ IsList ] );13]]></Listing>1415This will produce a manual entry for the operation <C>AnOperation</C>.16<P/>1718Inside of &AutoDoc; comments, <E>&AutoDoc; commands</E>19starting with <C>@</C> can be used to control the output &AutoDoc; produces.202122<Section>23<Heading>Documenting declarations</Heading>2425In the bare form above, the manual entry for <C>AnOperation</C> will not26contain much more than the name of the operation. In order to change27this, there are several commands you can put into the &AutoDoc; comment28before the declaration. Currently, the following commands are provided:2930<Subsection Label="@Description">31<Index Key="@Description"><C>@Description</C></Index>32<Heading>@Description <A>descr</A></Heading>33Adds the text in the following lines of the &AutoDoc; to the description34of the declaration in the manual. Lines are until the next &AutoDoc; command35or until the declaration is reached.36</Subsection>3738<Subsection Label="@Returns">39<Index Key="@Returns"><C>@Returns</C></Index>40<Heading>@Returns <A>ret_val</A></Heading>41The string <A>ret_val</A> is added to the documentation, with the text <Q>Returns: </Q>42put in front of it. This should usually give a brief hint about the type or meaning43of the value retuned by the documented function.44</Subsection>4546<Subsection Label="@Arguments">47<Index Key="@Arguments"><C>@Arguments</C></Index>48<Heading>@Arguments <A>args</A></Heading>49The string <A>args</A> contains a description of the arguments the50function expects, including optional parts, which are denoted by square51brackets. The argument names can be separated by whitespace, commas or52square brackets for the optional arguments, like <Q>grp[, elm]</Q> or53<Q>xx[y[z] ]</Q>. If &GAP; options are used, this can be followed by a colon :54and one or more assignments, like <Q>n[, r]: tries := 100</Q>.55</Subsection>5657<Subsection Label="@Group">58<Index Key="@Group"><C>@Group</C></Index>59<Heading>@Group <A>grpname</A></Heading>60Adds the following method to a group with the given name.61See section <Ref Sect="Groups"/> for more information about groups.62</Subsection>6364<Subsection Label="@Label">65<Index Key="@Label"><C>@Label</C></Index>66<Heading>@Label <A>label</A></Heading>67Adds label to the function as label.6869If this is not specified, then for declarations that involve a list of input filters70(as is the case for <C>DeclareOperation</C>, <C>DeclareAttribute</C>, etc.),71a default label is generated from this filter list.72</Subsection>7374<Listing><![CDATA[75#! @Label testlabel76DeclareProperty( "AProperty",77IsObject );78]]></Listing>79leads to this:80<ManSection>81<Prop Arg="arg" Name="AProperty" Label="testlabel"/>82<Returns> <C>true</C> or <C>false</C>83</Returns>84<Description>85</Description>86</ManSection>87while88<Listing><![CDATA[89#!90DeclareProperty( "AProperty",91IsObject );92]]></Listing>93leads to this:94<ManSection>95<Prop Arg="arg" Name="AProperty" Label="for IsObject"/>96<Returns> <C>true</C> or <C>false</C>97</Returns>98<Description>99</Description>100</ManSection>101102103<Subsection Label="@ChapterInfo">104<Index Key="@ChapterInfo"><C>@ChapterInfo</C></Index>105<Heading>@ChapterInfo <A>chapter, section</A></Heading>106Adds the entry to the given chapter and section. Here,107<A>chapter</A> and <A>section</A> are the respective108titles.109</Subsection>110111112As an example, a full &AutoDoc; comment for with all options could look like this:113114<Listing><![CDATA[115#! @Description116#! Computes the list of lists of degrees of ordinary characters117#! associated to the <A>p</A>-blocks of the group <A>G</A>118#! with <A>p</A>-modular character table <A>modtbl</A>119#! and underlying ordinary character table <A>ordtbl</A>.120#! @Returns a list121#! @Arguments modtbl122#! @Group CharacterDegreesOfBlocks123#! @FunctionLabel chardegblocks124#! @ChapterInfo Blocks, Attributes125DeclareAttribute( "CharacterDegreesOfBlocks",126IsBrauerTable );127]]></Listing>128129</Section>130131<Section>132<Heading>Other documentation comments</Heading>133134There are also some commands which can be used in &AutoDoc; comments135that are not associated to any declaration. This is useful for additional136text in your documentation, examples, mathematical chapters, etc..137138<Subsection Label="@Chapter">139<Index Key="@Chapter"><C>@Chapter</C></Index>140<Index Key="@ChapterLabel"><C>@ChapterLabel</C></Index>141<Heading>@Chapter <A>name</A></Heading>142Sets a chapter, all functions without separate info will be added to this chapter.143Also all text comments, i.e. lines that begin with #! without a command, and which do not144follow after @description, will be added to the chapter as regular text.145146Example:147148<Listing><![CDATA[149#! @Chapter My chapter150#! This is my chapter.151#! I document my stuff in it.152]]></Listing>153154The <C>@ChapterLabel</C> <A>label</A> command155can be used to set the label of the chapter to <C>Chapter_</C><A>label</A>.156157Additionally, the chapter will be stored as <C>_Chapter_</C><A>label</A><C>.xml</C>.158159160</Subsection>161162<Subsection Label="@Section">163<Index Key="@Section"><C>@Section</C></Index>164<Index Key="@SectionLabel"><C>@SectionLabel</C></Index>165<Heading>@Section <A>name</A></Heading>166Sets a section like chapter sets a chapter.167168<Listing><![CDATA[169#! @Section My first manual section170#! In this section I am going to document my first method.171]]></Listing>172173The <C>@SectionLabel</C> <A>label</A> command174can be used to set the label of the section to <C>Section_</C><A>label</A>.175</Subsection>176177<Subsection Label="@EndSection">178<Index Key="@EndSection"><C>@EndSection</C></Index>179<Heading>@EndSection</Heading>180Closes the current section. Please be careful here. Closing a section before181opening it might cause unexpected errors.182183<Listing><![CDATA[184#! @EndSection185#### The following text again belongs to the chapter186#! Now we could start a second section if we want to.187]]></Listing>188</Subsection>189190<Subsection Label="@Subsection">191<Index Key="@Subsection"><C>@Subsection</C></Index>192<Index Key="@SubsectionLabel"><C>@SubsectionLabel</C></Index>193<Heading>@Subsection <A>name</A></Heading>194Sets a subsection like chapter sets a chapter.195196<Listing><![CDATA[197#! @Subsection My first manual subsection198#! In this subsection I am going to document my first example.199]]></Listing>200201The <C>@SubsectionLabel</C> <A>label</A> command202can be used to set the label of the subsection to <C>Subsection_</C><A>label</A>.203204</Subsection>205206<Subsection Label="@EndSubsection">207<Index Key="@EndSubsection"><C>@EndSubsection</C></Index>208<Heading>@EndSubsection</Heading>209Closes the current subsection. Please be careful here. Closing a subsection before210opening it might cause unexpected errors.211<Listing><![CDATA[212#! @EndSubsection213#### The following text again belongs to the section214#! Now we are in the section again215]]></Listing>216</Subsection>217218<Subsection Label="@BeginAutoDoc">219<Index Key="@BeginAutoDoc"><C>@BeginAutoDoc</C></Index>220<Heading>@BeginAutoDoc</Heading>221Causes all subsequent declarations to be documented in the manual,222regardless of whether they have an &AutoDoc; comment in front of223them or not.224</Subsection>225226<Subsection Label="@EndAutoDoc">227<Index Key="@EndAutoDoc"><C>@EndAutoDoc</C></Index>228<Heading>@EndAutoDoc</Heading>229Ends the affect of <C>@BeginAutoDoc</C>. So from here on, again only declarations230with an explicit &AutoDoc; comment in front are added to the manual.231232<Listing><![CDATA[233#! @BeginAutoDoc234235DeclareOperation( "Operation1", [ IsList ] );236237DeclareProperty( "IsProperty", IsList );238239#! @EndAutoDoc240]]></Listing>241Both, <C>Operation1</C> and <C>IsProperty</C> would appear in the manual.242</Subsection>243244<Subsection Label="@BeginGroup">245<Index Key="@BeginGroup"><C>@BeginGroup</C></Index>246<Heading>@BeginGroup <A>[grpname]</A></Heading>247Starts a group. All following documented declarations without an248explicit <C>@Group</C> command are grouped together in the same group249with the given name. If no name is given, then a new nameless group is250generated.251The effect of this command is ended when an <C>@EndGroup</C> command252is reached.253<P/>254255See section <Ref Sect="Groups"/> for more information about groups.256</Subsection>257258<Subsection Label="@EndGroup">259<Index Key="@EndGroup"><C>@EndGroup</C></Index>260<Heading>@EndGroup</Heading>261Ends the current group.262263<Listing><![CDATA[264#! @BeginGroup MyGroup265#!266DeclareAttribute( "GroupedAttribute",267IsList );268269DeclareOperation( "NonGroupedOperation",270[ IsObject ] );271272#!273DeclareOperation( "GroupedOperation",274[ IsList, IsRubbish ] );275#! @EndGroup276]]></Listing>277</Subsection>278279<Subsection Label="@Level">280<Index Key="@Level"><C>@Level</C></Index>281<Heading>@Level <A>lvl</A></Heading>282Sets the current level of the documentation. All items created after this,283chapters, sections, and items, are given the level <A>lvl</A>,284until the <C>@ResetLevel</C> command resets the level to 0 or another level285is set.286<P/>287288See section <Ref Sect="Level"/> for more information about groups.289</Subsection>290291<Subsection Label="@ResetLevel">292<Index Key="@ResetLevel"><C>@ResetLevel</C></Index>293<Heading>@ResetLevel</Heading>294Resets the current level to 0.295<P/>296</Subsection>297298299<Subsection Label="@BeginExample">300<Index Key="@BeginExample"><C>@BeginExample and @EndExample</C></Index>301<Heading>@BeginExample and @EndExample</Heading>302@BeginExample inserts an example into the manual. The syntax for examples is different from303GAPDocs example syntax in order to have a304file that contains the example and is GAP readable. To achieve this, GAP commands are not preceded by a comment,305while output has to be preceded by an &AutoDoc; comment.306The GAP prompt for the display in the manual is added by AutoDoc.307@EndExample ends the example block.308<Listing><![CDATA[309#! @BeginExample310S5 := SymmetricGroup(5);311#! Sym( [ 1 .. 5 ] )312Order(S5);313#! 120314#! @EndExample315]]></Listing>316</Subsection>317318319<Subsection Label="@ExampleSession">320<Index Key="@ExampleSession"><C>@ExampleSession, @BeginExampleSession, and @EndExampleSession</C></Index>321<Heading>@ExampleSession and @EndExampleSession</Heading>322@ExampleSession inserts an example into the manual, but in a different syntax.323For example, consider324<Listing><![CDATA[325#! @BeginExample326S5 := SymmetricGroup(5);327#! Sym( [ 1 .. 5 ] )328Order(S5);329#! 120330#! @EndExample331]]></Listing>332As you can see, the commands are not commented and hence are executed when the file containing333the example block is read. To insert examples directly into source code files, one can instead334use @ExampleSession:335<Listing><![CDATA[336#! @ExampleSession337#! gap> S5 := SymmetricGroup(5);338#! Sym( [ 1 .. 5 ] )339#! gap> Order(S5);340#! 120341#! @EndExampleSession342]]></Listing>343It inserts an example into the manual just as @Example would do, but all lines are commented344and therefore not executed when the file is read.345</Subsection>346347348349<Subsection Label="@BeginLog">350<Index Key="@BeginLog"><C>@BeginLog and @EndLog</C></Index>351<Heading>@BeginLog and @EndLog</Heading>352Works just like the @BeginExample command, but the example353will not be tested. See the GAPDoc manual for more information.354</Subsection>355356<Subsection Label="@BeginLogSession">357<Index Key="@BeginLogSession"><C>@BeginLogSession and @EndLogSession</C></Index>358<Heading>@BeginLogSession and @EndLogSession</Heading>359Works just like the @BeginExampleSession command, but the example360will not be tested if manual examples are run. See the GAPDoc manual for more information.361</Subsection>362363<Subsection Label="@DoNotReadRestOfFile">364<Index Key="DoNotReadRestOfFile"><C>@DoNotReadRestOfFile</C></Index>365<Heading>@DoNotReadRestOfFile</Heading>366Prevents the rest of the file from being read by the parser. Useful for367not finished or temporary files.368369<Listing><![CDATA[370#! This will appear in the manual371372#! @DoNotReadRestOfFile373374#! This will not appear in the manual.375]]></Listing>376</Subsection>377378<Subsection Label="@BeginChunk">379<Index Key="@BeginChunk"><C>@BeginChunk, @EndChunk, and @InsertChunk</C></Index>380<Heading>@BeginChunk <A>name</A>, @EndChunk, and @InsertChunk <A>name</A></Heading>381Text insider of a @BeginChunk / @EndChunk part will not be inserted into382the final documentation directly. Instead, the text is stored in an internal buffer.383384That chunk of text can then later on be inserted in any other place by using the385@InsertChunk <A>name</A> command.386387If you do not provide an @EndChunk, the chunk ends at the end of the file.388<Listing><![CDATA[389#! @BeginChunk MyChunk390#! Hello, world.391#! @EndChunk392393#! @InsertChunk MyChunk394## The text "Hello, world." is inserted right before this.395]]></Listing>396397You can use this to define an example like this in one file:398399<Listing><![CDATA[400#! @BeginChunk Example_Symmetric_Group401#! @BeginExample402S5 := SymmetricGroup(5);403#! Sym( [ 1 .. 5 ] )404Order(S5);405#! 120406#! @EndExample407#! @EndChunk408]]></Listing>409410And then later, insert the example in a different file, like this:411412<Listing><![CDATA[413#! @InsertChunk Example_Symmetric_Group414]]></Listing>415416</Subsection>417418<Subsection Label="@BeginSystem">419<Index Key="@BeginSystem"><C>@BeginSystem, @EndSystem, and @InsertSystem</C></Index>420<Heading>@BeginSystem <A>name</A>, @EndSystem, and @InsertSystem <A>name</A></Heading>421Same as @BeginChunk etc. This command is deprecated. Please use chunk instead.422</Subsection>423424<Subsection Label="@BeginCode">425<Index Key="@BeginCode"><C>@BeginCode, @EndCode, and @InsertCode</C></Index>426<Heading>@BeginCode <A>name</A>, @EndCode, and @InsertCode <A>name</A></Heading>427Inserts the text between @BeginCode and @EndCode verbatim at the point where428@InsertCode is called. This is useful to insert code excerpts429directly into the manual.430<Listing><![CDATA[431#! @BeginCode Increment432i := i + 1;433#! @EndCode434435#! @InsertCode Increment436## Code is inserted here.437]]></Listing>438</Subsection>439440<Subsection Label="@LatexOnly">441<Index Key="@LatexOnly"><C>@@LatexOnly, @BeginLatexOnly, and @EndLatexOnly</C></Index>442<Heading>@LatexOnly <A>text</A>, @BeginLatexOnly , and @EndLatexOnly</Heading>443Code inserted between @BeginLatexOnly and @EndLatexOnly or after @LatexOnly is only inserted444in the PDF version of the manual or worksheet. It can hold arbitrary LaTeX-commands.445<Listing><![CDATA[446#! @BeginLatexOnly447#! \include{picture.tex}448#! @EndLatexOnly449450#! @LatexOnly \include{picture.tex}451]]></Listing>452</Subsection>453454</Section>455456457<Section Label="TitlepageCommands">458<Heading>Title page commands</Heading>459460The following commands can be used to add the corresponding parts to the title page of461the document, in case the scaffolding is enabled.462<List>463<Item>464@Title465</Item>466<Item>467@Subtitle468</Item>469<Item>470@Version471</Item>472<Item>473@TitleComment474</Item>475<Item>476@Author477</Item>478<Item>479@Date480</Item>481<Item>482@Address483</Item>484<Item>485@Abstract486</Item>487<Item>488@Copyright489</Item>490<Item>491@Acknowledgements492</Item>493<Item>494@Colophon495</Item>496</List>497Those add the following lines at the corresponding point of the title page. Please note that many of those498things can be (better) extracted from the PackageInfo.g. In case you set some of those,499the extracted or in scaffold defined items will be overwritten. While this is not very useful for500documenting packages, they are necessary for worksheets created with <Ref Func="AutoDocWorksheet"/>,501since they do not have a PackageInfo to extract those information.502</Section>503504<Section Label="PlainText">505<Heading>Plain text files</Heading>506507AutoDoc plain text files work exactly like AutoDoc comments, except that the508#! is unnecessary at the beginning of a line which should be documented.509Files that have the suffix .autodoc will automatically regarded as plain text files510while the commands @AutoDocPlainText and @EndAutoDocPlainText mark parts in plain text files which511should be regarded as AutoDoc parts. All commands can be used like before.512513</Section>514515<Section Label="Groups">516<Heading>Grouping</Heading>517518In &GAPDoc;, it is possible to make groups of ManItems, i.e., when documenting519a function, operation, etc., it is possible to group them into suitable chunks.520This can be particularly useful if there are several definitions of an operation521with several different argument types, all doing more or less the same to the arguments.522Then their manual items can be grouped, sharing the same description and return type information.523Note that it is currently not possible to give a header to the Group in the manual,524but the generated ManItem heading of the first entry will be used.525<P/>526527Note that group names are globally unique throughout the whole manual.528That is, groups with the same name are in fact merged into a single group, even if they529were declared in different source files.530Thus you can have multiple <C>@BeginGroup</C> / <C>@EndGroup</C> pairs using the531same group name, in different places, and these all will refer to the same group.532<P/>533534Moreover, this means that you can add items to a group via the <C>@Group</C> command535in the &AutoDoc; comment of an arbitrary declaration, at any time.536537The following code538<Listing><![CDATA[539#! @BeginGroup Group1540541#! @Description542#! First sentence.543DeclareOperation( "FirstOperation", [ IsInt ] );544545#! @Description546#! Second sentence.547DeclareOperation( "SecondOperation", [ IsInt, IsGroup ] );548549#! @EndGroup550551## .. Stuff ..552553#! @Description554#! Third sentence.555#! @Group Group1556KeyDependentOperation( "ThirdOperation", IsGroup, IsInt, "prime );557]]></Listing>558559produces the following:560561<ManSection Label="Group1">562<Oper Arg="arg" Name="FirstOperation" Label="for IsInt"/>563<Oper Arg="arg1,arg2" Name="SecondOperation" Label="for IsInt, IsGroup"/>564<Oper Arg="arg1,arg2" Name="ThirdOperation" Label="for IsGroupIsGroup, "/>565<Returns></Returns>566<Description>567First sentence.568Second sentence.569Third sentence.570</Description>571</ManSection>572573</Section>574575<Section Label="Level">576<Heading>Level</Heading>577Levels can be set to not write certain parts in the manual by default.578Every entry has by default the level 0. The command <C>@Level</C> can579be used to set the level of the following part to a higher level, for580example 1, and prevent it from being printed to the manual by default.581However, if one sets the level to a higher value in the autodoc option of582<C>AutoDoc</C>, the parts will be included in the manual at the specific place.583584<Listing><![CDATA[585#! This text will be printed to the manual.586#! @Level 1587#! This text will be printed to the manual if created with level 1 or higher.588#! @Level 2589#! This text will be printed to the manual if created with level 2 or higher.590#! @ResetLevel591#! This text will be printed to the manual.592]]></Listing>593</Section>594595<Section Label="MarkdownExtension">596<Heading>Markdown-like formatting of text in &AutoDoc;</Heading>597598&AutoDoc; has some convenient ways to insert special format into text, like599math formulas and lists. The syntax for them are inspired by Markdown and LaTeX,600but do not follow them strictly. Neither are all features of the Markdown language601supported. The following subsections describe what is possible.602603<Subsection Label="MarkdownExtensionList">604<Heading>Lists</Heading>605606One can create lists of items by beginning a new line with *, +, -, followed by one607space. The first item starts the list. When items are longer than one line, the following lines608have to be indented by at least two spaces. The list ends when a line which does not start a new609item is not indented by two spaces. Of course lists can be nested. Here is an example:610611<Listing><![CDATA[612#! The list starts in the next line613#! * item 1614#! * item 2615#! which is a bit longer616#! * and also contains a nested list617#! * with two items618#! * item 3 of the outer list619#! This does not belong to the list anymore.620]]></Listing>621622This is the output:<Br/>623The list starts in the next line624<List>625<Item>626item 1627</Item>628<Item>629item 2630which is a bit longer631<List>632<Item>633and also contains a nested list634</Item>635<Item>636with two items637</Item>638</List>639</Item>640<Item>641item 3 of the outer list642</Item>643</List>644This does not belong to the list anymore.<Br/>645646647The *, -, and + are fully interchangeable and can even be used mixed, but this is not recommended.648649</Subsection>650651<Subsection Label="MarkdownExtensionMath">652<Heading>Math modes</Heading>653654One can start an inline formula with a $, and also end it with $, just like in &LaTeX;. This will translate into655&GAPDoc;s inline math environment. For display mode one can use $$, also like &LaTeX;.656657<Listing><![CDATA[658#! This is an inline formula: $1+1 = 2$.659#! This is a display formula:660#! $$ \sum_{i=1}^n i. $$661]]></Listing>662663produces the following output:<Br/>664This is an inline formula: <Math>1+1 = 2</Math>.665This is a display formula:666<Display> \sum_{i=1}^n i. </Display>667668</Subsection>669670<Subsection Label="MarkdownExtensionEmph">671<Heading>Emphasize</Heading>672673One can emphasize text by using two asterisks (**) or two underscores (__) at the674beginning and the end of the text which should be emphasized. Example:675676<Listing><![CDATA[677#! **This** is very important.678#! This is __also important__.679#! **Naturally, more than one line680#! can be important.**681]]></Listing>682683This produces the following output:<Br/>684<E>This</E> is very important.685This is <E>also important</E>.686<E>Naturally, more than one line687can be important.</E>688689</Subsection>690</Section>691692</Chapter>693694695