diff --git a/gap/AutoDocMainFunction.gi b/gap/AutoDocMainFunction.gi index a844ecab..7eb2ebc2 100644 --- a/gap/AutoDocMainFunction.gi +++ b/gap/AutoDocMainFunction.gi @@ -323,37 +323,39 @@ end ); ## InstallGlobalFunction( AutoDocWorksheet, function( arg ) - local autodoc_rec, scaffold_rec; + local opt, val; - if Length( arg ) = 1 then - arg[ 2 ] := rec( ); + if Length( arg ) = 2 then + opt := Remove( arg ); + else + opt := rec( ); fi; - scaffold_rec := ValueOption( "scaffold" ); - if scaffold_rec = fail then - scaffold_rec := rec( ); + val := ValueOption( "scaffold" ); + if val <> fail then + opt.scaffold := val; + elif not IsBound(opt.scaffold) then + opt.scaffold := rec(); fi; - AUTODOC_SetIfMissing( scaffold_rec, "index", false ); + AUTODOC_SetIfMissing( opt.scaffold, "index", false ); - if Length( arg ) = 2 then - autodoc_rec := ValueOption( "autodoc" ); - if autodoc_rec = fail then - autodoc_rec := rec( ); + if Length( arg ) = 1 then + val := ValueOption( "autodoc" ); + if val <> fail then + opt.autodoc := val; + elif not IsBound(opt.autodoc) then + opt.autodoc := rec(); fi; if IsString( arg[ 1 ] ) then arg[ 1 ] := [ arg[ 1 ] ]; fi; - if IsBound( autodoc_rec.files ) then - Append( autodoc_rec.files, arg[ 1 ] ); + if IsBound( opt.autodoc.files ) then + Append( opt.autodoc.files, arg[ 1 ] ); else - autodoc_rec.files := arg[ 1 ]; + opt.autodoc.files := arg[ 1 ]; fi; - AutoDoc( "AutoDocWorksheet", arg[ 2 ] : autodoc := autodoc_rec, scaffold := scaffold_rec ); - fi; - - if Length( arg ) = 0 then - AutoDoc( "AutoDocWorksheet" : scaffold := scaffold_rec ); fi; + AutoDoc_INTERN( true, "AutoDocWorksheet", rec( ), DirectoryCurrent( ), opt ); end ); # The following function is based on code by Alexander Konovalov diff --git a/gap/Magic.gd b/gap/Magic.gd index beaac504..48a2f025 100644 --- a/gap/Magic.gd +++ b/gap/Magic.gd @@ -464,6 +464,8 @@ #! @Arguments [packageOrDirectory], [optrec] DeclareGlobalFunction( "AutoDoc" ); +DeclareGlobalFunction( "AutoDoc_INTERN" ); + #! @Description #! Info class for the AutoDoc package. Set this to #! 0 to suppress info messages, 1 to allow most messages, and 2 to allow all diff --git a/gap/Magic.gi b/gap/Magic.gi index 3420609c..59d65c91 100644 --- a/gap/Magic.gi +++ b/gap/Magic.gi @@ -8,13 +8,7 @@ # InstallGlobalFunction( AutoDoc, function( arg ) - local pkgname, pkginfo, pkgdir, - opt, scaffold, gapdoc, extract_examples, autodoc, i, - doc_dir, doc_dir_rel, tmp, key, val, file, - pkgdirstr, docdirstr, - title_page, tree, is_worksheet, - position_document_class, - args; + local pkgname, pkginfo, pkgdir, opt, file; if Length( arg ) >= 3 then Error( "too many arguments" ); @@ -42,7 +36,6 @@ function( arg ) fi; if IsBound( pkgdir ) then - is_worksheet := false; file := Filename( pkgdir, "PackageInfo.g" ); if not IsExistingFile( file ) then Error( "no package name given and no PackageInfo.g file found" ); @@ -60,14 +53,7 @@ function( arg ) fi; pkgname := pkginfo.PackageName; - elif pkgname = "AutoDocWorksheet" then - # For internal use only -- for details, refer to the AutoDocWorksheet() function. - is_worksheet := true; - pkginfo := rec( ); - pkgdir := DirectoryCurrent( ); - else - is_worksheet := false; pkginfo := PackageInfo( pkgname ); if IsEmpty( pkginfo ) then Error( "Could not find package ", pkgname ); @@ -78,6 +64,18 @@ function( arg ) pkgdir := Directory( pkginfo.InstallationPath ); fi; + return AutoDoc_INTERN( false, pkgname, pkginfo, pkgdir, opt ); +end ); + +InstallGlobalFunction( AutoDoc_INTERN, +function( is_worksheet, pkgname, pkginfo, pkgdir, opt ) + local scaffold, gapdoc, extract_examples, autodoc, i, + doc_dir, doc_dir_rel, tmp, key, val, file, + pkgdirstr, docdirstr, + title_page, tree, + position_document_class, + args; + # # Check for user supplied options. If present, they take # precedence over any defaults as well as the opt record.