Skip to content

Commit 5acf626

Browse files
fingolfincodex
andcommitted
Remove or deprecate various legacy feature
- Remove the undocumented AutoDoc package-name invocation. - Stop honoring GAP global options as overrides for normal AutoDoc options. - Keep worksheet compatibility, with a warning for legacy ':' syntax. Co-authored-by: Codex <codex@openai.com>
1 parent 3654706 commit 5acf626

10 files changed

Lines changed: 204 additions & 88 deletions

File tree

CHANGES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
This file describes changes in the AutoDoc package.
22

3+
## 2026.MM.DD
4+
5+
+ **Breaking changes**
6+
- Remove support for calling `AutoDoc()` with a package name argument
7+
- Remove support for controlling `AutoDoc()` via GAP global options
8+
corresponding to regular option-record entries such as `dir`,
9+
`scaffold`, `autodoc`, `gapdoc`, and `extract_examples`
10+
- Remove support for implicitly enabling `opt.autodoc` when a
11+
package merely declares a dependency on AutoDoc
12+
- Keep the documented `relativePath` and `nopdf` global options,
13+
and keep the legacy option-record override syntax for
14+
`AutoDocWorksheet()` for backwards compatibility while no longer
15+
recommending it
16+
317
## 2026.03.18
418
- Fix running the test suite via `TestPackage("AutoDoc")` when the
519
current working directory is not the package root

gap/AutoDocMainFunction.gd

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ DeclareGlobalFunction( "ExtractTitleInfoFromPackageInfo" );
5151
#! The purpose of this function is to create stand-alone PDF and HTML files
5252
#! using &AutoDoc; without associating them with a package.
5353
#! <P/>
54-
#! It uses the same optional record entries as <Ref Func="AutoDoc"/>, but
55-
#! instead of a package name, you pass one filename or a list of filenames
56-
#! containing &AutoDoc; text from which the document is created.
54+
#! Instead of a package directory, you pass one filename or a list of
55+
#! filenames containing &AutoDoc; text from which the document is created.
56+
#! Settings are supplied via an optional record using the same entries as
57+
#! the <A>optrec</A> argument of <Ref Func="AutoDoc"/>. Alternatively, you may
58+
#! omit <A>filenames</A> and specify the files via <C>optrec.autodoc.files</C>.
5759
#! <P/>
5860
#! A simple worksheet file can define title-page information and chapter
5961
#! content directly in the source file, including example blocks.
@@ -65,5 +67,18 @@ DeclareGlobalFunction( "ExtractTitleInfoFromPackageInfo" );
6567
#! <P/>
6668
#! Since worksheets do not have a <F>PackageInfo.g</F>, title-page fields are
6769
#! specified directly in the worksheet file.
68-
#! @Arguments list_of_filenames : options
70+
#! <P/>
71+
#! For backwards compatibility, worksheet calls still accept GAP global
72+
#! options for specifying the option-record entries such as
73+
#! <C>dir</C>, <C>scaffold</C>, <C>autodoc</C>, <C>gapdoc</C>, and
74+
#! <C>extract_examples</C>.
75+
#! However, this feature is deprecated. If its use is detected, &AutoDoc;
76+
#! prints a warning recommending the explicit options record instead.
77+
#! For example:
78+
#! @BeginLogSession
79+
#! gap> AutoDocWorksheet( : autodoc := rec( files := ["worksheet.g"] ) );
80+
#! #W AutoDocWorksheet: legacy ':' syntax is deprecated; use optrec instead
81+
#! ...
82+
#! @EndLogSession
83+
#! @Arguments [filenames,] [optrec]
6984
DeclareGlobalFunction( "AutoDocWorksheet" );

