"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1
2 __EmptyDoc:=
3 rec(
4 kind:="UNBOUND",
5 name:="",
6 sin:=[[]],
7 sou:=[],
8 short:="",
9 sig:="",
10 hash:="UNBOUND");
11
12 ## Auxiliary
13
14 __CurryDisplayHookFun:=
15 hook->
16 (docrec->
17 RunHookWithArg(hook,docrec));
18
19 ___CurryPrintFun:=
20 pre->
21 (post->
22 (fun->
23 (function(args)
24 local tmp;
25 tmp:=fun(args);
26 PrintString(pre);
27 if tmp<>[] then
28 if IsString(tmp) then
29 PrintString(tmp);
30 elif IsList(tmp) then
31 Mapc(i->PrintString(i," "),tmp);
32 elif tmp = FAILURE then
33 return VOID;
34 else
35 PrintString(tmp);
36 fi;
37 fi;
38 PrintString(post);
39 end)));
40
41 ___CurryPrintFunIf:=
42 pre->
43 (post->
44 (fun->
45 (function(args)
46 local tmp;
47 tmp:=fun(args);
48 if tmp<>"" and tmp<>false and tmp<>[] then
49 PrintString(pre);
50 if IsString(tmp) then
51 PrintString(tmp);
52 elif IsList(tmp) then
53 Mapc(i->PrintString(i," "),tmp);
54 elif tmp=FAILURE then
55 PrintString("");
56 else
57 PrintString(tmp);
58 fi;
59 PrintString(post);
60 fi;
61 end)));
62
63 __CurryPrintFun:=___CurryPrintFun("");
64 __CurryPrintFunIf:=___CurryPrintFunIf("");
65 __CurryPrintFunNL:=__CurryPrintFun("\n");
66 __CurryPrintFun1L:=__CurryPrintFun(": ");
67 __CurryPrintFunNLie:=__CurryPrintFunIf("\n");
68 __CurryPrintFun1Lie:=__CurryPrintFunIf(": ");
69
70 ___CurryPrintFunFC:=
71 prfun->
72 (pre->
73 (post->
74 (fun->
75 (function(args)
76 local tmp;
77 tmp:=fun(args);
78 if tmp<>"" and tmp<>false and tmp<>FAILURE then
79 PrintString(pre);
80 prfun(_Filtered_func_list(i->IsSuccess(i),tmp));
81 PrintString(post);
82 fi;
83 end))));
84
85
86
87 ### less main funs
88
89 RetrieveDocumentation:=_Function_alist(__DOC,rec(Fail:=FAILURE));
90 InstallDocumentation(
91 rec(
92 kind:="FUNCTION",
93 name:="RetrieveDocumentation",
94 sin := [[string,"dochash"]],
95 sou := [[record]],
96 short := "Retrieve the current entry for `dochash' in the global "+
97 "documentation.\n"+
98 "Use this function to obtain the entire record from __DOC as is.",
99 ex := ["RetrieveDocumentation(\""+
100 DocGenHashByString("RetrieveDocumentation(string)")+
101 "\");"]), rec());
102
103 ExistsDocumentation:=hash->IsSuccess(_Position_alist_any(__DOC,hash));
104 InstallDocumentation(
105 rec(
106 kind:="FUNCTION",
107 name:="ExistsDocumentation",
108 sin := [[string,"dochash"]],
109 sou := [[elt-alg^boo]],
110 short := "Return true iff documentation for 'dochash' is available."), rec());
111
112
113
114 __RetrieveDocField:=
115 field->
116 (docrec->
117 _GetEntry_rec_string(docrec,field,rec(Fail:=[])));
118
119
120 ## forward declaration (in lack of backquoting)
121 if not(IsBound(DisplayDocsSig)) then
122 DisplayDocsSig:=
123 function(i) Print("hehe\n");
124 end;
125 fi;
126
127
128 ###
129 ### Display atom funs
130 ###
131 ## The master display function
132 __InstallDocDisplay:=
133 function(field)
134 EvalString("_RetrieveDoc"+Camelcase(field)+":=__RetrieveDocField(\""+Downcase(field)+"\")");
135 EvalString("_DisplayDoc"+Camelcase(field)+"NL:=__CurryPrintFunNL(_RetrieveDoc"+Camelcase(field)+")");
136 EvalString("_DisplayDoc"+Camelcase(field)+"1L:=__CurryPrintFun1L(_RetrieveDoc"+Camelcase(field)+")");
137 EvalString("_DisplayDoc"+Camelcase(field)+"NLie:=__CurryPrintFunNLie(_RetrieveDoc"+Camelcase(field)+")");
138 EvalString("_DisplayDoc"+Camelcase(field)+"1Lie:=__CurryPrintFun1Lie(_RetrieveDoc"+Camelcase(field)+")");
139 EvalString("_DisplayDoc"+Camelcase(field)+":=sep->__CurryPrintFun(sep)(_RetrieveDoc"+Camelcase(field)+")");
140 end;
141
142 __InstallDocDisplay("sig");
143 __InstallDocDisplay("sog");
144
145 _RetrieveDocHash:=__RetrieveDocField("hash");
146 _DisplayDocHashOV:=___CurryPrintFun("[0;1m#")("[0;0m: ")(_RetrieveDocHash);
147 _DisplayDocHashNL:=___CurryPrintFun("[0;0m#")("\n")(_RetrieveDocHash);
148 _DisplayDocHash1L:=___CurryPrintFun("[0;0m#")(": ")(_RetrieveDocHash);
149 _DisplayDocHash:=sep->___CurryPrintFun("[0;0m#")(sep)(_RetrieveDocHash);
150
151 _RetrieveDocPos:=
152 function(docrec)
153 local pos;
154 pos:=_Position_alist_any(__DOC,_GetEntry_rec_string(docrec,"hash",rec(Fail:=FAILURE)),rec(Fail:="----"));
155 pos:=SPrint(pos);
156 return (4-_Size_list(pos))*"0"+pos;
157 end;
158 _DisplayDocPosOV:=___CurryPrintFun("[0;1m")("[0;0m: ")(_RetrieveDocPos);
159 _DisplayDocPosNL:=___CurryPrintFun("[0;0m")("\n")(_RetrieveDocPos);
160 _DisplayDocPos1L:=___CurryPrintFun("[0;0m")(": ")(_RetrieveDocPos);
161 _DisplayDocPosParen:=sep->___CurryPrintFun("[0;0m(")("[0;0m)"+sep)(_RetrieveDocPos);
162 _DisplayDocPos:=sep->___CurryPrintFun("[0;0m")(sep)(_RetrieveDocPos);
163
164 _RetrieveDocKind:=__RetrieveDocField("kind");
165 _DisplayDocKindNL:=___CurryPrintFun("[0;1m")("[0;0m\n")(_RetrieveDocKind);
166 _DisplayDocKind1L:=___CurryPrintFun("[0;1m")("[0;0m:")(_RetrieveDocKind);
167 _DisplayDocKindNLie:=__CurryPrintFunNLie(_RetrieveDocKind);
168 _DisplayDocKind1Lie:=__CurryPrintFun1Lie(_RetrieveDocKind);
169 _DisplayDocKind:=sep->___CurryPrintFun("[0;1m")("[0;0m"+sep)(_RetrieveDocKind);
170
171
172 _RetrieveDocSyntax:=__RetrieveDocField("syntax");
173 _DisplayDocSyntaxNL:=___CurryPrintFunIf("\n[0;1mSYNTAX:[0;0m\n")("\n")(_RetrieveDocSyntax);
174 _DisplayDocSyntax1L:=___CurryPrintFunIf("\nSYNTAX:")(": ")(_RetrieveDocSyntax);
175 _DisplayDocSyntax:=sep->___CurryPrintFunIf("\nSYNTAX:\n")(sep)(_RetrieveDocSyntax);
176
177
178 _RetrieveDocShort:=__RetrieveDocField("short");
179 _DisplayDocShortNL:=___CurryPrintFunIf("[0;1mPURPOSE:[0;0m\n")("\n")(_RetrieveDocShort);
180 _DisplayDocShort1L:=___CurryPrintFunIf("PURPOSE:")(": ")(_RetrieveDocShort);
181 _DisplayDocShort:=sep->___CurryPrintFunIf("PURPOSE:\n")(sep)(_RetrieveDocShort);
182
183
184 _RetrieveDocEx:=docrec->_Mapconcat_func_list_string(i->i,__RetrieveDocField("ex")(docrec),"\n\n");
185 _DisplayDocExNL:=___CurryPrintFunIf("[0;1mEXAMPLE:[0;0m\n")("\n\n")(_RetrieveDocEx);
186 _DisplayDocEx:=sep->___CurryPrintFunIf("EXAMPLE:\n")(sep)(_RetrieveDocEx);
187
188
189 _RetrieveDocSource:=__RetrieveDocField("docsrc");
190 _DisplayDocSourceNL:=___CurryPrintFunIf("[0;1mSOURCE FILES:[0;0m\n")("\n")(_RetrieveDocSource);
191 _DisplayDocSource1L:=___CurryPrintFunIf("SOURCE FILES:")(": ")(_RetrieveDocSource);
192 _DisplayDocSourceNL:=___CurryPrintFunIf("[0;1mSOURCE FILES:[0;0m\n")("\n\n")(_RetrieveDocSource);
193 _DisplayDocSource:=sep->___CurryPrintFunIf("SOURCE FILES:\n")(sep)(_RetrieveDocSource);
194
195
196 _RetrieveDocCite:=__RetrieveDocField("cite");
197 _DisplayDocCiteNL:=___CurryPrintFunIf("[0;1mREFERENCES:[0;0m\n")("\n")(_RetrieveDocCite);
198 _DisplayDocCite1L:=___CurryPrintFunIf("REFERENCES:")(": ")(_RetrieveDocCite);
199 _DisplayDocCiteNL:=___CurryPrintFunIf("[0;1mREFERENCES:[0;0m\n")("\n\n")(_RetrieveDocCite);
200 _DisplayDocCite:=sep->___CurryPrintFunIf("REFERENCES:\n")(sep)(_RetrieveDocCite);
201
202
203 ## forward declare
204 _RetrieveDocSee:=docrec->_Mapconcat_func_list_string(i->"#"+i,__RetrieveDocField("see")(docrec),", ");
205 _RetrieveDocSeeLookup:=docrec->_Apply_list_func(__RetrieveDocField("see")(docrec),i->RetrieveDocumentation(i));
206 _DisplayDocSeeNL:=___CurryPrintFunIf("SEE ALSO: ")("\n\n")(_RetrieveDocSee);
207 _DisplayDocSee1L:=___CurryPrintFunIf("SEE ALSO: ")("; ")(_RetrieveDocSee);
208 _DisplayDocSeeLU:=___CurryPrintFunFC(DisplayDocsSig)("\nSEE ALSO:\n\n")("\n\n")(_RetrieveDocSeeLookup);
209 _DisplayDocSee:=sep->___CurryPrintFunFC(DisplayDocsSig)("[0;1mSEE ALSO:[0;0m\n")(sep)(_RetrieveDocSeeLookup);
210
211 ## handling of optional arguments
212 _RetrieveDocOpt:=docrec->_Mapconcat_func_list_string(i->""+_GenerateDocSinAtom2(i)+"",__RetrieveDocField("opt")(docrec),"\n");
213 _DisplayDocOptNLie:=___CurryPrintFunIf("\n[0;1mOPTIONAL ARGUMENTS:[0;0m\n")("\n")(_RetrieveDocOpt);
214
215
216 ## obscure general display funs
217 _DisplayDoc:=sep->(field->__CurryPrintFun(sep)(__RetrieveDocField(field)));
218 _EmptyNL:=
219 function(arg)
220 Print("\n");
221 end;
222 _Indent1L:=
223 function(arg)
224 Print(" ");
225 end;
226
227
228 ###
229 ### Display Functions
230 ###
231 ## Some hooks
232 DisplayDocSigFormatHook:=
233 [
234 _DisplayDocPos1L,_DisplayDocSig(""),_DisplayDocSogNL];
235 DisplayDocSigShortFormatHook:=
236 [
237 _DisplayDocPos1L,_DisplayDocKind1L,_DisplayDocSig(""),_DisplayDocSogNL,
238 _DisplayDocShortNL];
239 DisplayDocSigShortOneLineFormatHook:=
240 [
241 _DisplayDocPos1L,_DisplayDocKind1L,_DisplayDocSig(""),_DisplayDocSog1L,_DisplayDocShortNL];
242 DisplayDocCompleteFormatHook:=
243 [
244 _DisplayDocHashOV,_DisplayDocKind(" "),_DisplayDocPosParen("\n"),
245 _DisplayDocSig(""),_DisplayDocSogNL,
246 _DisplayDocSyntaxNL,
247 _DisplayDocOptNLie,
248 _EmptyNL,
249 _DisplayDocShortNL,
250 _EmptyNL,
251 _DisplayDocExNL,
252 _DisplayDocSourceNL,
253 _DisplayDocCiteNL,
254 _DisplayDocSee("\n")];
255
256
257 ## MAIN DISPLAY FUNCTIONS
258 DisplayDocSig:=__CurryDisplayHookFun(DisplayDocSigFormatHook);
259 DisplayDocShort:=__CurryDisplayHookFun(DisplayDocSigShortFormatHook);
260 DisplayDocShort1L:=__CurryDisplayHookFun(DisplayDocSigShortOneLineFormatHook);
261 DisplayDocComplete:=__CurryDisplayHookFun(DisplayDocCompleteFormatHook);
262
263
264 ## higher level function for more than 1 docrec
265 _DisplayDocs:=
266 dispfun->
267 (dreclist->
268 Mapc(dispfun,dreclist));
269 DisplayDocsSig:=_DisplayDocs(DisplayDocSig);
270 DisplayDocsSig2:=_DisplayDocs(DisplayDocSig);
271 DisplayDocsShort:=_DisplayDocs(DisplayDocShort);
272 DisplayDocsShort1L:=_DisplayDocs(DisplayDocShort1L);
273
274
275 ## default functions
276 DisplayDoc:=DisplayDocShort1L;
277 DisplayDocs:=DisplayDocsShort1L;
278
279
280
281
282 ## now the most important, the documentation of the documentation ;)
283
284 InstallDocumentation(
285 rec(
286 kind:="FUNCTION",
287 name:="DisplayDocSig",
288 sin:=[[string,"dochash"]],
289 sou:=[],
290 short:="Display name and signature for `dochash' which must be a valid \
291 hash in the internal documentation.",
292 see:=[DocGenHashByString("DisplayDocShort(string)"),
293 DocGenHashByString("DisplayDocComplete(string)")],
294 ex:=["DisplayDocSig(\""+DocGenHashByString("DisplayDocSig(string)")+"\");"]),rec());
295 InstallDocumentation(
296 rec(
297 kind:="FUNCTION",
298 name:="DisplayDocShort",
299 sin:=[[string,"dochash"]],
300 sou:=[],
301 short:="Display name, signature and shortdoc (if existing) for `dochash'.",
302 see:=[DocGenHashByString("DisplayDocSig(string)"),
303 DocGenHashByString("DisplayDocComplete(string)")],
304 ex:=["DisplayDocShort(\""+DocGenHashByString("DisplayDocShort(string)")+"\");"]),rec());
305 InstallDocumentation(
306 rec(
307 kind:="FUNCTION",
308 name:="DisplayDocComplete",
309 sin:=[[string,"dochash"]],
310 sou:=[],
311 short:="Display name, signature and everything else for `dochash'.",
312 see:=[DocGenHashByString("DisplayDocSig(string)"),
313 DocGenHashByString("DisplayDocShort(string)")],
314 ex:=["DisplayDocComplete(\""+DocGenHashByString("DisplayDocComplete(string)")+"\");"]),rec());
315
316
317
318
319 ###
320 ### Higher level Retrieve Funs
321 ###
322 ## You can retrieve a dochash or a list of dochashes with them here
323
324 _FindByPos:=
325 (pos->
326 __DOC[pos]);
327 _FindBySexp:=
328 field->
329 (sexp->
330 _Filtered_list_func(__DOC,i->sexp=i.(field)));
331 _FindByISexp:=
332 field->
333 (sexp->
334 _Filtered_list_func(__DOC,i->Downcase(sexp)=Downcase(i.(field))));
335 _FindBySexpAndKind:=
336 kind->
337 (field->
338 (sexp->
339 _Filtered_list_func(_FindBySexp(field)(sexp),i->i.kind=kind)));
340 _FindByISexpAndKind:=
341 kind->
342 (field->
343 (sexp->
344 _Filtered_list_func(_FindBySexp(field)(sexp),i->i.kind=kind)));
345 _FindByRexp:=
346 field->
347 (rexp->
348 _Filtered_list_func(__DOC,i->IsMatching(rexp,i.(field))));
349 _FindByIRexp:=
350 field->
351 (rexp->
352 _Filtered_list_func(__DOC,i->IsMatching(Downcase(rexp),Downcase(i.(field)))));
353
354
355 _IfFieldBoundp:=
356 function(record,field,default)
357 local prfun,gr;
358 prfun:=
359 function(lit)
360 if Type(lit)=string then
361 return lit;
362 elif IsList(lit) then
363 return _Mapconcat_func_list(i->prfun(i),lit);
364 else
365 return default;
366 fi;
367 end;
368
369 gr := _GetEntry_rec_string(record,field,rec(Fail:=FAILURE));
370 if gr=FAILURE then
371 return default;
372 else
373 return prfun(gr);
374 fi;
375 end;
376 _FindByRexps:=
377 fields->
378 (rexp->
379 _Filtered_list_func(__DOC,i->_ForAny_list_func(fields,j->IsMatching(rexp,_IfFieldBoundp(i,j,"")))));
380 _FindByIRexps:=
381 fields->
382 (rexp->
383 _Filtered_list_func(__DOC,i->_ForAny_list_func(fields,j->IsMatching(Downcase(rexp),Downcase(_IfFieldBoundp(i,j,""))))));
384 _FindByRexpAndKind:=
385 kind->
386 (field->
387 (rexp->
388 _Filtered_list_func(_FindByRexp(field)(rexp),i->i.kind=kind)));
389 _FindByIRexpAndKind:=
390 kind->
391 (field->
392 (rexp->
393 _Filtered_list_func(_FindByIRexp(field)(rexp),i->i.kind=kind)));
394 _FindByRexpsAndKind:=
395 kind->
396 (fields->
397 (rexp->
398 _Filtered_list_func(_FindByRexps(fields)(rexp),i->i.kind=kind)));
399 _FindByIRexpsAndKind:=
400 kind->
401 (fields->
402 (rexp->
403 _Filtered_list_func(_FindByIRexps(fields)(rexp),i->i.kind=kind)));
404
405
406 DocFindNames:=_FindByISexp("name");
407 DocFindNamesCS:=_FindBySexp("name");
408 DocFindNamesLimitTo:=kind->_FindByISexpAndKind(kind)("name");
409 DocFindNamesCSLimitTo:=kind->_FindBySexpAndKind(kind)("name");
410
411 DocFindMatchingNames:=_FindByIRexp("name");
412 DocFindMatchingNamesCS:=_FindByRexp("name");
413 DocFindMatchingNamesLimitTo:=kind->_FindByIRexpAndKind(kind)("name");
414 DocFindMatchingNamesCSLimitTo:=kind->_FindByRexpAndKind(kind)("name");
415
416 DocFindMatchingNamesOrShort:=_FindByIRexps(["name","short","opt"]);
417 DocFindMatchingNamesOrShortCS:=_FindByRexps(["name","short","opt"]);
418 DocFindMatchingNamesOrShortLimitTo:=kind->_FindByIRexpsAndKind(kind)(["name","short","opt","ex"]);
419 DocFindMatchingNamesOrShortCSLimitTo:=kind->_FindByRexpsAndKind(kind)(["name","short","opt","ex"]);
420
421
422 ##Mapc(i->EvalString("DocFind"+Camelcase(i)+"Names:=_FindByISexpAndKind(\""+ i + "\")(\"name\")"),__DocumentationKinds);
423 ##Mapc(i->EvalString("DocFind"+Camelcase(i)+"NamesCS:=_FindBySexpAndKind(\""+ i + "\")(\"name\")"),__DocumentationKinds);
424
425 ##Mapc(i->EvalString("DocFindMatching"+Camelcase(i)+"Names:=_FindByIRexpAndKind(\""+ i + "\")(\"name\")"),__DocumentationKinds);
426 ##Mapc(i->EvalString("DocFindMatching"+Camelcase(i)+"NamesCS:=_FindByRexpAndKind(\""+ i + "\")(\"name\")"),__DocumentationKinds);
427
428
429
430 DocDisplayMatching:=
431 rexp->
432 Mapc(DisplayDocShort,DocFindMatchingNames(rexp));
433
434 ##Mapc(i->EvalString("DocDisplayMatching"+Camelcase(i)+"s:=rexp->Mapc(DisplayDocShort1L,DocFindMatching"+Camelcase(i)+"Names(rexp))"),__DocumentationKinds);
435
436
437
438
439
440 ### signature
441 #
442 __DocFindMatchingSignatures:=
443 record->
444 (field->
445 (function(arg)
446 local A,match,typ,I;
447 match:=[];
448 if _Size_list(arg)=0 then
449 typ:=void;
450 elif _Size_list(arg)=1 then
451 typ:=arg[1];
452 else
453 return match;
454 fi;
455 for A in record do
456 if IsBound(A.(field)) and IsList(A.(field)) then
457 for I in A.(field) do
458 if IsList(I) and IsBound(I[1]) then
459 if I[1]=typ then
460 _Add__list_any(match,A);
461 fi;
462 elif typ=void then
463 _Add__list_any(match,A);
464 fi;
465 od;
466 fi;
467 od;
468 return match;
469 end));
470 _DocFindMatchingSignatures:=__DocFindMatchingSignatures(__DOC);
471 _DocDisplayMatchingSignatures:=
472 field->
473 (type->
474 Mapc(DisplayDocSig,_DocFindMatchingSignatures(field)(type)));
475
476
477 DocFindMatchingSignaturesIn:=_DocFindMatchingSignatures("sin");
478 DocDisplayMatchingSignaturesIn:=_DocDisplayMatchingSignatures("sin");
479
480 DocFindMatchingSignaturesOut:=_DocFindMatchingSignatures("sin");
481 DocDisplayMatchingSignaturesOut:=_DocDisplayMatchingSignatures("sou");
482
483
484 DisplayDocShortThreshold:=1;
485
486
487 #############################################################################
488 ##
489 #F Help( <various> )
490 ##
491 Help:=i->i; ## just a dummy
492 _ParseHelp:=
493 function(search)
494 local typ, submatch, lim, limp, gather, i;
495
496 gather:=[];
497 limp:=false;
498
499 ### search by hash
500 submatch:=StringMatch("^#*\\([0-9a-f]\\{6\\}\\)$",Downcase(search));
501 if IsBound(submatch[2]) then
502 gather:=[RetrieveDocumentation(submatch[2])];
503 fi;
504
505 ## if more than one hash
506 submatch:=StringMatch("^\\(.*\\)[, :]+#*\\([0-9a-f]\\{6\\}\\)",Downcase(search));
507 if IsBound(submatch[3]) then
508 Help(submatch[2]);
509 gather:=[RetrieveDocumentation(submatch[3])];
510 fi;
511
512
513 ### search by pos
514 submatch:=StringMatch("^\\([0-9]\\{1,4\\}\\)$",search);
515 if IsBound(submatch[2]) then
516 i:=EvalString(submatch[2]);
517 gather:=[_GetEntry_list_eor(__DOC,i,rec(Fail:=""))];
518 fi;
519
520 ## if more than one pos
521 submatch:=StringMatch("^\\(.*\\)[, :]+\\([0-9]\\{1,4\\}\\)",search);
522 if IsBound(submatch[3]) then
523 Help(submatch[2]);
524 i:=EvalString(submatch[3]);
525 gather:=[_GetEntry_list_eor(__DOC,i,rec(Fail:=""))];
526 fi;
527
528
529 lim:=__DOC;
530 submatch:=StringMatch("(\\(.*\\))",search);
531 if not(_GetEntry_list_eor(submatch,2,rec(Fail:=""))="") then
532 submatch:=Split(submatch[2],",");
533 if _GetEntry_list_eor(submatch,1,rec(Fail:=""))="" then
534 submatch:=["void"];
535 fi;
536 typ := _Apply_func_list(EvalString,submatch);
537 if _ForAny_list_func(typ,i->Type(i)<>type) then
538 Print("?(<type>) expected.\n");
539 typ:=[];
540 lim:=[];
541 fi;
542 for i in typ do
543 lim:=__DocFindMatchingSignatures(lim)("sin")(i);
544 od;
545 limp:=true;
546 fi;
547
548 submatch:=StringMatch("->\\([^ ]*\\)",search);
549 if not(_GetEntry_list_eor(submatch,2,rec(Fail:=""))="") then
550 submatch:=Split(submatch[2],",");
551 if _GetEntry_list_eor(submatch,1,rec(Fail:=""))="" then
552 submatch:=["void"];
553 fi;
554 typ := _Apply_func_list(EvalString,submatch);
555 if _ForAny_list_func(typ,i->Type(i)<>type) then
556 Print("?-><type> expected.\n");
557 typ:=[];
558 lim:=[];
559 fi;
560 for i in typ do
561 lim:=__DocFindMatchingSignatures(lim)("sou")(i);
562 od;
563 limp:=true;
564 fi;
565 if limp then
566 gather:=lim;
567 fi;
568
569
570 ## general string searches
571 submatch:=StringMatch("^\\(.\\)\\(.+\\)|\\(.*\\)",search);
572 if IsBound(submatch[3]) then
573
574 if (submatch[2]="*") then
575 gather:=DocFindMatchingNamesOrShortLimitTo(Upcase(submatch[4]))(submatch[3]);
576
577 elif (submatch[2]="!") then
578 gather:=DocFindMatchingNamesLimitTo(Upcase(submatch[4]))(submatch[3]);
579
580 elif (submatch[2]="^") then
581 gather:=DocFindMatchingNamesLimitTo(Upcase(submatch[4]))("^"+submatch[3]);
582
583 else
584 gather:=DocFindNamesLimitTo(Upcase(submatch[3]))(submatch[2]+submatch[3]);
585 fi;
586
587 else
588
589 ## now match again, but w/o the | operator
590 submatch:=StringMatch("^\\(.\\)\\(.+\\)",search);
591 if not(_GetEntry_list_eor(submatch,3,rec(Fail:=""))="") then
592
593 if (submatch[2]="*") then
594 gather:=DocFindMatchingNamesOrShort(submatch[3]);
595
596 elif (submatch[2]="!") then
597 gather:=DocFindMatchingNames(submatch[3]);
598
599 elif (submatch[2]="^") then
600 gather:=DocFindMatchingNames("^"+submatch[3]);
601 fi;
602
603 fi;
604
605 fi;
606
607 Append_(gather,DocFindNames(search));
608
609 return gather;
610 end;
611
612
613 Help := function(query)
614 local search, submatch, gather;
615
616 search := Copy(query);
617
618 ## cleansing query
619 submatch:=StringMatch("^[ \t]*",search);
620 if IsBound(submatch[1]) then
621 search:=search{[_Size_list(submatch[1])+1.._Size_list(search)]};
622 fi;
623
624 submatch:=StringMatch("[ \t]*;?$",search);
625 if IsBound(submatch[1]) then
626 search:=search{[1.._Size_list(search)-_Size_list(submatch[1])]};
627 fi;
628
629 if search="" or search=";" then
630 search:="Help";
631 fi;
632
633
634 ## parsing
635 gather:=_Filtered_list_func(_ParseHelp(search),i->i<>__EmptyDoc);
636
637 ## output
638 if _Size_list(gather)=0 then
639 PrintString("\nNo matches.\nMaybe try ?*<string>.\n");
640 elif _Size_list(gather)<=DisplayDocShortThreshold then
641 Print("\n");
642 Mapc(DisplayDocComplete,gather);
643 else
644 Print("\n");
645 Mapc(DisplayDocSig,gather);
646 Print("\n");
647 fi;
648 end;
649
650
651 if _DocDebug and not(QUIET) and not(IsBound(__looserefswarned)) then
652 __LooseRefs:=_Filtered_func_list(i->_ForAny_list_func(_GetEntry_rec_string(i,"see",rec(Fail:=[])),k->not(ExistsDocumentation(k))),__DOC);
653 if _Size_list(__LooseRefs)>0 then
654 PrintString("\n");
655 PrintString("##############################################################################\n");
656 PrintString("## Nirvana references in see fields detected. ##\n");
657 PrintString("## See `Apply(i->i.hash,__LooseRefs);' for a list of the referring entries. ##\n");
658 PrintString("##############################################################################\n");
659 fi;
660 __looserefswarned:=true;
661 fi;