Skip to content
Draft
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
2 changes: 1 addition & 1 deletion gap/AutoDocMainFunction.gi
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function( pkgname, pkgdir, docdir, main, files, opt, roots )
AppendTo(output, "gap> START_TEST(\"", basename, "\");\n\n");
for a in ch do
location := a[2][1];
if not StartsWith(location, "/") then
if not AUTODOC_IsAbsolutePath(location) then
# Already reproducible: AutoDoc recorded this position itself,
# or GAPDoc resolved it relative to the documentation dir.
comment := location;
Expand Down
1 change: 1 addition & 0 deletions gap/ToolFunctions.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DeclareGlobalFunction( "AUTODOC_StageDirectory" );
DeclareGlobalFunction( "AUTODOC_SourceMarker" );
DeclareGlobalFunction( "AUTODOC_RemapSourcePositions" );
DeclareGlobalFunction( "AUTODOC_CurrentDirectory" );
DeclareGlobalFunction( "AUTODOC_IsAbsolutePath" );
DeclareGlobalFunction( "AUTODOC_LineStartsCDATA" );
DeclareGlobalFunction( "AUTODOC_LineEndsCDATA" );
DeclareGlobalFunction( "AUTODOC_EscapeCDATAContent" );
Expand Down
21 changes: 13 additions & 8 deletions gap/ToolFunctions.gi
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,23 @@ function(d)
return true;
end );

# Not DirectoryCurrent: its cached value goes stale when the directory is
# changed other than by ChangeDirectoryCurrent. Not the `pwd` program either,
# which under MSYS2 prints a path native Windows programs cannot use.
InstallGlobalFunction( "AUTODOC_CurrentDirectory",
function(args...)
local pwd, result;
pwd := Filename( DirectoriesSystemPrograms(), "pwd" );
if pwd = fail then
Error("failed to locate 'pwd' tool");
fi;
result := "";
Process(DirectoryCurrent(), pwd, InputTextNone(), OutputTextString(result, true), []);
return Chomp(result);
return GAP_getcwd();
end);

# Whether <path> is absolute: it starts with a slash, or on Windows with a
# drive, as in `C:/`.
InstallGlobalFunction( "AUTODOC_IsAbsolutePath",
function( path )
return StartsWith( path, "/" ) or
( ARCH_IS_WINDOWS() and Length( path ) >= 3 and
path[2] = ':' and path[3] in "/\\" );
end );

InstallGlobalFunction( "AUTODOC_LineStartsCDATA",
function(line)
# Phase 1 keeps CDATA encoded as raw strings; Parser.gi still injects such
Expand Down
2 changes: 1 addition & 1 deletion tst/autodoctest-manual.tst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gap> olddir := AUTODOC_CurrentDirectory();;
gap> pkgdir := DirectoriesPackageLibrary( "AutoDoc", "tst/AutoDocTest" );;
gap> pkgdir := pkgdir[1];;
gap> pkgdir := Filename( pkgdir, "" );;
gap> if not StartsWith( pkgdir, "/" ) then
gap> if not AUTODOC_IsAbsolutePath( pkgdir ) then
> pkgdir := Concatenation( olddir, "/", pkgdir );
> fi;
gap> ReadPackage( "AutoDoc", "tst/utils.g" );
Expand Down
2 changes: 1 addition & 1 deletion tst/errorwithpos.tst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# test parser error reporting with ErrorWithPos
gap> autodoc_pkgroot := Filename( DirectoriesPackageLibrary( "AutoDoc", "" ), "" );;
gap> if not StartsWith( autodoc_pkgroot, "/" ) then
gap> if not AUTODOC_IsAbsolutePath( autodoc_pkgroot ) then
> autodoc_pkgroot := Filename(
> Directory( AUTODOC_CurrentDirectory() ),
> autodoc_pkgroot
Expand Down
2 changes: 1 addition & 1 deletion tst/misc.tst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ true
# AutoDoc_Parser_ReadFiles: multiline InstallMethod parsing
#
gap> autodoc_pkgroot := Filename( DirectoriesPackageLibrary( "AutoDoc", "" ), "" );;
gap> if not StartsWith( autodoc_pkgroot, "/" ) then
gap> if not AUTODOC_IsAbsolutePath( autodoc_pkgroot ) then
> autodoc_pkgroot := Filename(
> Directory( AUTODOC_CurrentDirectory() ),
> autodoc_pkgroot
Expand Down