gap/AutoDocMainFunction.gi

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -323,37 +323,52 @@ end );
323323
##
324324
InstallGlobalFunction( AutoDocWorksheet,
325325
function( arg )
326-
local autodoc_rec, scaffold_rec;
327-
328-
if Length( arg ) = 1 then
329-
arg[ 2 ] := rec( );
330-
fi;
331-
332-
scaffold_rec := ValueOption( "scaffold" );
333-
if scaffold_rec = fail then
334-
scaffold_rec := rec( );
335-
fi;
336-
AUTODOC_SetIfMissing( scaffold_rec, "index", false );
337-
338-
if Length( arg ) = 2 then
339-
autodoc_rec := ValueOption( "autodoc" );
340-
if autodoc_rec = fail then
341-
autodoc_rec := rec( );
326+
local filenames, opt, key, val, used_legacy_value_options;
327+
328+
filenames := [ ];
329+
opt := rec( );
330+
331+
if Length( arg ) > 2 then
332+
Error("too many arguments");
333+
elif Length( arg ) > 0 then
334+
if IsString( First( arg ) ) then
335+
filenames := [ First( arg ) ];
336+
elif IsList( First( arg ) ) then
337+
filenames := First( arg );
342338
fi;
343-
if IsString( arg[ 1 ] ) then
344-
arg[ 1 ] := [ arg[ 1 ] ];
339+
if IsRecord( Last( arg ) ) then
340+
opt := StructuralCopy( Last( arg ) );
345341
fi;
346-
if IsBound( autodoc_rec.files ) then
347-
Append( autodoc_rec.files, arg[ 1 ] );
348-
else
349-
autodoc_rec.files := arg[ 1 ];
342+
fi;
343+
344+
# Backwards compatibility: worksheet callers historically passed the
345+
# normal AutoDoc option-record entries via GAP value options.
346+
used_legacy_value_options := false;
347+
for key in [ "dir", "scaffold", "autodoc", "gapdoc", "extract_examples" ] do
348+
val := ValueOption( key );
349+
if val <> fail then
350+
opt.( key ) := val;
351+
used_legacy_value_options := true;
350352
fi;
351-
AutoDoc( "AutoDocWorksheet", arg[ 2 ] : autodoc := autodoc_rec, scaffold := scaffold_rec );
353+
od;
354+
355+
if used_legacy_value_options then
356+
Print(
357+
"#W AutoDocWorksheet: legacy ':' syntax is deprecated; ",
358+
"use optrec instead\n"
359+
);
352360
fi;
353361

354-
if Length( arg ) = 0 then
355-
AutoDoc( "AutoDocWorksheet" : scaffold := scaffold_rec );
362+
AUTODOC_SetIfMissing( opt, "scaffold", rec( ) );
363+
AUTODOC_SetIfMissing( opt.scaffold, "index", false );
364+
365+
if Length( filenames ) > 0 then
366+
AUTODOC_SetIfMissing( opt, "autodoc", rec( ) );
367+
AUTODOC_SetIfMissing( opt.autodoc, "files", [ ] );
368+
Append( opt.autodoc.files, filenames );
356369
fi;
370+
371+
AutoDoc( "AutoDocWorksheet", opt );
357372
end );
358373

359374
# The following function is based on code by Alexander Konovalov

gap/Magic.gd

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,16 @@
5353
#! <Item>
5454
#! The purpose of this parameter is twofold: to determine the package
5555
#! directory in which &AutoDoc; will operate, and to find the metadata
56-
#! concerning the package being documented. The parameter is either a
57-
#! string, an <C>IsDirectory</C> object, or omitted.
58-
#! If it is a string, &AutoDoc; interprets it as the name of a
59-
#! package, uses the metadata of the first package known to &GAP;
60-
#! with that name, and uses the <C>InstallationPath</C> specified in that
61-
#! metadata as the package directory. If <A>packageOrDirectory</A> is
62-
#! an <C>IsDirectory</C> object, this is used as package directory;
63-
#! if the argument is omitted, then the current directory is used.
64-
#! In the last two cases, the specified directory must contain a
56+
#! concerning the package being documented. The parameter is either an
57+
#! <C>IsDirectory</C> object or omitted. If
58+
#! <A>packageOrDirectory</A> is an <C>IsDirectory</C> object, this is used
59+
#! as package directory; if the argument is omitted, then the current
60+
#! directory is used. In both cases, the specified directory must contain a
6561
#! <F>PackageInfo.g</F> file, and &AutoDoc; extracts all needed metadata
6662
#! from that. The <C>IsDirectory</C> form is for example useful if you
6763
#! have multiple versions of the package around and want to make sure the
6864
#! documentation of the correct version is built.
65+
#! Passing a package name string is no longer supported.
6966
#! <P/>
7067
#! Note that when using <C>AutoDocWorksheet</C> (see
7168
#! <Ref Sect='Section_AutoDocWorksheet'/>), there is
@@ -238,9 +235,7 @@
238235
#! The value should be either <K>true</K>, <K>false</K> or a
239236
#! record. If it is a record or <K>true</K> (the latter is
240237
#! equivalent to specifying an empty record), then this feature is
241-
#! enabled. It is also enabled if <A>opt.autodoc</A> is missing but the
242-
#! package depends (directly) on the &AutoDoc; package.
243-
#! In all other cases (in particular if <A>opt.autodoc</A> is
238+
#! enabled. In all other cases (in particular if <A>opt.autodoc</A> is
244239
#! <K>false</K>), this feature is disabled.
245240
#! <P/>
246241
#!

