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
40 changes: 21 additions & 19 deletions gap/AutoDocMainFunction.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gap/Magic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@
#! @Arguments [packageOrDirectory], [optrec]
DeclareGlobalFunction( "AutoDoc" );

DeclareGlobalFunction( "AutoDoc_INTERN" );

#! @Description
#! Info class for the <Package>AutoDoc</Package> package. Set this to
#! 0 to suppress info messages, 1 to allow most messages, and 2 to allow all
Expand Down
28 changes: 13 additions & 15 deletions gap/Magic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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" );
Expand All @@ -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 );
Expand All @@ -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.
Expand Down