Back to index

plt-scheme  4.2.1
generatedoc.c
Go to the documentation of this file.
00001 /*   wbuild
00002      Copyright (C) 1996  Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
00003      
00004      This program is free software; you can redistribute it and/or
00005      modify it under the terms of the GNU General Public License
00006      as published by the Free Software Foundation; either version 2
00007      of the License, or (at your option) any later version.
00008      
00009      This program is distributed in the hope that it will be useful,
00010      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012      GNU General Public License for more details.
00013      
00014      You should have received a copy of the GNU General Public License
00015      along with this program; if not, write to the Free Software
00016      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 
00020 #define fputS(s, f) = fputs(get(s), f)
00021 
00022 #include <config.h>
00023 #include <stdio.h>
00024 #include <libit/unistd.h>
00025 #include <libit/string.h>
00026 #include <libit/ctype.h>
00027 #include <wbuild.h>
00028 #include <wsym.h>
00029 
00030 #include <libintl.h>
00031 #define _(String) gettext(String)
00032 
00033 #include <libit/malloc.h>
00034 
00035 /* Document tags. In the documentation file various tags indicate the
00036  * sections of the text. The tags can be in four formats (|DOCTYPES = 3|):
00037  * \TeX, Nroff, {\sc sgml}, or TexInfo. The following table contains all
00038  * the tags. The * enumerated type defines symbolic names for the tags.
00039  * The tags come in * pairs, like opening and closing brackets.
00040  *
00041  * The second half of the tags contains symbolic names for characters
00042  * that are special to \TeX.
00043  *
00044  * |doctp| is the type of documentation that will be generated: 0
00045  * for \TeX, 2 for Nroff, 1 for {\sc sgml}, 3 for TeXinfo.
00046  */
00047 
00048 #define topen(tg) (tag[tg][0])
00049 #define tclose(tg) (tag[tg][1])
00050 
00051 /* |putcode| is used to write C code that might contain
00052  * characters that are special to \TeX. It also expands tabs.
00053  */
00054 
00055 static void putcode(STRING text, FILE *f, tagpair *tag)
00056 {
00057        char *p;
00058        int col = 0;
00059        if (text) {
00060               for (p = get(text); *p; p++) {
00061                      switch (*p) {
00062                             case '_': fputs(topen(t_underline), f);
00063                                    col++; break;
00064                             case '\\': fputs(topen(t_backslash), f);
00065                                    col++; break;
00066                             case '~': fputs(topen(t_tilde), f);
00067                                    col++; break;
00068                             case '#': fputs(topen(t_hashmark), f);
00069                                    col++; break;
00070                             case '$': fputs(topen(t_dollar), f);
00071                                    col++; break;
00072                             case '%': fputs(topen(t_percent), f);
00073                                    col++; break;
00074                             case '^': fputs(topen(t_caret), f);
00075                                    col++; break;
00076                             case '<': fputs(topen(t_less), f);
00077                                    col++; break;
00078                             case '>': fputs(topen(t_greater), f);
00079                                    col++; break;
00080                             case '&': fputs(topen(t_ampersand), f);
00081                                    col++; break;
00082                             case '{': fputs(topen(t_lbrace), f);
00083                                    col++; break;
00084                             case '}': fputs(topen(t_rbrace), f);
00085                                    col++; break;
00086                             case '|': fputs(topen(t_bar), f);
00087                                    col++; break;
00088                             case '@': fputs(topen(t_at), f);
00089                                    col++; break;
00090                             case '\n': putc('\n', f);
00091                                    col = 0; break;
00092                             case '\t':
00093                                    do {
00094                                           putc(' ', f);
00095                                    } while (++col % 8 != 0);
00096                                    break;
00097                             default: putc(*p, f); col++;
00098                      }
00099               }
00100        }
00101 }
00102 
00103 
00104 /* The function |print_text_par| copies text to the documentation file
00105  * and ends it with an empty line. Text between vertical bars is set in
00106  * typewriter type with special characters quoted.
00107  *
00108  * The function checks for an even number of vertical bars and inserts an
00109  * extra closing brace if the final bar is missing.
00110  */
00111 
00112 static void print_text_par(FILE *f, tagpair *tag, STRING text,
00113        STRING file, int lineno)
00114 {
00115        char *p;
00116        int between_bars;
00117 
00118        if (!text)
00119               return;
00120        between_bars = 0;
00121        for (p = get(text); *p; p++) {
00122               if (between_bars) {
00123                      switch (*p) {
00124                             case '_': fputs(topen(t_underline), f); break;
00125                             case '\\': fputs(topen(t_backslash), f); break;
00126                             case '~': fputs(topen(t_tilde), f); break;
00127                             case '#': fputs(topen(t_hashmark), f); break;
00128                             case '$': fputs(topen(t_dollar), f); break;
00129                             case '%': fputs(topen(t_percent), f); break;
00130                             case '^': fputs(topen(t_caret), f); break;
00131                             case '&': fputs(topen(t_ampersand), f); break;
00132                             case '{': fputs(topen(t_lbrace), f); break;
00133                             case '}': fputs(topen(t_rbrace), f); break;
00134                             case '@': fputs(topen(t_at), f); break;
00135                             case '|':
00136                                    fputs(tclose(t_inline), f);
00137                                    between_bars = 0;
00138                                    break;
00139                             default: putc(*p, f);
00140                      }
00141               } else if (*p == '|') {
00142                      between_bars = 1;
00143                      fputs(topen(t_inline), f);
00144               } else {
00145                      putc(*p, f);
00146               }
00147        }
00148        if (between_bars) {
00149               fprintf(stderr, _("%s:%d: unmatched \"|\" in text\n"),
00150                      get(file), lineno);
00151               nerrors++;
00152               fputs(tclose(t_inline), f); /* make TeX happy */
00153        }
00154        putc('\n', f); (void) putc('\n', f);
00155 }
00156 
00157 inline static void import_file(FILE *f, tagpair *tag, Section s)
00158 {
00159        fputs(topen(t_code), f);
00160        fputs(topen(t_incl), f);
00161        putc(' ', f);
00162        putcode(s->decl->name, f, tag);
00163        fputs(tclose(t_code), f);
00164 }
00165 
00166 /* The function name and body are taken from |s|, but the type and
00167  * parameters are taken from |s2|. |s2| may be the same as |s|, but for
00168  * inherited methods, it should point to the first definition of the
00169  * function.
00170  */
00171 
00172 inline static void function(FILE *f, tagpair *tag, Section s, Section s2)
00173 {
00174        Decl d1;
00175 
00176        fputs(topen(t_code), f);
00177        if (s2->decl->type) {
00178               putcode(s2->decl->type, f, tag);
00179               putc(' ', f);
00180        }
00181        putcode(s->decl->name, f, tag);
00182        putc('(', f);
00183        if (s2->decl->params) {
00184               for (d1 = s2->decl->params; d1; d1 = d1->next) {
00185                      if (d1->type) {
00186                             putcode(d1->type, f, tag);
00187                             putc(' ', f);
00188                      }
00189                      putcode(d1->name, f, tag);
00190                      if (d1->suffix)
00191                             putcode(d1->suffix, f, tag);
00192                      if (d1->next)
00193                             fputs(", ", f);
00194               }
00195        }
00196        putc(')', f);
00197        putc('\n', f);
00198        if (s->decl->body)
00199               putcode(s->decl->body, f, tag);
00200        fputs(tclose(t_code), f);
00201 }
00202 
00203 inline static void variable(FILE *f, tagpair *tag, Section s)
00204 {
00205        fputs(topen(t_code), f);
00206        putcode(s->decl->type, f, tag);
00207        if (s->decl->type)
00208               putc(' ', f);
00209        putcode(s->decl->name, f, tag);
00210        if (s->decl->suffix)
00211               putcode(s->decl->suffix, f, tag);
00212        if (s->decl->value) {
00213               fputs(" = ", f);
00214               putcode(s->decl->value, f, tag);
00215        }
00216        fputs(tclose(t_code), f);
00217 }
00218 
00219 inline static void type(FILE *f, tagpair *tag, Section s)
00220 {
00221        fputs(topen(t_code), f);
00222        fputs(topen(t_type), f);
00223        putc(' ', f);
00224        putcode(s->decl->name, f, tag);
00225        fputs(" = ", f);
00226        putcode(s->decl->type, f, tag);
00227        fputs(tclose(t_code), f);
00228 }
00229 
00230 inline static void macro(FILE *f, tagpair *tag, Section s)
00231 {
00232        Decl d1;
00233 
00234        fputs(topen(t_macro), f);
00235        putcode(s->decl->name, f, tag);
00236        if (s->decl->params) {
00237               putc('(', f);
00238               for (d1 = s->decl->params; d1; d1 = d1->next) {
00239                      putcode(d1->name, f, tag);
00240                      if (d1->next)
00241                             fputs(", ", f);
00242               }
00243               fputs(") =\n", f);
00244        } else {
00245               fputs(" = ", f);
00246        }
00247        putcode(s->decl->body, f, tag);
00248        fputs(tclose(t_macro), f);
00249 }
00250 inline static void chapter_title_intro(FILE *f, tagpair *tag, Class c)
00251 {
00252        fputs(topen(t_class), f);
00253        fputs(topen(t_name), f);
00254        putcode(c->name, f, tag);
00255        fputs(tclose(t_name), f);
00256        if (topen(t_name2)) {
00257               fputs(topen(t_name2), f);
00258               putcode(c->name, f, tag);
00259               fputs(tclose(t_name2), f);
00260        }
00261        print_text_par(f, tag, c->text, c->filename, c->lineno);
00262 }
00263 
00264 
00265 /* The table is started with |\restable{name}| and ends with
00266  * |\endrestable|. The `name' is the name of the class in which the
00267  * public variables (resources) are defined.
00268  */
00269 
00270 
00271 inline static void public_variables_table(FILE *f, tagpair *tag, Class c)
00272 {
00273        Section s;
00274 
00275        fputs(topen(t_table), f);
00276        fputs(topen(t_tablehead), f);
00277        putcode(c->name, f, tag);
00278        fputs(tclose(t_tablehead), f);
00279        for (s = c->publicvars; s; s = s->next) {
00280               if (s->decl && find_instvar_class(c, s->decl->name) == c) {
00281                      fputs(topen(t_row), f);
00282                      fputs(topen(t_resname), f);
00283                      if (s->decl->namesym) {
00284                             putcode(s->decl->namesym, f, tag);
00285                      } else {
00286                             fputs("XtN", f);
00287                             putcode(s->decl->name, f, tag);
00288                      }
00289                      fputs(tclose(t_resname), f);
00290                      fputs(topen(t_resclass), f);
00291                      fputs("XtC", f);
00292                      if (s->decl->namesym)
00293                             putcode(get_classname(s->decl->namesym),
00294                                    f, tag);
00295                      else
00296                             putcode(get_classname(s->decl->name), f, tag);
00297                      fputs(tclose(t_resclass), f);
00298                      fputs(topen(t_restype), f);
00299                      /* (void) fputs("XtR", f); */
00300                      if (s->decl->typesym)
00301                             putcode(s->decl->typesym, f, tag);
00302                      else
00303                             putcode(s->decl->type, f, tag);
00304                      fputs(tclose(t_restype), f);
00305                      fputs(topen(t_resdefault), f);
00306                      putcode(s->decl->value, f, tag);
00307                      fputs(tclose(t_resdefault), f);
00308                      fputs(tclose(t_row), f);
00309               }
00310        }
00311        fputs(tclose(t_table), f);
00312 }
00313 
00314 /* The section on public instance variables (resources) contains only
00315  * the variables that are new in this widget. The inherited resources
00316  * will be listed in the next section. However, if an inherited resource
00317  * is give a new default value (and an explanatory text), that variable
00318  * will be given here also.
00319  */
00320 
00321 
00322 inline static void public_variables(FILE *f, tagpair *tag, Class c,
00323        int shortdoc)
00324 {
00325        Section s;
00326 
00327        if (c->publicvars != NULL) {
00328               fputs(topen(t_publicvars), f);
00329               public_variables_table(f, tag, c);
00330               for (s = c->publicvars; s; s = s->next) {
00331                      fputs(topen(t_section), f);
00332                      if (s->decl) {
00333                             fputs(topen(t_publicvar), f);
00334                             if (s->decl->namesym) {
00335                                    putcode(s->decl->namesym, f, tag);
00336                             } else {
00337                                    fputs("XtN", f);
00338                                    putcode(s->decl->name, f, tag);
00339                             }
00340                             fputs(tclose(t_publicvar), f);
00341                      }
00342                      print_text_par(f, tag, s->text, c->filename, c->lineno);
00343                      if (!shortdoc && s->decl) {
00344                             /* (void) fputs(topen(t_code), f); */
00345                             if (s->decl->typesym) {
00346                                    fputs(topen(t_less), f);
00347                                    putcode(s->decl->typesym, f, tag);
00348                                    fputs(topen(t_greater), f);
00349                                    putc(' ', f);
00350                             }
00351                             putcode(s->decl->type, f, tag);
00352                             putc(' ', f);
00353                             putcode(s->decl->name, f, tag);
00354                             if (s->decl->suffix)
00355                                    putcode(s->decl->suffix, f, tag);
00356                             if (s->decl->namesym) {
00357                                    fputs(topen(t_less), f);
00358                                    putcode(s->decl->namesym, f, tag);
00359                                    fputs(topen(t_greater), f);
00360                                    putc(' ', f);
00361                             }
00362                             fputs(" = ", f);
00363                             if (s->decl->valuesym) {
00364                                    fputs(topen(t_less), f);
00365                                    putcode(s->decl->valuesym, f, tag);
00366                                    fputs(topen(t_greater), f);
00367                             }
00368                             putcode(s->decl->value, f, tag);
00369                             /* (void) fputs(tclose(t_code), f); */
00370                      }
00371                      fputs(tclose(t_section), f);
00372               }
00373               fputs(tclose(t_publicvars), f);
00374        }
00375 }
00376 
00377 inline static void constraint_resources_table(FILE *f, tagpair *tag, Class c)
00378 {
00379        Section s;
00380 
00381        fputs(topen(t_table), f);
00382        fputs(topen(t_tablehead), f);
00383        putcode(c->name, f, tag);
00384        fputs(tclose(t_tablehead), f);
00385        for (s = c->constraints; s; s = s->next) {
00386               if (s->decl && find_constr_class(c, s->decl->name) == c) {
00387                      fputs(topen(t_row), f);
00388                      fputs(topen(t_resname), f);
00389                      if (s->decl->namesym) {
00390                             putcode(s->decl->namesym, f, tag);
00391                      } else {
00392                             fputs("XtN", f);
00393                             putcode(s->decl->name, f, tag);
00394                      }
00395                      fputs(tclose(t_resname), f);
00396                      fputs(topen(t_resclass), f);
00397                      fputs("XtC", f);
00398                      if (s->decl->namesym)
00399                             putcode(get_classname(s->decl->namesym),
00400                                    f, tag);
00401                      else
00402                             putcode(get_classname(s->decl->name), f, tag);
00403                      fputs(tclose(t_resclass), f);
00404                      fputs(topen(t_restype), f);
00405                      /* (void) fputs("XtR", f); */
00406                      if (s->decl->typesym)
00407                             putcode(s->decl->typesym, f, tag);
00408                      else
00409                             putcode(s->decl->type, f, tag);
00410                      fputs(tclose(t_restype), f);
00411                      fputs(topen(t_resdefault), f);
00412                      putcode(s->decl->value, f, tag);
00413                      fputs(tclose(t_resdefault), f);
00414                      fputs(tclose(t_row), f);
00415               }
00416        }
00417        fputs(tclose(t_table), f);
00418 }
00419 
00420 
00421 inline static void constraint_resources(FILE *f, tagpair *tag, Class c,
00422        int shortdoc)
00423 {
00424        Section s;
00425 
00426        if (c->constraints != NULL) {
00427               fputs(topen(t_constraints), f);
00428               constraint_resources_table(f, tag, c);
00429               for (s = c->constraints; s; s = s->next) {
00430                      fputs(topen(t_section), f);
00431                      if (s->decl) {
00432                             fputs(topen(t_constraint), f);
00433                             if (s->decl->namesym) {
00434                                    putcode(s->decl->namesym, f, tag);
00435                             } else {
00436                                    fputs("XtN", f);
00437                                    putcode(s->decl->name, f, tag);
00438                             }
00439                             fputs(tclose(t_constraint), f);
00440                      }
00441                      print_text_par(f, tag, s->text, c->filename, c->lineno);
00442                      if (!shortdoc && s->decl) {
00443                             /* (void) fputs(topen(t_code), f); */
00444                             if (s->decl->typesym) {
00445                                    fputs(topen(t_less), f);
00446                                    putcode(s->decl->typesym, f, tag);
00447                                    fputs(topen(t_greater), f);
00448                                    putc(' ', f);
00449                             }
00450                             putcode(s->decl->type, f, tag);
00451                             putc(' ', f);
00452                             putcode(s->decl->name, f, tag);
00453                             if (s->decl->suffix)
00454                                    putcode(s->decl->suffix, f, tag);
00455                             if (s->decl->namesym) {
00456                                    fputs(topen(t_less), f);
00457                                    putcode(s->decl->namesym, f, tag);
00458                                    fputs(topen(t_greater), f);
00459                                    putc(' ', f);
00460                             }
00461                             fputs(" = ", f);
00462                             if (s->decl->valuesym) {
00463                                    fputs(topen(t_less), f);
00464                                    putcode(s->decl->valuesym, f, tag);
00465                                    fputs(topen(t_greater), f);
00466                             }
00467                             putcode(s->decl->value, f, tag);
00468                             /* (void) fputs(tclose(t_code), f); */
00469                      }
00470                      fputs(tclose(t_section), f);
00471               }
00472               fputs(tclose(t_constraints), f);
00473        }
00474 }
00475 
00476 
00477 
00478 inline static void export_declaration(FILE *f, tagpair *tag, Section s,
00479        int shortdoc)
00480 {
00481        Decl d1;
00482 
00483        switch (s->decl->tp) {
00484               case Proc:
00485                      fputs(topen(t_code), f);
00486                      putcode(s->decl->type, f, tag);
00487                      if (s->decl->type)
00488                             putc(' ', f);
00489                      putcode(s->decl->name, f, tag);
00490                      if (s->decl->suffix)
00491                             putcode(s->decl->suffix, f, tag);
00492                      if (s->decl->params) {
00493                             putc('(', f);
00494                             for (d1 = s->decl->params; d1; d1 = d1->next) {
00495                                    putcode(d1->type, f, tag);
00496                                    putc(' ', f);
00497                                    putcode(d1->name, f, tag);
00498                                    if (d1->suffix)
00499                                           putcode(d1->suffix, f, tag);
00500                                    if (d1->next)
00501                                           fputs(", ", f);
00502                             }
00503                             putc(')', f);
00504                      }
00505                      fputs(tclose(t_code), f);
00506                      if (!shortdoc)
00507                             putcode(s->decl->body, f, tag);
00508                      break;
00509               case Var: variable(f, tag, s); break;
00510               case Type: type(f, tag, s); break;
00511               case Def: macro(f, tag, s); break;
00512               case Incl: import_file(f, tag, s); break;
00513               default: ; /* Cannot happen! */
00514        }
00515 }
00516 
00517 inline static void exports(FILE *f, tagpair *tag, Class c, int shortdoc)
00518 {
00519        Section s;
00520 
00521        if (c->exports != NULL) {
00522               fputs(topen(t_exports), f);
00523               for (s = c->exports; s; s = s->next) {
00524                      fputs(topen(t_section), f);
00525                      print_text_par(f, tag, s->text, c->filename,
00526                             s->decl ? s->decl->lineno : -1);
00527                      if (s->decl) {
00528                             export_declaration(f, tag, s, shortdoc);
00529                      }
00530                      fputs(tclose(t_section), f);
00531               }
00532               fputs(tclose(t_exports), f);
00533        }
00534 }
00535 
00536 /* A recursive procedure |tabulate_inherited_resources| creates tables
00537  * for the public variables of all superclasses, with the most recent
00538  * initial values.
00539  */
00540 
00541 static void tabulate_inherited_resources(FILE *f, tagpair *tag, Class self,
00542        Class part)
00543 {
00544        Section s;
00545        if (!part)
00546               return;
00547        if (part->publicvars) {
00548               fputs(topen(t_table), f);
00549               fputs(topen(t_tablehead), f);
00550               putcode(part->name, f, tag);
00551               fputs(tclose(t_tablehead), f);
00552               for (s = part->publicvars; s; s = s->next) {
00553                      if (s->decl && (find_instvar_class(part, s->decl->name)
00554                                    == part)) {
00555                             fputs(topen(t_row), f);
00556                             fputs(topen(t_resname), f);
00557                             if (s->decl->namesym) {
00558                                    putcode(s->decl->namesym, f, tag);
00559                             } else {
00560                                    fputs("XtN", f);
00561                                    putcode(s->decl->name, f, tag);
00562                             }
00563                             fputs(tclose(t_resname), f);
00564                             fputs(topen(t_resclass), f);
00565                             fputs("XtC", f);
00566                             if (s->decl->namesym)
00567                                    putcode(get_classname(s->decl->namesym),
00568                                           f, tag);
00569                             else
00570                                    putcode(get_classname(s->decl->name),
00571                                           f, tag);
00572                             fputs(tclose(t_resclass), f);
00573                             fputs(topen(t_restype), f);
00574                             /* (void) fputs("XtR", f); */
00575                             if (s->decl->typesym)
00576                                    putcode(s->decl->typesym, f, tag);
00577                             else
00578                                    putcode(get_classname(s->decl->type),
00579                                           f, tag);
00580                             fputs(tclose(t_restype), f);
00581                             fputs(topen(t_resdefault), f);
00582                             putcode(s->decl->value, f, tag);
00583                             fputs(tclose(t_resdefault), f);
00584                             fputs(tclose(t_row), f);
00585                      }
00586               }
00587               fputs(tclose(t_table), f);
00588        }
00589        tabulate_inherited_resources(f, tag, self, part->super);
00590 }
00591 
00592 inline static void summary_inherited_resources(FILE *f, tagpair *tag, Class c)
00593 {
00594        if (c->superclass)
00595               tabulate_inherited_resources(f, tag, c, c->super);
00596 }
00597 
00598 
00599 inline static void actions(FILE *f, tagpair *tag, Class c, int shortdoc)
00600 {
00601        Section s;
00602 
00603        if (c->actions) {
00604               fputs(topen(t_actions), f);
00605               for (s = c->actions; s; s = s->next) {
00606                      fputs(topen(t_section), f);
00607                      if (s->decl && s->decl->tp == Proc) {
00608                             fputs(topen(t_action), f);
00609                             putcode(s->decl->name, f, tag);
00610                             fputs(tclose(t_action), f);
00611                      }
00612                      print_text_par(f, tag, s->text, c->filename,
00613                             s->decl ? s->decl->lineno : -1);
00614                      if (!shortdoc && s->decl) {
00615                             switch (s->decl->tp) {
00616                                    case Proc:
00617                                           function(f, tag, s,
00618                                                  &action_proto);
00619                                           break;
00620                                    case Def:
00621                                           macro(f, tag, s);
00622                                           break;
00623                                    default: break;
00624                             }
00625                      }
00626               fputs(tclose(t_section), f);
00627               }
00628        fputs(tclose(t_actions), f);
00629        }
00630 }
00631 
00632 inline static void default_translations(FILE *f, tagpair *tag, Class c)
00633 {
00634        Section s;
00635 
00636        if (c->translations) {
00637               fputs(topen(t_translations), f);
00638               for (s = c->translations; s; s = s->next) {
00639                      fputs(topen(t_section), f);
00640                      print_text_par(f, tag, s->text, c->filename,
00641                             s->decl ? s->decl->lineno : -1);
00642                      if (s->decl) {
00643                             fputs(topen(t_code), f);
00644                             putcode(s->decl->type, f, tag);
00645                             fputs(": ", f);
00646                             putcode(s->decl->value, f, tag);
00647                             fputs(tclose(t_code), f);
00648                      }
00649                      fputs(tclose(t_section), f);
00650               }
00651               fputs(tclose(t_translations), f);
00652        }
00653 }
00654 
00655 inline static void imports(FILE *f, tagpair *tag, Class c)
00656 {
00657        Section s;
00658        if (c->imports) {
00659               fputs(topen(t_imports), f);
00660               for (s = c->imports; s; s = s->next) {
00661                      fputs(topen(t_section), f);
00662                      print_text_par(f, tag, s->text, c->filename,
00663                             s->decl ? s->decl->lineno : -1);
00664                      if (s->decl) {
00665                             switch (s->decl->tp) {
00666                                    case Proc:
00667                                           function(f, tag, s, s);
00668                                           break;
00669                                    case Var:
00670                                           variable(f, tag, s);
00671                                           break;
00672                                    case Incl:
00673                                           import_file(f, tag, s);
00674                                           break;
00675                                    default: ; /* Cannot happen! */
00676                             }
00677                      }
00678                      fputs(tclose(t_section), f);
00679               }
00680               fputs(tclose(t_imports), f);
00681        }
00682 }
00683 
00684 
00685 inline static void private_variables(FILE *f, tagpair *tag, Class c)
00686 {
00687        Section s;
00688 
00689        if (c->privatevars) {
00690               fputs(topen(t_privatevars), f);
00691               for (s = c->privatevars; s; s = s->next) {
00692                      fputs(topen(t_section), f);
00693                      print_text_par(f, tag, s->text, c->filename,
00694                             s->decl ? s->decl->lineno : -1);
00695                      if (s->decl) {
00696                             fputs(topen(t_code), f);
00697                             putcode(s->decl->type, f, tag);
00698                             putc(' ', f);
00699                             putcode(s->decl->name, f, tag);
00700                             if (s->decl->suffix)
00701                                    putcode(s->decl->suffix, f, tag);
00702                             fputs(tclose(t_code), f);
00703                      }
00704                      fputs(tclose(t_section), f);
00705               }
00706               fputs(tclose(t_privatevars), f);
00707        }
00708 }
00709 
00710 inline static void private_constraint_variables(FILE *f, tagpair *tag, Class c)
00711 {
00712        Section s;
00713 
00714        if (c->privconstr) {
00715               fputs(topen(t_privconstraints), f);
00716               for (s = c->privconstr; s; s = s->next) {
00717                      fputs(topen(t_section), f);
00718                      print_text_par(f, tag, s->text, c->filename,
00719                             s->decl ? s->decl->lineno : -1);
00720                      if (s->decl) {
00721                             fputs(topen(t_code), f);
00722                             putcode(s->decl->type, f, tag);
00723                             putc(' ', f);
00724                             putcode(s->decl->name, f, tag);
00725                             if (s->decl->suffix)
00726                                    putcode(s->decl->suffix, f, tag);
00727                             fputs(tclose(t_code), f);
00728                      }
00729                      fputs(tclose(t_section), f);
00730               }
00731               fputs(tclose(t_privconstraints), f);
00732        }
00733 }
00734 
00735 inline static void private_class_variables(FILE *f, tagpair *tag, Class c)
00736 {
00737        Section s;
00738 
00739        if (c->classvars != NULL) {
00740               fputs(topen(t_classvars), f);
00741               for (s = c->classvars; s; s = s->next) {
00742                      fputs(topen(t_section), f);
00743                      print_text_par(f, tag, s->text, c->filename,
00744                             s->decl ? s->decl->lineno : -1);
00745                      if (s->decl)
00746                             variable(f, tag, s);
00747                      fputs(tclose(t_section), f);
00748               }
00749               fputs(tclose(t_classvars), f);
00750        }
00751 }
00752 
00753 inline static void utilities(FILE *f, tagpair *tag, Class c)
00754 {
00755        Section s;
00756 
00757        if (c->utilities) {
00758               fputs(topen(t_utilities), f);
00759               for (s = c->utilities; s; s = s->next) {
00760                      fputs(topen(t_section), f);
00761                      print_text_par(f, tag, s->text, c->filename,
00762                             s->decl ? s->decl->lineno : -1);
00763                      if (s->decl) {
00764                             switch (s->decl->tp) {
00765                                    case Proc: function(f, tag, s, s);
00766                                           break;
00767                                    case Var: variable(f, tag, s); break;
00768                                    case Type: type(f, tag, s); break;
00769                                    case Def: macro(f, tag, s); break;
00770                                    default: ; /* Cannot happen! */
00771                             }
00772                      }
00773                      fputs(tclose(t_section), f);
00774               }
00775               fputs(tclose(t_utilities), f);
00776        }
00777 }
00778 
00779 
00780 inline static void private_methods(FILE *f, tagpair *tag, Class c)
00781 {
00782        Section s, s2;
00783 
00784        if (c->methods) {
00785               fputs(topen(t_methods), f);
00786               for (s = c->methods; s; s = s->next) {
00787                      fputs(topen(t_section), f);
00788                      print_text_par(f, tag, s->text, c->filename,
00789                             s->decl ? s->decl->lineno : -1);
00790                      if (s->decl) {
00791                             switch (s->decl->tp) {
00792                                    case Proc:
00793                                           s2 = find_method(c,
00794                                                  s->decl->name);
00795                                           function(f, tag, s, s2);
00796                                           break;
00797                                    case Def:
00798                                           macro(f, tag, s);
00799                                           break;
00800                                    default:
00801                                      break;
00802                             }
00803                      }
00804                      fputs(tclose(t_section), f);
00805               }
00806               fputs(tclose(t_methods), f);
00807        }
00808 }
00809 
00810 void generate_doc(FILE *f, tagpair *tag, Class c, int shortdoc)
00811 {
00812        fputs(topen(t_start), f);
00813        chapter_title_intro(f, tag, c);
00814        public_variables(f, tag, c, shortdoc);
00815        summary_inherited_resources(f, tag, c);
00816        constraint_resources(f, tag, c, shortdoc);
00817        exports(f, tag, c, shortdoc);
00818        default_translations(f, tag, c);
00819        actions(f, tag, c, shortdoc);
00820        if (!shortdoc) {
00821               imports(f, tag, c);
00822               private_variables(f, tag, c);
00823               private_constraint_variables(f, tag, c);
00824               private_class_variables(f, tag, c);
00825               private_methods(f, tag, c);
00826               utilities(f, tag, c);
00827        }
00828        fputs(tclose(t_start), f);
00829 }