[BACK]Return to genhelp.k CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097 / Doc

Annotation of OpenXM/src/k097/Doc/genhelp.k, Revision 1.1

1.1     ! takayama    1: /* $OpenXM$ */
        !             2:
        !             3: /* Todo
        !             4:
        !             5:   * Helplist should be sorted.
        !             6:   * Ex. should be removed.
        !             7:   * Args and references should be given in the Helplist.
        !             8:
        !             9: */
        !            10:
        !            11: def foo() {
        !            12:   local n,i,key,s,aaa,ref;
        !            13:
        !            14:   Println("DO NOT EDIT THIS FILE. ");
        !            15:   Println("It is AUTHOMATICALLY GENERATED.");
        !            16:   sm1(" (cat standard-0.texi) system ");
        !            17:   n = Length(Helplist);
        !            18:   Println("/*&C ");
        !            19:   Println("@menu ");
        !            20:   for (i=0; i<n; i++) {
        !            21:     Print("* "); Print(Helplist[i,0]); Println("::");
        !            22:   }
        !            23:   Println("@end menu"); Ln();
        !            24:   Println(" */"); Ln();
        !            25:
        !            26:   n = Length(Helplist);
        !            27:   for (i=0; i<n; i++) {
        !            28:      Print("//&C @c "); Println(i);
        !            29:      key = Helplist[i,0];
        !            30:      s = Helplist[i,1];
        !            31:      if (Length(Helplist[i]) > 2) {
        !            32:        aaa = Helplist[i,2];
        !            33:        ref = Helplist[i,3];
        !            34:      }else{
        !            35:        aaa = " (?) ";
        !            36:        ref = "Not yet written.";
        !            37:      }
        !            38:      printItem(key,s,aaa,ref);
        !            39:   }
        !            40:
        !            41:   sm1(" (cat standard-1.texi) system ");
        !            42:
        !            43: }
        !            44:
        !            45: def printItem(key,s,aaa,ref) {
        !            46:   local desc,example;
        !            47:   desc = splitExample(s);
        !            48:
        !            49:   Println("/*&en ");
        !            50:   Print("@c  "); Print(" -------------  start of ");
        !            51:   Print(key); Println(" --------------");
        !            52:   Println("@menu");
        !            53:   Print("* "); Print(key); Println("::");
        !            54:   Println("@end menu");
        !            55:   Print("@node "); Print(key); Println(",,, STANDARD function");
        !            56:   Print("@subsection @code{"); Print(key); Println("}");
        !            57:   Print("@findex "); Println(key);
        !            58:   Println("@table @t");
        !            59:   Print("@item "); Print(key);  Println(aaa);
        !            60:   Print(":: "); Println(desc[0]);
        !            61:   Println("@end table");
        !            62:   Ln();
        !            63:   Println(" */");
        !            64:
        !            65:   Println("/*&en ");
        !            66:   Println("@itemize @bullet");
        !            67:   Print("@item "); Println(desc[0]);
        !            68:   Println("@end itemize");
        !            69:   Println(" */ ");
        !            70:
        !            71:   if (Length(desc) == 2) {
        !            72:     Println("/*&C ");
        !            73:     Println("@example");
        !            74:     Println(desc[1]);
        !            75:     Println("@end example");
        !            76:     Ln();
        !            77:     Println(" */ ");
        !            78:   }
        !            79:   Println("/*&C ");
        !            80:   Println("@table @t");
        !            81:   Println("@item Reference");
        !            82:   Println(ref);
        !            83:   Println("@end table");
        !            84:   Ln();
        !            85:   Println(" */ ");
        !            86: }
        !            87:
        !            88: def findKey(keys,s) {
        !            89:   local n,m,i,j,r,k,ii,II;
        !            90:   s = StringToAsciiArray(s);
        !            91:   II = Length(keys);
        !            92:   for (ii=0; ii<II; ii++) {
        !            93:     k = StringToAsciiArray(keys[ii]);
        !            94:     n = Length(k); m = Length(s);
        !            95:     i = 0;
        !            96:     while( i<m-n ) {
        !            97:       r = true;
        !            98:       for (j=0; j<n; j++) {
        !            99:         if (k[j] != s[i+j]) {
        !           100:            r = false;
        !           101:         }
        !           102:       }
        !           103:       if (r == true) return(true);
        !           104:       i++;
        !           105:     }
        !           106:   }
        !           107:   return(false);
        !           108: }
        !           109:
        !           110: def splitExample(s) {
        !           111:   local desc,example,n,i,inExample,newl,news,tt;
        !           112:   if (IsArray(s) && Length(s) == 1) {
        !           113:     s = s[0];
        !           114:   }
        !           115:   if (IsString(s)) {
        !           116:     s = StringToAsciiArray(s);
        !           117:     tt = [ ];
        !           118:     news = [ ];
        !           119:     n = Length(s);
        !           120:     for (i=0; i<n; i++) {
        !           121:       tt = Append(tt,s[i]);
        !           122:       if (s[i] == 10) {
        !           123:         if (Length(tt) > 0) {
        !           124:           tt = Map(tt,"AsciiToString");
        !           125:           tt = AddString(tt);
        !           126:         }else{
        !           127:           tt = AsciiToString(10);
        !           128:         }
        !           129:         news = Append(news,tt);
        !           130:         tt = [ ];
        !           131:       }
        !           132:     }
        !           133:     if (Length(tt) > 0) {
        !           134:        tt = Map(tt,"AsciiToString");
        !           135:        tt = AddString(tt);
        !           136:        news = Append(news, tt);
        !           137:     }
        !           138:     s = news;
        !           139:   }
        !           140:   n = Length(s);
        !           141:   inExample = false;
        !           142:   newl = AsciiToString(10);
        !           143:   desc = " "; example = " ";
        !           144:   i = 0;
        !           145:   while (i<n) {
        !           146:     if (findKey(["Ex.","Example","example"],s[i])) {
        !           147:       inExample = true;
        !           148:     }
        !           149:     s[i] = addEscape(s[i]);
        !           150:     if (inExample) {
        !           151:       example = AddString([example,newl,s[i]]);
        !           152:     }else{
        !           153:       desc = AddString([desc,newl,s[i]]);
        !           154:     }
        !           155:     i++;
        !           156:   }
        !           157:   if (Length(example) < 2) {
        !           158:      return([desc]);
        !           159:   }else{
        !           160:     return([desc,example]);
        !           161:   }
        !           162: }
        !           163:
        !           164: def addEscape(s) {
        !           165:   local i,n,ans,leftCurryBrace,rightCurryBrace,at;
        !           166:   leftCurryBrace = 123;
        !           167:   rightCurryBrace = 125;
        !           168:   at = 64;
        !           169:   s = StringToAsciiArray(s);
        !           170:   n = Length(s);
        !           171:   ans = [ ];
        !           172:   for (i=0; i<n; i++) {
        !           173:     if (s[i] == leftCurryBrace) {
        !           174:       ans = Join(ans,[64,leftCurryBrace]);
        !           175:     }else if (s[i] == rightCurryBrace) {
        !           176:       ans = Join(ans,[64,rightCurryBrace]);
        !           177:     }else{
        !           178:       ans = Append(ans,s[i]);
        !           179:     }
        !           180:   }
        !           181:   return(AddString(Map(ans,"AsciiToString")));
        !           182: }
        !           183:
        !           184: foo();

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>