gap/Magic.gi

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,9 @@ function( arg )
6767
pkgdir := DirectoryCurrent( );
6868

6969
else
70-
is_worksheet := false;
71-
pkginfo := PackageInfo( pkgname );
72-
if IsEmpty( pkginfo ) then
73-
Error( "Could not find package ", pkgname );
74-
elif Length( pkginfo ) > 1 then
75-
Info( InfoWarning, 1, "multiple versions of package ", pkgname, " are present, using the first one" );
76-
fi;
77-
pkginfo := pkginfo[ 1 ];
78-
pkgdir := Directory( pkginfo.InstallationPath );
70+
Error("Invoking 'AutoDoc' with a package name as argument is no longer supported");
7971
fi;
8072

81-
#
82-
# Check for user supplied options. If present, they take
83-
# precedence over any defaults as well as the opt record.
84-
#
85-
for key in [ "dir", "scaffold", "autodoc", "gapdoc", "extract_examples" ] do
86-
val := ValueOption( key );
87-
if val <> fail then
88-
opt.(key) := val;
89-
fi;
90-
od;
91-
9273
#
9374
# Setup the output directory
9475
#
@@ -173,18 +154,9 @@ function( arg )
173154
#
174155
# Extract AutoDoc settings
175156
#
176-
if not IsBound(opt.autodoc) and not is_worksheet then
177-
# Enable AutoDoc support if the package depends on AutoDoc.
178-
tmp := Concatenation( pkginfo.Dependencies.NeededOtherPackages,
179-
pkginfo.Dependencies.SuggestedOtherPackages );
180-
## Empty entries are allowed in Dependencies
181-
tmp := Filtered( tmp, i -> i <> [ ] );
182-
if ForAny( tmp, x -> LowercaseString(x[1]) = "autodoc" ) then
183-
autodoc := rec();
184-
fi;
185-
elif IsRecord(opt.autodoc) then
157+
if IsBound( opt.autodoc ) and IsRecord( opt.autodoc ) then
186158
autodoc := opt.autodoc;
187-
elif IsBool(opt.autodoc) and opt.autodoc = true then
159+
elif IsBound( opt.autodoc ) and IsBool( opt.autodoc ) and opt.autodoc = true then
188160
autodoc := rec();
189161
fi;
190162

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
LoadPackage("AutoDoc");
2+
3+
AutoDoc(rec(
4+
gapdoc := rec(
5+
files := [ "gap/AutoDocTest.gd", "gap/AutoDocTest.gi" ],
6+
),
7+
scaffold := rec(
8+
includes := [ "chapter1.xml" ],
9+
appendix := [ "appendix1.xml" ],
10+
bib := "AutoDocTest.bib",
11+
bibstyle := "alphaurl",
12+
),
13+
));

tst/autodoctest-manual.tst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ gap> AUTODOC_RunPackageScenario( pkgdir, olddir, rec(
3535
> makedoc := "makedoc.g",
3636
> doc_expected := "tst/manual.expected",
3737
> ) );
38+
gap> AUTODOC_RunPackageScenario( pkgdir, olddir, rec(
39+
> name := "no-autodoc-dependency-fallback",
40+
> makedoc := "makedoc-no-autodoc.g",
41+
> stub_gapdoc := true,
42+
> prepare := function( tempdir )
43+
> local file, text, out;
44+
> file := Concatenation( tempdir, "/PackageInfo.g" );
45+
> text := StringFile( file );
46+
> text := ReplacedString(
47+
> text,
48+
> " NeededOtherPackages := [ ],",
49+
> " NeededOtherPackages := [ [ \"AutoDoc\", \">= 0\" ] ],"
50+
> );
51+
> out := OutputTextFile( file, false );
52+
> WriteAll( out, text );
53+
> CloseStream( out );
54+
> end,
55+
> doc_present := [ "_entities.xml", "_main.xml", "title.xml" ],
56+
> doc_absent := [ "_Chapter_SourceAPI.xml", "_Chapter_PlainTextFixture.xml", "_Chunks.xml" ],
57+
> ) );
3858

