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: 4183461[1X1 [33X[0;0YGetting started using [5XAutoDoc[105X[101X[1X[133X[101X23[33X[0;0Y[5XAutoDoc[105X is a [5XGAP[105X package which is meant to aid [5XGAP[105X package authors in4creating and maintaining the documentation of their packages. In this5capacity it builds upon [5XGAPDoc[105X, and is not a replacement for [5XGAPDoc[105X, but6rather complements it.[133X78[33X[0;0YIn this chapter we describe how to get started using [5XAutoDoc[105X for your9package. First, we explain in Section [14X1.1[114X how to write a new package manual10from scratch.[133X1112[33X[0;0YThen we show in Section [14X1.3[114X how you might benefit from [5XAutoDoc[105X even if you13already have a complete manual written using [5XGAPDoc[105X.[133X1415[33X[0;0YIn Section [14X1.4[114X, we explain how you may use [5XAutoDoc[105X to generate a title page16and the main XML file for your manual.[133X1718[33X[0;0YFinally, Section [14X1.5[114X, explains what [5XAutoDoc[105X worksheets are and how to use19them.[133X202122[1X1.1 [33X[0;0YCreating a package manual from scratch[133X[101X2324[33X[0;0YSuppose your package is already up and running, but so far has no manual.25Then you can rapidly generate a [21Xscaffold[121X for a package manual using the26[2XAutoDoc[102X ([14X4.1-1[114X) command like this, while running [5XGAP[105X from within your27package's directory (the one containing the [11XPackageInfo.g[111X file):[133X2829[4X[32X[104X30[4XLoadPackage( "AutoDoc" );[104X31[4XAutoDoc( rec( scaffold := true ) );[104X32[4X[32X[104X3334[33X[0;0YThis first reads the [11XPackageInfo.g[111X file from the current directory. It35extracts information about package from it (such as its name and version,36see Section [14X1.4-1[114X). It then creates two XML files37[11Xdoc/NAME_OF_YOUR_PACKAGE.xml[111X and [11Xdoc/title.xml[111X insider the package38directory. Finally, it runs [5XGAPDoc[105X on them to produce a nice initial PDF and39HTML version of your fresh manual.[133X4041[33X[0;0YTo ensure that the [5XGAP[105X help system picks up your package manual, you should42also add something like the following to your [11XPackageInfo.g[111X:[133X4344[4X[32X[104X45[4XPackageDoc := rec([104X46[4X BookName := ~.PackageName,[104X47[4X ArchiveURLSubset := ["doc"],[104X48[4X HTMLStart := "doc/chap0.html",[104X49[4X PDFFile := "doc/manual.pdf",[104X50[4X SixFile := "doc/manual.six",[104X51[4X LongTitle := ~.Subtitle,[104X52[4X),[104X53[4X[32X[104X5455[33X[0;0YCongratulations, your package now has a minimal working manual. Of course it56will be mostly empty for now, but it already should contain some useful57information, based on the data in your [11XPackageInfo.g[111X. This includes your58package's name, version and description as well as information about its59authors. And if you ever change the package data, (e.g. because your email60address changed), just re-run the above command to regenerate the two main61XML files with the latest information.[133X6263[33X[0;0YNext of course you need to provide actual content (unfortunately, we were64not yet able to automate [13Xthat[113X for you, more research on artificial65intelligence is required). To add more content, you have several options:66You could add further [5XGAPDoc[105X XML files containing extra chapters, sections67and so on. Or you could use classic [5XGAPDoc[105X source comments (in either case,68see Section [14X1.3[114X on how to teach the [2XAutoDoc[102X ([14X4.1-1[114X) command to include this69extra documentation). Or you could use the special documentation facilities70[5XAutoDoc[105X provides (see Section [14X1.2[114X).[133X7172[33X[0;0YYou will probably want to re-run the [2XAutoDoc[102X ([14X4.1-1[114X) command frequently,73e.g. whenever you modified your documentation or your [11XPackageInfo.g[111X. To make74this more convenient and reproducible, we recommend putting its invocation75into a file [11Xmakedoc.g[111X in your package directory, with content based on the76following example:[133X7778[4X[32X[104X79[4XLoadPackage( "AutoDoc" );[104X80[4XAutoDoc( rec( autodoc := true ) );[104X81[4XQUIT;[104X82[4X[32X[104X8384[33X[0;0YThen you can regenerate the package manual from the command line with the85following command, executed from within in the package directory:[133X8687[4X[32X[104X88[4Xgap makedoc.g[104X89[4X[32X[104X909192[1X1.2 [33X[0;0YDocumenting code with [5XAutoDoc[105X[101X[1X[133X[101X9394[33X[0;0YTo get one of your global functions, operations, attributes etc. to appear95in the package manual, simply insert an [5XAutoDoc[105X comment of the form [10X#![110X96directly in front of it. For example:[133X9798[4X[32X[104X99[4X#![104X100[4XDeclareOperation( "ToricVariety", [ IsConvexObject ] );[104X101[4X[32X[104X102103[33X[0;0YThis tiny change is already sufficient to ensure that the operation appears104in the manual. In general, you will want to add further information about105the operation, such as in the following example:[133X106107[4X[32X[104X108[4X#! @Arguments conv[104X109[4X#! @Returns a toric variety[104X110[4X#! @Description[104X111[4X#! Creates a toric variety out[104X112[4X#! of the convex object <A>conv</A>.[104X113[4XDeclareOperation( "ToricVariety", [ IsConvexObject ] );[104X114[4X[32X[104X115116[33X[0;0YFor a thorough description of what you can do with [5XAutoDoc[105X documentation117comments, please refer to chapter [14X2[114X.[133X118119[33X[0;0YSuppose you have not been using [5XGAPDoc[105X before but instead used the process120described in section [14X1.1[114X to create your manual. Then the following [5XGAP[105X121command will regenerate the manual and automatically include all newly122documented functions, operations etc.:[133X123124[4X[32X[104X125[4XLoadPackage( "AutoDoc" );[104X126[4XAutoDoc( rec( scaffold := true,[104X127[4X autodoc := true ) );[104X128[4X[32X[104X129130[33X[0;0YIf you are not using the scaffolding feature, e.g. because you already have131an existing [5XGAPDoc[105X based manual, then you can still use [5XAutoDoc[105X132documentation comments. Just make sure to first edit the main XML file of133your documentation, and insert the line[133X134135[4X[32X[104X136[4X#Include SYSTEM "_AutoDocMainFile.xml"[104X137[4X[32X[104X138139[33X[0;0Yin a suitable place. This means that you can mix [5XAutoDoc[105X documentation140comment freely with your existing documentation; you can even still make use141of any existing [5XGAPDoc[105X documentation comments in your code. The following142command should be useful for you in this case; it still scans the package143code for [5XAutoDoc[105X documentation comments and the runs [5XGAPDoc[105X to produce HTML144and PDF output, but does not touch your documentation XML files otherwise.[133X145146[4X[32X[104X147[4XLoadPackage( "AutoDoc" );[104X148[4XAutoDoc( rec( autodoc := true ) );[104X149[4X[32X[104X150151152[1X1.3 [33X[0;0YUsing [5XAutoDoc[105X[101X[1X in an existing [5XGAPDoc[105X[101X[1X manual[133X[101X153154[33X[0;0YEven if you already have an existing [5XGAPDoc[105X manual, it might be interesting155for you to use [5XAutoDoc[105X for two purposes:[133X156157[33X[0;0YFirst off, with [5XAutoDoc[105X is very convenient to regenerate your documentation.[133X158159[33X[0;0YSecondly, the scaffolding feature which generates a title package with all160the metadata of your package in a uniform way is very handy. The somewhat161tedious process of keeping your title page in sync with your [11XPackageInfo.g[111X162is fully automated this way (including the correct version, release data,163author information and so on).[133X164165[33X[0;0YThere are various examples of packages using [5XAutoDoc[105X for only this purpose,166e.g. [5XIO[105X and [5Xorb[105X.[133X167168169[1X1.3-1 [33X[0;0YUsing [5XAutoDoc[105X[101X[1X on a complete [5XGAPDoc[105X[101X[1X manual[133X[101X170171[33X[0;0YSuppose you already have a complete XML manual, with some main and title XML172files and some documentation for operations distributed over all your [11X.g[111X,173[11X.gd[111X, and [11X.gi[111X files. Suppose the main XML file is named [11XPACKAGENAME.xml[111X and174is in the [11X/doc[111X subfolder of your package. Then you can rebuild your manual175by executing the following two GAP commands from a GAP sessions started176started in the root directory of your package:[133X177178[4X[32X[104X179[4XLoadPackage( "AutoDoc" );[104X180[4XAutoDoc( );[104X181[4X[32X[104X182183[33X[0;0YIn contrast, the [5XRingsForHomalg[105X currently uses essentially the following184code in its [11Xmakedoc.g[111X file to achieve the same result[133X185186[4X[32X[104X187[4XLoadPackage( "GAPDoc" );[104X188[4XSetGapDocLaTeXOptions( "utf8" );[104X189[4Xbib := ParseBibFiles( "doc/RingsForHomalg.bib" );[104X190[4XWriteBibXMLextFile( "doc/RingsForHomalgBib.xml", bib );[104X191[4Xlist := [[104X192[4X "../gap/RingsForHomalg.gd",[104X193[4X "../gap/RingsForHomalg.gi",[104X194[4X "../gap/Singular.gi",[104X195[4X "../gap/SingularBasic.gi",[104X196[4X "../examples/RingConstructionsExternalGAP.g",[104X197[4X "../examples/RingConstructionsSingular.g",[104X198[4X "../examples/RingConstructionsMAGMA.g",[104X199[4X "../examples/RingConstructionsMacaulay2.g",[104X200[4X "../examples/RingConstructionsSage.g",[104X201[4X "../examples/RingConstructionsMaple.g",[104X202[4X ];[104X203[4XMakeGAPDocDoc( "doc", "RingsForHomalg", list, "RingsForHomalg" );[104X204[4XGAPDocManualLab( "RingsForHomalg" );[104X205[4X[32X[104X206207[33X[0;0YNote that in particular, you do not have to worry about keeping a list of208your implementation files up-to-date.[133X209210[33X[0;0YBut there is more. [5XAutoDoc[105X can create a [11Xmaketest.g[111X file, which uses the211examples in your manual to test your package. This can be achieved via[133X212213[4X[32X[104X214[4XLoadPackage( "AutoDoc" );[104X215[4XAutoDoc( rec( maketest := true ) );[104X216[4X[32X[104X217218[33X[0;0YNow the file [11Xmaketest.g[111X appears in your package directory, and[133X219220[4X[32X[104X221[4Xgap maketest.g[104X222[4X[32X[104X223224[33X[0;0Ytest the examples from your manual.[133X225226227[1X1.3-2 [33X[0;0YSetting different [5XGAPDoc[105X[101X[1X options[133X[101X228229[33X[0;0YSometimes, the default values for the [5XGAPDoc[105X command used by [5XAutoDoc[105X may not230be suitable for your manual.[133X231232[33X[0;0YSuppose your main XML file is [13Xnot[113X named [11XPACKAGENAME.xml[111X, but rather233something else, e.g. [11Xmain.xml[111X. Then you can tell [5XAutoDoc[105X to use this file as234the main XML file via[133X235236[4X[32X[104X237[4XLoadPackage( "AutoDoc" );[104X238[4XAutoDoc( rec( gapdoc := rec( main := "main" ) ) );[104X239[4X[32X[104X240241[33X[0;0YAs explained above, by default [5XAutoDoc[105X scans all [11X.g[111X, [11X.gd[111X and [11X.gi[111X files it242can find inside of your package root directory, and in the subdirectories243[11Xgap[111X, [11Xlib[111X, [11Xexamples[111X and [11Xexamples/doc[111X as well. If you keep source files with244documentation in other directories, you can adjust the list of directories245AutoDoc scans via the [10Xscan_dirs[110X option. The following example illustrates246this by instructing [5XAutoDoc[105X to only search in the subdirectory247[11Xpackage_sources[111X of the packages root directory.[133X248249[4X[32X[104X250[4XLoadPackage( "AutoDoc" );[104X251[4XAutoDoc( rec( gapdoc := rec( scan_dirs := [ "package_source" ] ) ) );[104X252[4X[32X[104X253254[33X[0;0YYou can also specify an explicit list of files containing documentation,255which will be searched in addition to any files located within the scan256directories:[133X257258[4X[32X[104X259[4XLoadPackage( "AutoDoc" );[104X260[4XAutoDoc( rec( gapdoc := rec( files := [ "path/to/some/hidden/file.gds" ] ) ) );[104X261[4X[32X[104X262263[33X[0;0YGiving such a file does not prevent the standard [10Xscan_dirs[110X from being264scanned for other files.[133X265266[33X[0;0YNext, [5XGAPDoc[105X supports the documentation to be built with relative paths.267This means, links to manuals of other packages or the [5XGAP[105X library will not268be absolute, but relative from your documentation. This can be particularly269useful if you want to build a release tarball or move your [5XGAP[105X installation270around later. Suppose you are starting [5XGAP[105X in the root path of your package271as always, and the standard call of [2XAutoDoc[102X ([14X4.1-1[114X) will then build the272documentation in the [11Xdoc[111X subfolder of your package. From this folder, the273gap root directory has the relative path [11X../../..[111X. Then you can enable the274relative paths by[133X275276[4X[32X[104X277[4XLoadPackage( "AutoDoc" );[104X278[4XAutoDoc( rec( gapdoc := rec( gap_root_relative_path := "../../.." ) ) );[104X279[4X[32X[104X280281[33X[0;0Yor, since [11X../../..[111X is the standard option for [10Xgap_root_relative_path[110X, by[133X282283[4X[32X[104X284[4XLoadPackage( "AutoDoc" );[104X285[4XAutoDoc( rec( gapdoc := rec( gap_root_relative_path := true ) ) );[104X286[4X[32X[104X287288289[1X1.4 [33X[0;0YScaffolds[133X[101X290291292[1X1.4-1 [33X[0;0YGenerating a title page[133X[101X293294[33X[0;0YFor most (if not all) [5XGAP[105X packages, the title page of the package manual295lists information such as the release date, version, names and contact296details of the authors, and so on. All this data is also contained in your297[11XPackageInfo.g[111X, and whenever you make a change to that file, there is a risk298that you forget to update your manual to match. And even if you don't forget299it, you of course have to spend some time to adjust the manual. [5XGAPDoc[105X can300help to a degree with this via entities. Thus, you will sometimes see code301like this in [11XPackageInfo.g[111X files:[133X302303[4X[32X[104X304[4XVersion := "1.2.3",[104X305[4XDate := "20/01/2015",[104X306[4X## <#GAPDoc Label="PKGVERSIONDATA">[104X307[4X## <!ENTITY VERSION "1.2.3">[104X308[4X## <!ENTITY RELEASEDATE "20 January 2015">[104X309[4X## <!ENTITY RELEASEYEAR "2015">[104X310[4X## <#/GAPDoc>[104X311[4X[32X[104X312313[33X[0;0YHowever, it is still easy to forget both of these versions. And it doesn't314solve the problem of updating package authors addresses. Neither of these is315a big issue, of course, but there have been plenty examples in the past316where people forget either of these two things, and it can be slightly317embarrassing. It may even require you to make a new release just to fix the318issue, which in our opinion is a sad waste of your valuable time.[133X319320[33X[0;0YSo instead of worrying about manually synchronising these things, you can321instruct [5XAutoDoc[105X to generate a title page for your manual based on the322information in your [11XPackageInfo.g[111X. The following commands do just that (in323addition to building your manual), by generating a file called324[11Xdoc/title.xml[111X.[133X325326[4X[32X[104X327[4XLoadPackage( "AutoDoc" );[104X328[4XAutoDoc( rec( scaffold := rec( MainPage := false ) ) );[104X329[4X[32X[104X330331[33X[0;0YNote that this only outputs [11Xdoc/title.xml[111X but does not touch any other files332of your documentation. In particular, you need to explicitly include333[11Xdoc/title.xml[111X from your main XML file.[133X334335[33X[0;0YHowever, you can also tell [5XAutoDoc[105X to maintain the main XML file for you, in336which case this is automatic. In fact, this is the default if you enabling337scaffolding; the above example command explicitly told [5XAutoDoc[105X not to338generate a main page. More o[133X339340341[1X1.4-2 [33X[0;0YGenerating the main XML file[133X[101X342343[33X[0;0YThe following generates a main XML file for your documentation in addition344to the title page. The main XML file includes the title page by default, as345well as any documentation generated from [5XAutoDoc[105X documentation comments.[133X346347[4X[32X[104X348[4XLoadPackage( "AutoDoc" );[104X349[4XAutoDoc( rec( scaffold := true ) );[104X350[4X[32X[104X351352[33X[0;0YYou can instruct [5XAutoDoc[105X to include additional XML files by giving it a list353of filenames, as in the following example:[133X354355[4X[32X[104X356[4XLoadPackage( "AutoDoc" );[104X357[4XAutoDoc(rec([104X358[4X scaffold := rec([104X359[4X includes := [ "somefile.xml", "anotherfile.xml" ][104X360[4X )[104X361[4X));[104X362[4X[32X[104X363364[33X[0;0YFor more information, please consult the documentation of the [2XAutoDoc[102X365([14X4.1-1[114X) function.[133X366367368[1X1.4-3 [33X[0;0YWhat data is extracted from [11XPackageInfo.g[111X[101X[1X?[133X[101X369370[33X[0;0Y[5XAutoDoc[105X can extract data from [11XPackageInfo.g[111X in order to generate a title371page. Specifically, the following components of the package info record are372looked at:[133X373374[8XVersion[108X375[33X[0;6YThis is used to set the [10X<Version>[110X element of the title page, with the376string [21XVersion [121X prepended.[133X377378[8XDate[108X379[33X[0;6YThis is used to set the [10X<Date>[110X element of the title page.[133X380381[8XSubtitle[108X382[33X[0;6YThis is used to set the [10X<Subtitle>[110X element of the title page (the383[10X<Title>[110X is set to the package name).[133X384385[8XPersons[108X386[33X[0;6YThis is used to generate [10X<Author>[110X elements in the generated title387page.[133X388389[8XPackageDoc[108X390[33X[0;6YThis is a record (or a list of records) which is used to tell the [5XGAP[105X391help system about the package manual. Currently [5XAutoDoc[105X extracts the392value of the [10XPackageDoc.BookName[110X component and then passes that on to393[5XGAPDoc[105X when creating the HTML, PDF and text versions of the manual.[133X394395[8XAutoDoc[108X396[33X[0;6YThis is a record which can be used to control the scaffolding397performed by [5XAutoDoc[105X, specifically to provide extra information for398the title page. For example, you can set [10XAutoDoc.TitlePage.Copyright[110X399to a string which will then be inserted on the generated title page.400Using this method you can customize the following title page elements:401[10XTitleComment[110X, [10XAbstract[110X, [10XCopyright[110X, [10XAcknowledgements[110X and [10XColophon[110X.[133X402403[33X[0;6YNote that [10XAutoDoc.TitlePage[110X behaves exactly the same as the404[10Xscaffold.TitlePage[110X parameter of the [2XAutoDoc[102X ([14X4.1-1[114X) function.[133X405406407[1X1.5 [33X[0;0YAutoDoc worksheets[133X[101X408409[33X[0;0Y[5XAutoDoc[105X worksheets can be used to create HTML and PDF documents using410AutoDoc syntax and possibly including [5XGAP[105X examples and implementations411without having them associated to a package. A file for a worksheet could412look like this:[133X413414[4X[32X[104X415[4X#! @Title My first worksheet[104X416[4X#! @Author Charlie Brown[104X417[4X[104X418[4X#! @Chapter Some groups[104X419[4X[104X420[4X#! @BeginExample[104X421[4XS3 := SymmetricGroup( 3 );;[104X422[4XS4 := SymmetricGroup( 4 );;[104X423[4X#! @EndExample[104X424[4X[32X[104X425426[33X[0;0YNow, one can create a PDF and HTML document, like a package documentation427out of it. Suppose the document above is saved as [11Xworksheet.g[111X. Then, when428GAP is started in the folder of this file, the command[133X429430[4X[32X[104X431[4XAutoDocWorksheet( "worksheet.g" );[104X432[4X[32X[104X433434[33X[0;0Ywill create a subfolder called [11Xdoc[111X of the current directory in which it will435create the documentation. There are several options to configure the output436of the worksheet command, which are identical to the options of the [2XAutoDoc[102X437([14X4.1-1[114X) command. It is even possible to test the examples in the worksheet438using the maketest option from the AutoDoc command.[133X439440[33X[0;0YSince the worksheets do not have a [11XPackageInfo.g[111X to extract information, all441possible tags that [5XGAPDoc[105X supports for the title page can be set into the442document. A fully typed title page can look like this:[133X443444[4X[32X[104X445[4X#! @Title My first worksheet[104X446[4X#! @Subtitle Some small examples[104X447[4X#! @Author Charlie Brown[104X448[4X[104X449[4X#! @Version 0.1[104X450[4X#! @TitleComment Some worksheet[104X451[4X#! @Date 01/01/2016[104X452[4X#! @Address TU Kaiserslautern[104X453[4X#! @Abstract[104X454[4X#! A worksheet showing some small examples about groups.[104X455[4X#! @Copyright 2016 Charlie Brown[104X456[4X#! @Acknowledgements Woodstock[104X457[4X#! @Colophon Some colophon[104X458[4X[104X459[4X#! @Chapter Some groups[104X460[4X[104X461[4X#! @BeginExample[104X462[4XS3 := SymmetricGroup( 3 );;[104X463[4XS4 := SymmetricGroup( 4 );;[104X464[4X#! @EndExample[104X465[4X[32X[104X466467468469