Skip to content

Commit

Permalink
Separate doc.* files
Browse files Browse the repository at this point in the history
  • Loading branch information
mtorpey committed Sep 3, 2024
1 parent 7509cf2 commit 64c2dc9
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 54 deletions.
1 change: 0 additions & 1 deletion gap/PackageManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ DeclareGlobalFunction("GetPackageURLs");
# Hidden functions
DeclareGlobalFunction("PKGMAN_InstallDependencies");
DeclareGlobalFunction("PKGMAN_CheckPackage");
DeclareGlobalFunction("PKGMAN_MakeDoc");
DeclareGlobalFunction("PKGMAN_Exec");
DeclareGlobalFunction("PKGMAN_NameOfGitRepo");
DeclareGlobalFunction("PKGMAN_NameOfHgRepo");
Expand Down
53 changes: 0 additions & 53 deletions gap/PackageManager.gi
Original file line number Diff line number Diff line change
Expand Up @@ -899,59 +899,6 @@ function(dir)
return true;
end);

InstallGlobalFunction(PKGMAN_MakeDoc,
function(dir)
local last_infogapdoc, last_infowarning, makedoc_g, doc_dir, doc_make_doc,
last_dir, str, exec;
if not IsPackageLoaded("gapdoc") then
Info(InfoPackageManager, 1,
"GAPDoc package not found, skipping building the documentation...");
return;
fi;

# Mute GAPDoc
if IsBoundGlobal("InfoGAPDoc") then
last_infogapdoc := InfoLevel(ValueGlobal("InfoGAPDoc"));
SetInfoLevel(ValueGlobal("InfoGAPDoc"), 0);
fi;

last_infowarning := InfoLevel(InfoWarning);
SetInfoLevel(InfoWarning, 0);

# Make documentation
makedoc_g := Filename(Directory(dir), "makedoc.g");
doc_dir := Filename(Directory(dir), "doc");
doc_make_doc := Filename(Directory(doc_dir), "make_doc");
if IsReadableFile(makedoc_g) then
Info(InfoPackageManager, 3,
"Building documentation (using makedoc.g)...");

# Run makedoc.g, in the correct directory, without quitting
last_dir := Filename(DirectoryCurrent(), "");
ChangeDirectoryCurrent(dir);
str := StringFile(makedoc_g);
str := ReplacedString(str, "QUIT;", ""); # TODO: is there a better way?
str := ReplacedString(str, "quit;", "");
Read(InputTextString(str));
ChangeDirectoryCurrent(last_dir);

elif IsReadableFile(doc_make_doc) then
Info(InfoPackageManager, 3,
"Building documentation (using doc/make_doc)...");
exec := PKGMAN_Exec(doc_dir, doc_make_doc);
if exec.code <> 0 then
Info(InfoPackageManager, 3, "WARNING: doc/make_doc failed");
fi;
else
Info(InfoPackageManager, 3,
"WARNING: could not build doc (no makedoc.g or doc/make_doc)");
fi;
if IsBoundGlobal("InfoGAPDoc") then
SetInfoLevel(ValueGlobal("InfoGAPDoc"), last_infogapdoc);
fi;
SetInfoLevel(InfoWarning, last_infowarning);
end);

InstallGlobalFunction(PKGMAN_Exec,
function(dir, cmd, args...)
local sh, fullcmd, instream, out, outstream, code;
Expand Down
1 change: 1 addition & 0 deletions gap/doc.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DeclareGlobalFunction("PKGMAN_MakeDoc");
52 changes: 52 additions & 0 deletions gap/doc.gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
InstallGlobalFunction(PKGMAN_MakeDoc,
function(dir)
local last_infogapdoc, last_infowarning, makedoc_g, doc_dir, doc_make_doc,
last_dir, str, exec;
if not IsPackageLoaded("gapdoc") then
Info(InfoPackageManager, 1,
"GAPDoc package not found, skipping building the documentation...");
return;
fi;

# Mute GAPDoc
if IsBoundGlobal("InfoGAPDoc") then
last_infogapdoc := InfoLevel(ValueGlobal("InfoGAPDoc"));
SetInfoLevel(ValueGlobal("InfoGAPDoc"), 0);
fi;

last_infowarning := InfoLevel(InfoWarning);
SetInfoLevel(InfoWarning, 0);

# Make documentation
makedoc_g := Filename(Directory(dir), "makedoc.g");
doc_dir := Filename(Directory(dir), "doc");
doc_make_doc := Filename(Directory(doc_dir), "make_doc");
if IsReadableFile(makedoc_g) then
Info(InfoPackageManager, 3,
"Building documentation (using makedoc.g)...");

# Run makedoc.g, in the correct directory, without quitting
last_dir := Filename(DirectoryCurrent(), "");
ChangeDirectoryCurrent(dir);
str := StringFile(makedoc_g);
str := ReplacedString(str, "QUIT;", ""); # TODO: is there a better way?
str := ReplacedString(str, "quit;", "");
Read(InputTextString(str));
ChangeDirectoryCurrent(last_dir);

elif IsReadableFile(doc_make_doc) then
Info(InfoPackageManager, 3,
"Building documentation (using doc/make_doc)...");
exec := PKGMAN_Exec(doc_dir, doc_make_doc);
if exec.code <> 0 then
Info(InfoPackageManager, 3, "WARNING: doc/make_doc failed");
fi;
else
Info(InfoPackageManager, 3,
"WARNING: could not build doc (no makedoc.g or doc/make_doc)");
fi;
if IsBoundGlobal("InfoGAPDoc") then
SetInfoLevel(ValueGlobal("InfoGAPDoc"), last_infogapdoc);
fi;
SetInfoLevel(InfoWarning, last_infowarning);
end);
1 change: 1 addition & 0 deletions init.g
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

ReadPackage("PackageManager", "gap/PackageManager.gd");
ReadPackage("PackageManager", "gap/compile.gd");
ReadPackage("PackageManager", "gap/doc.gd");
ReadPackage("PackageManager", "gap/Interactive.gd");
1 change: 1 addition & 0 deletions read.g
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

ReadPackage("PackageManager", "gap/PackageManager.gi");
ReadPackage("PackageManager", "gap/compile.gi");
ReadPackage("PackageManager", "gap/doc.gi");
ReadPackage("PackageManager", "gap/Interactive.gi");
2 changes: 2 additions & 0 deletions tst/PackageManager.tst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ true
gap> ForAny(DirectoryContents(PKGMAN_PackageDir()),
> f -> StartsWith(LowercaseString(f), "example"));
true
gap> RemovePackage("example", false);
true

# RemovePackage failure
gap> RemovePackage(3);
Expand Down
2 changes: 2 additions & 0 deletions tst/compile.tst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ gap> CompilePackage("example");
#I Compilation script not found
false
gap> PKGMAN_BuildPackagesScript := temp;;
gap> RemovePackage("example", false);
true

# Compile already compiled
gap> InstallPackage("toric");
Expand Down
File renamed without changes.

0 comments on commit 64c2dc9

Please sign in to comment.