3959
# entities option variants
4060
gap> AUTODOC_RunPackageScenario( pkgdir, olddir, rec(

tst/manual.expected/_Chapter_Reference.xml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
<Heading>AutoDoc worksheets</Heading>
99

1010
<ManSection>
11-
<Func Arg="list_of_filenames : options" Name="AutoDocWorksheet" />
11+
<Func Arg="[filenames,] [optrec]" Name="AutoDocWorksheet" />
1212
<Description>
1313
The purpose of this function is to create stand-alone PDF and HTML files
1414
using &AutoDoc; without associating them with a package.
1515
<P/>
16-
It uses the same optional record entries as <Ref Func="AutoDoc"/>, but
17-
instead of a package name, you pass one filename or a list of filenames
18-
containing &AutoDoc; text from which the document is created.
16+
Instead of a package directory, you pass one filename or a list of
17+
filenames containing &AutoDoc; text from which the document is created.
18+
Settings are supplied via an optional record using the same entries as
19+
the <A>optrec</A> argument of <Ref Func="AutoDoc"/>. Alternatively, you may
20+
omit <A>filenames</A> and specify the files via <C>optrec.autodoc.files</C>.
1921
<P/>
2022
A simple worksheet file can define title-page information and chapter
2123
content directly in the source file, including example blocks.
@@ -28,6 +30,20 @@
2830
<P/>
2931
Since worksheets do not have a <F>PackageInfo.g</F>, title-page fields are
3032
specified directly in the worksheet file.
33+
<P/>
34+
For backwards compatibility, worksheet calls still accept GAP global
35+
options for specifying the option-record entries such as
36+
<C>dir</C>, <C>scaffold</C>, <C>autodoc</C>, <C>gapdoc</C>, and
37+
<C>extract_examples</C>.
38+
However, this feature is deprecated. If its use is detected, &AutoDoc;
39+
prints a warning recommending the explicit options record instead.
40+
For example:
41+
<Log><![CDATA[
42+
gap> AutoDocWorksheet( : autodoc := rec( files := ["worksheet.g"] ) );
43+
#W AutoDocWorksheet: legacy ':' syntax is deprecated; use optrec instead
44+
...
45+
]]></Log>
46+
3147
</Description>
3248
</ManSection>
3349

@@ -83,19 +99,16 @@
8399
<Item>
84100
The purpose of this parameter is twofold: to determine the package
85101
directory in which &AutoDoc; will operate, and to find the metadata
86-
concerning the package being documented. The parameter is either a
87-
string, an <C>IsDirectory</C> object, or omitted.
88-
If it is a string, &AutoDoc; interprets it as the name of a
89-
package, uses the metadata of the first package known to &GAP;
90-
with that name, and uses the <C>InstallationPath</C> specified in that
91-
metadata as the package directory. If <A>packageOrDirectory</A> is
92-
an <C>IsDirectory</C> object, this is used as package directory;
93-
if the argument is omitted, then the current directory is used.
94-
In the last two cases, the specified directory must contain a
102+
concerning the package being documented. The parameter is either an
103+
<C>IsDirectory</C> object or omitted. If
104+
<A>packageOrDirectory</A> is an <C>IsDirectory</C> object, this is used
105+
as package directory; if the argument is omitted, then the current
106+
directory is used. In both cases, the specified directory must contain a
95107
<F>PackageInfo.g</F> file, and &AutoDoc; extracts all needed metadata
96108
from that. The <C>IsDirectory</C> form is for example useful if you
97109
have multiple versions of the package around and want to make sure the
98110
documentation of the correct version is built.
111+
Passing a package name string is no longer supported.
99112
<P/>
100113
Note that when using <C>AutoDocWorksheet</C> (see
101114
<Ref Sect='Section_AutoDocWorksheet'/>), there is
@@ -256,9 +269,7 @@
256269
The value should be either <K>true</K>, <K>false</K> or a
257270
record. If it is a record or <K>true</K> (the latter is
258271
equivalent to specifying an empty record), then this feature is
259-
enabled. It is also enabled if <A>opt.autodoc</A> is missing but the
260-
package depends (directly) on the &AutoDoc; package.
261-
In all other cases (in particular if <A>opt.autodoc</A> is
272+
enabled. In all other cases (in particular if <A>opt.autodoc</A> is
262273
<K>false</K>), this feature is disabled.
263274
<P/>
264275
<P/>

tst/utils.g

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ AUTODOC_RunPackageScenario := function( pkgdir, olddir, scenario )
3131
Exec( Concatenation( "cp -R \"", pkgdir, "\" \"", tempdir, "\"" ) );
3232
ChangeDirectoryCurrent( tempdir );
3333

34+
if IsBound( scenario.prepare ) then
35+
scenario.prepare( tempdir );
36+
fi;
37+
3438
docdir := Directory( Concatenation( tempdir, "/doc" ) );
3539
# Keep only handwritten fixture inputs in doc/. Any pre-existing generated
3640
# output would otherwise make presence/absence checks depend on stale files

0 commit comments

Comments
 (0)