Skip to content

Commit

Permalink
Revise handling of chunks XML file
Browse files Browse the repository at this point in the history
Also remove AUTODOC_AbsolutePath
  • Loading branch information
fingolfin committed May 24, 2023
1 parent d92a6a2 commit 4cf4a1b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 31 deletions.
3 changes: 0 additions & 3 deletions gap/AutoDocMainFunction.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ DeclareGlobalFunction( "AutoDocScanFiles" );
## Global option record
DeclareGlobalVariable( "_AUTODOC_GLOBAL_OPTION_RECORD" );

##
_AUTODOC_GLOBAL_CHUNKS_FILE := fail;

##
## This function creates a title file. It must be called with the package name and the path to doc files.
DeclareGlobalFunction( "CreateTitlePage" );
Expand Down
6 changes: 1 addition & 5 deletions gap/AutoDocMainFunction.gi
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,7 @@ end );
# The following function is based on code by Alexander Konovalov
BindGlobal("AUTODOC_ExtractMyManualExamples",
function( pkgname, pkgdir, docdir, main, files, opt )
local tst, i, s, basename, name, output, ch, a, location, pos, comment,
pkgdirString, absPkgdirString,
local tst, i, s, basename, name, output, ch, a, location, pos, comment, pkgdirString,
nonempty_units_found, number_of_digits, lpkgname, tstdir;
Print("Extracting manual examples for ", pkgname, " package ...\n" );

Expand All @@ -450,7 +449,6 @@ function( pkgname, pkgdir, docdir, main, files, opt )
tst:=ExtractExamples( docdir, main, files, opt.units );
Print(Length(tst), " ", LowercaseString( opt.units ), "s detected\n");
pkgdirString := Filename(pkgdir, "");
absPkgdirString := AUTODOC_AbsolutePath(pkgdirString);

# ensure the 'tst' directory exists
tstdir := Filename(pkgdir, "tst");
Expand Down Expand Up @@ -510,8 +508,6 @@ function( pkgname, pkgdir, docdir, main, files, opt )
location := a[2][1];
if StartsWith(location, pkgdirString) then
comment := location{[ Length(pkgdirString)+1 .. Length(location) ]};
elif StartsWith(location, absPkgdirString) then
comment := location{[ Length(absPkgdirString)+1 .. Length(location) ]};
else
pos := PositionSublist(location, LowercaseString(pkgname));
if pos <> fail then
Expand Down
2 changes: 1 addition & 1 deletion gap/DocumentationTree.gi
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ BindGlobal( "WriteChunks",
current_chunk;

filename := "_Chunks.xml";
_AUTODOC_GLOBAL_CHUNKS_FILE := AUTODOC_AbsolutePath( path_to_xmlfiles, filename );

chunks_stream := AUTODOC_OutputTextFile( path_to_xmlfiles, filename );
chunk_names := RecNames( tree!.chunks );

Expand Down
13 changes: 7 additions & 6 deletions gap/Magic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,15 @@ function( arg )
#
# Write AutoDoc XML files
#
_AUTODOC_GLOBAL_CHUNKS_FILE := fail;
if IsBound( autodoc ) then
WriteDocumentation( tree, doc_dir, autodoc.level );
if IsBound( gapdoc ) then
if IsBound( doc_dir_rel ) then
Add( gapdoc.files, "_Chunks.xml" );
else
Add( gapdoc.files, Filename( doc_dir, "_Chunks.xml" ) );
fi;
fi;
fi;


Expand Down Expand Up @@ -553,11 +559,6 @@ function( arg )
"\\immediate\\write\\pagenrlog{[\"Ind\", 0, 0], \\arabic{page},}\n",
GAPDoc2LaTeXProcs.Tail );

# Process Chunks.xml file, if present
if IsString(_AUTODOC_GLOBAL_CHUNKS_FILE) then
Add( gapdoc.files, _AUTODOC_GLOBAL_CHUNKS_FILE );
fi;

# Default parameters for MakeGAPDocDoc
args := [ doc_dir, gapdoc.main, gapdoc.files, gapdoc.bookname, "MathJax" ];

Expand Down
1 change: 0 additions & 1 deletion gap/ToolFunctions.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

DeclareGlobalFunction( "AUTODOC_CreateDirIfMissing" );
DeclareGlobalFunction( "AUTODOC_CurrentDirectory" );
DeclareGlobalFunction( "AUTODOC_AbsolutePath" );

DeclareGlobalFunction( "AUTODOC_OutputTextFile" );
DeclareGlobalFunction( "AutoDoc_WriteDocEntry" );
Expand Down
18 changes: 3 additions & 15 deletions gap/ToolFunctions.gi
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,15 @@ function(d)
end );

InstallGlobalFunction( "AUTODOC_CurrentDirectory",
function()
return AUTODOC_AbsolutePath(DirectoryCurrent());
end);

# given a path (relative or absolute), return an absolute path pointing to the
# same file or directory.
InstallGlobalFunction( "AUTODOC_AbsolutePath",
function( dir, filename... )
function(args...)
local pwd, result;
pwd := Filename( DirectoriesSystemPrograms(), "pwd" );
if pwd = fail then
Error("failed to locate 'pwd' tool");
fi;
result := "";
Process(Directory(dir), pwd, InputTextNone(), OutputTextString(result, true), []);
result := Chomp(result);
if Length(filename) > 0 and Length(filename[1]) > 0 then
Append(result, "/");
Append(result, filename[1]);
fi;
return result;
Process(DirectoryCurrent(), pwd, InputTextNone(), OutputTextString(result, true), []);
return Chomp(result);
end);


Expand Down

0 comments on commit 4cf4a1b

Please sign in to comment.