diff --git a/CHANGES.md b/CHANGES.md index 7652dd77..6cd9e2d7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,10 @@ This file describes changes in the AutoDoc package. `@Command` does not start at column 1 - Normalize parsed `InstallMethod` names by stripping surrounding quotes, matching `Declare...` handling + - Loosen requirements on `@Date` command: this used to allow free form, + but in recent versions was restricted to dates of the form YYYY-MM-DD + or DD/MM/YYYY; now we again allow any text, but text in those specific + formats is still parsed and formatted (e.g. 2026-03-08 as 8 March 2026) - Improve parser robustness by reporting clear EOF errors for unterminated declaration headers and filter lists - Make tests work when the package directory is read-only by writing diff --git a/gap/AutoDocMainFunction.gi b/gap/AutoDocMainFunction.gi index 59cb8844..62eedc2b 100644 --- a/gap/AutoDocMainFunction.gi +++ b/gap/AutoDocMainFunction.gi @@ -223,7 +223,8 @@ end ); ## separately. InstallGlobalFunction( CreateTitlePage, function( dir, argument_rec ) - local indent, tag, names, filestream, entity_list, OutWithTag, Out, i; + local indent, tag, names, filestream, entity_list, OutWithTag, Out, i, + parsed_date; filestream := AUTODOC_OutputTextFile( dir, "title.xml" ); indent := 0; @@ -271,11 +272,17 @@ InstallGlobalFunction( CreateTitlePage, fi; if IsBound( argument_rec.Date ) then - # try to parse the date in format DD/MM/YYYY (we also accept single - # 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 - OutWithTag( "Date", AUTODOC_FormatDate(argument_rec.Date) ); + if IsString( argument_rec.Date ) then + argument_rec.Date := Chomp( argument_rec.Date ); # remove trailing newlines, if present + + # PackageInfo.g dates are normalized, but @Date should also allow + # free-form text when the input is not one of the supported date formats. + parsed_date := AUTODOC_ParseDate( argument_rec.Date ); + if parsed_date <> fail then + argument_rec.Date := AUTODOC_FormatDate( parsed_date ); + fi; + fi; + OutWithTag( "Date", argument_rec.Date ); fi; for i in [ "Address", "Abstract", "Copyright", "Acknowledgements", "Colophon" ] do diff --git a/tst/worksheets/autoplain.expected/title.xml b/tst/worksheets/autoplain.expected/title.xml index 084922a5..a931989a 100644 --- a/tst/worksheets/autoplain.expected/title.xml +++ b/tst/worksheets/autoplain.expected/title.xml @@ -6,6 +6,6 @@ Plain file.autodoc Test - 30 August 2018 + 8 March 2026 \ No newline at end of file diff --git a/tst/worksheets/autoplain.sheet/plain.autodoc b/tst/worksheets/autoplain.sheet/plain.autodoc index 46d6da77..24d282f9 100644 --- a/tst/worksheets/autoplain.sheet/plain.autodoc +++ b/tst/worksheets/autoplain.sheet/plain.autodoc @@ -1,5 +1,5 @@ @Title Plain file.autodoc Test -@Date 2018-08-30 +@Date 8 March 2026 # Test Does AutoDoc have a way to allow that header block not to appear in