frankluebeck / GAPDoc

A package to generate documentation for GAP (https://www.gap-system.org) code
http://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc/
5 stars 10 forks source link

Calling SetGAPDocTextTheme with the default theme breaks GAPDoc #45

Closed embray closed 3 years ago

embray commented 3 years ago

Observed behavior

gap> GAPDocTextTheme;
rec( Arg := [ [ "3X", "103X" ], [ "\033[22m\033[32m", "\033[0m" ] ], B := [ [ "12X", "112X" ], [ "<", ">" ] ], BibAuthor := [ [ "16X", "116X" ], [ "\033[1m\033[31m", "\033[0m" ] ], 
  BibJournal := [ [ "18X", "118X" ], [ "", "" ] ], BibLabel := [ [ "20X", "120X" ], [ "\033[35m", "\033[0m" ] ], BibReset := [ [ "15X", "115X" ], [ "\033[0m", "\033[0m" ] ], 
  BibTitle := [ [ "17X", "117X" ], [ "\033[34m", "\033[0m" ] ], BibVolume := [ [ "19X", "119X" ], [ "\033[34m", "\033[0m" ] ], 
  BrkPrompt := [ [ "26X", "126X" ], [ "\033[1m\033[31m", "\033[0m" ] ], C := [ [ "10X", "110X" ], [ "\033[22m\033[31m", "\033[0m" ] ], 
  DefLineMarker := [ [ "29X", "129X" ], [ "‣ ", "‣ " ] ], Display := [ [ "24X", "124X" ], [ "", "" ] ], Emph := [ [ "13X", "113X" ], [ "\033[1m", "\033[0m" ] ], 
  EnumMarks := [ [ "31X", "131X" ], [ " ", "." ] ], Example := [ [ "4X", "104X" ], [ "\033[22m\033[30m", "\033[0m" ] ], F := [ [ "11X", "111X" ], [ "\033[22m\033[36m", "\033[0m" ] ], 
  FillString := [ [ "32X", "132X" ], [ "───", "───" ] ], Func := [ [ "2X", "102X" ], [ "\033[22m\033[34m", "\033[0m" ] ], 
  GAPInput := [ [ "27X", "127X" ], [ "\033[31m", "\033[0m" ] ], GAPOutput := [ [ "28X", "128X" ], [ "\033[0m", "\033[0m" ] ], Heading := [ [ "1X", "101X" ], [ "\033[22m\033[4m", "\033[0m" ] ]
    , K := [ [ "9X", "109X" ], [ "\033[22m\033[31m", "\033[0m" ] ], ListBullet := [ [ "30X", "130X" ], [ " •", " •" ] ], M := [ [ "22X", "122X" ], [ "", "" ] ], 
  Mark := [ [ "8X", "108X" ], [ "\033[1m\033[35m", "\033[0m" ] ], Math := [ [ "23X", "123X" ], [ "$", "$" ] ], Package := [ [ "5X", "105X" ], [ "\033[1m", "\033[0m" ] ], 
  Prompt := [ [ "25X", "125X" ], [ "\033[1m\033[34m", "\033[0m" ] ], Q := [ [ "21X", "121X" ], [ "\"", "\"" ] ], Ref := [ [ "14X", "114X" ], [ "\033[36m", "\033[0m" ] ], 
  Returns := [ [ "6X", "106X" ], [ "\033[22m", "\033[0m" ] ], URL := [ [ "7X", "107X" ], [ "\033[36m", "\033[0m" ] ], flush := [ [ "34X", "134X" ], [ "both", "both" ] ], 
  format := [ [ "33X", "133X" ], [ "", "" ] ], hash := [ [ "0X", "100X", "101X", "102X", "103X", "104X", "105X", "106X", "107X", "108X", "109X", "10X", "110X", "111X", "112X", "113X", 
          "114X", "115X", "116X", "117X", "118X", "119X", "11X", "120X", "121X", "122X", "123X", "124X", "125X", "126X", "127X", "128X", "129X", "12X", "130X", "131X", "132X", "133X", 
          "134X", "13X", "14X", "15X", "16X", "17X", "18X", "19X", "1X", "20X", "21X", "22X", "23X", "24X", "25X", "26X", "27X", "28X", "29X", "2X", "30X", "31X", "32X", "33X", "34X", "3X", 
          "4X", "5X", "6X", "7X", "8X", "9X" ], [ "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[22m\033[31m", 
          "\033[0m", "\033[0m", ">", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "\033[0m", "", "\033[0m", "\033[22m\033[36m", "\033[0m", "\"", "", "$", "", "\033[0m", "\033[0m", "\033[0m", 
          "\033[0m", "‣ ", "<", " •", ".", "───", "", "both", "\033[1m", "\033[36m", "\033[0m", "\033[1m\033[31m", "\033[34m", "", "\033[34m", "\033[22m\033[4m", "\033[35m", "\"", 
          "", "$", "", "\033[1m\033[34m", "\033[1m\033[31m", "\033[31m", "\033[0m", "‣ ", "\033[22m\033[34m", " •", " ", "───", "", "both", "\033[22m\033[32m", "\033[22m\033[30m", 
          "\033[1m", "\033[22m", "\033[36m", "\033[1m\033[35m", "\033[22m\033[31m" ] ], reset := [ [ "0X", "100X" ], [ "\033[0m", "\033[0m" ] ] )
gap> SetGAPDocTextTheme(GAPDocTextTheme);
gap> HELP("CyclicGroup");
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `Unicode' on 2 arguments at /home/embray/src/gap-system/gap/lib/methsel2.g:249 called from
Unicode( str, "UTF-8" ) at /home/embray/src/gap-system/gap/pkg/GAPDoc-1.6.2/lib/UnicodeTools.gi:1133 called from
widthfun( StripEscapeSequences( res{[ i + 1 .. Length( res ) ]} ) ) at /home/embray/src/gap-system/gap/pkg/GAPDoc-1.6.2/lib/Text.gi:1042 called from
SubstituteEscapeSequences( a[8], theme ) at /home/embray/src/gap-system/gap/pkg/GAPDoc-1.6.2/lib/HelpBookHandler.g:96 called from
HELP_BOOK_HANDLER.GapDocGAP.apptheme( res, GAPDocTextTheme ); at /home/embray/src/gap-system/gap/pkg/GAPDoc-1.6.2/lib/HelpBookHandler.g:167 called from
HELP_BOOK_HANDLER.(handler).ReadSix( stream ) at /home/embray/src/gap-system/gap/lib/helpbase.gi:722 called from
...  at *stdin*:3
type 'quit;' to quit to outer loop
brk>

This is with

 ┌───────┐   GAP 4.11.0 of today
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-default64-kv7
 Configuration:  gmp 6.1.2, GASMAN, readline
 Loading the library and packages ...
 Packages:   GAPDoc 1.6.2, PrimGrp 3.3.2, SmallGrp 1.3, TransGrp 2.0.4
embray commented 3 years ago

I see now that SetGAPDocTextTheme just manipulates the existing record in GAPDocTextTheme in-place, rather than create a new record, if I understand correctly. That's probably responsible for the mess I made by doing that, but this is confusing.

frankluebeck commented 3 years ago

You are not using a record with valid components as an argument (these must be either a string or a list of two strings, as documented).

Nevertheless, I have just commited a small fix (commit 836ea0e) which raises an error on your input.

[BTW: the default argument of SetGAPDocTextTheme (if none is given) is in GAPDoc2TextProcs.OtherThemes.default.]

embray commented 3 years ago

Right, I think what's not obvious is that the actual value of GAPDocTextTheme is not a valid input to SetGAPDocTextTheme (which you might try to use if you wanted to save/restore the existing theme, which it turns out is more easily done by just setting GAPDocTextTheme directly).

[BTW: the default argument of SetGAPDocTextTheme (if none is given) is in GAPDoc2TextProcs.OtherThemes.default.]

Thanks, that works too (at least for restoring the default).