##___DOC:=ShallowCopy(__DOC);

## now first of all initialise
##__DOC:=[];
SizeScreen([255,255]);

## read in raw documentations from magma kernel
ReadLib("../doc/DOC_KANT");
stime:=UTime();
__PREVIOUS_LIB:=__CURRENT_LIB;
__CURRENT_LIB:="<internal>";
Mapc(i->InstallDocumentation(i),__DOC_KANT);
__CURRENT_LIB:=__PREVIOUS_LIB;
etime:=UTime();
Print("[",etime-stime,"] ");

## now read the merge info for the magma kernel
ReadPath(LIBNAME, "../doc/DOC_KANT_MERGE", ".g", "ReadLib");
## now merge :)
stime:=UTime();
__PREVIOUS_LIB:=__CURRENT_LIB;
__CURRENT_LIB:="<internal>";
Mapc(i->MergeDocumentation(i),__DOC_KANT_MERGE);
__CURRENT_LIB:=__PREVIOUS_LIB;
etime:=UTime();
Print("[",etime-stime,"] ");

ReadLib("../doc/DOC_INTERNAL");
stime:=UTime();
Mapc(i->InstallDocumentation(i,rec(ForceAdd:=TRUE)),__DOC_INTERNAL);
etime:=UTime();
Print("[",etime-stime,"] ");

### now dumping the new documentation
stime:=UTime();
PrintTo("__DOC.g","__DOC := rec(keys:=Dry([\n");
MapAlist(
  function(key,val)
    AppendTo("__DOC.g","\"",key,"\",\n");
  end, __DOC);
AppendTo("__DOC.g","SUCCESS],rec(DupCheck:=FALSE)),\n    base:=[\n");
MapAlist(
  function(key,val)
    AppendTo("__DOC.g",val,",\n");
  end, __DOC);
AppendTo("__DOC.g","rec(kind:=\"KEYWORD\",name:=\"This is not a valid entry\",hash:=\"SUCCESS\")],\n"+
  "type:=alist,\noperations:=rec(Print:=_PrintAlist));\n");
etime:=UTime();
Print("[",etime-stime,"]\n");
