Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
This file describes changes in the AutoDoc package.

2025.MM.DD
- Make handling `Date` in `PackageInfo.g` more strict (previously some
malformed variants were accepted to deal with very old packages, but by
now all packages are compliant)
- Remove a bunch of features that were deprecated since 2019:
- `AutoDoc` option `scaffold.gapdoc_latex_options` has been
replaced by `gapdoc.LaTeXOptions`
Expand Down
16 changes: 1 addition & 15 deletions gap/AutoDocMainFunction.gi
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,7 @@ InstallGlobalFunction( CreateTitlePage,
# digit day or month, which is formally not allowed in PackageInfo.g,
# but happens in a few legacy packages)
argument_rec.Date := Chomp( argument_rec.Date ); # remove trailing newlines, if present
i := SplitString( argument_rec.Date, "/" );
if Length( argument_rec.Date ) in [8..10] and Length( i ) = 3 then
i := List(i, Int);
OutWithTag( "Date", AUTODOC_FormatDate(i[3], i[2], i[1]) );
else
# try to parse the date in ISO8601 format YYYY-MM-DD (here we are strict)
i := SplitString( argument_rec.Date, "-" );
if Length( argument_rec.Date ) = 10 and Length( i ) = 3 then
i := List(i, Int);
OutWithTag( "Date", AUTODOC_FormatDate(i[1], i[2], i[3]) );
else
Info(InfoAutoDoc, 1, "Warning: could not parse package date '", argument_rec.Date, "'");
OutWithTag( "Date", argument_rec.Date );
fi;
fi;
OutWithTag( "Date", AUTODOC_FormatDate(argument_rec.Date) );
fi;

for i in [ "Address", "Abstract", "Copyright", "Acknowledgements", "Colophon" ] do
Expand Down
20 changes: 20 additions & 0 deletions gap/ToolFunctions.gi
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,33 @@ BindGlobal("AUTODOC_months", MakeImmutable([
# The input can be one of the following:
# - AUTODOC_FormatDate(rec), where <rec> is a record with entries year, month, day;
# - AUTODOC_FormatDate(year[, month[, day]])
# - AUTODOC_FormatDate(date_str) where date_str is a string of the form "DD/MM/YYYY" or "YYYY-MM-DD"
# In each case, the year, month or day may be given as either an
# integer, or as a string representing an integer.
InstallGlobalFunction( AUTODOC_FormatDate,
function(arg)
local date, key, val, result;
if Length(arg) = 1 and IsRecord(arg[1]) then
date := ShallowCopy(arg[1]);
elif Length(arg) = 1 and IsString(arg[1]) then
if Length(arg[1]) = 10 then
date := arg[1];
if date{[3,6]} = "//" then
date := rec(
day := Int(date{[1,2]}),
month := Int(date{[4,5]}),
year := Int(date{[7..10]}),
);
elif date{[5,8]} = "--" then
date := rec(
year := Int(date{[1..4]}),
month := Int(date{[6,7]}),
day := Int(date{[9,10]}),
);
else
Unbind(date);
fi;
fi;
elif Length(arg) in [1..3] then
date := rec();
date.year := arg[1];
Expand Down
4 changes: 4 additions & 0 deletions tst/misc.tst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ gap> AUTODOC_FormatDate(2019, 3, 1);
"1 March 2019"
gap> AUTODOC_FormatDate("2019", "3", "1");
"1 March 2019"
gap> AUTODOC_FormatDate("2019-03-01");
"1 March 2019"
gap> AUTODOC_FormatDate("01/03/2019");
"1 March 2019"
gap> AUTODOC_FormatDate(rec(year:=2019));
"2019"
gap> AUTODOC_FormatDate(rec(year:=2019, month:=3));
Expand Down