[AD] HTML documentation index minitoc |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hi.
The attached patch makes the HTML output create a small minitoc
at the top of the page. A skilled designer might want to use those
divs for better looks.
Index: docs/src/makedoc/makehtml.c
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/makedoc/makehtml.c,v
retrieving revision 1.35
diff -u -r1.35 makehtml.c
--- docs/src/makedoc/makehtml.c 9 Feb 2005 09:07:25 -0000 1.35
+++ docs/src/makedoc/makehtml.c 28 Feb 2005 23:05:55 -0000
@@ -1494,6 +1494,7 @@
static void _output_symbol_index(void)
{
int f, g, num = 0;
+ char last_letter;
char **list = NULL;
for(f = 0; _post[f]; f++) {
@@ -1516,7 +1517,34 @@
qsort(list, num, sizeof(char *), _str_cmp);
- for (f = 0; f < num; f++) {
+ /* Create minitoc scanning first letters of sorted list. */
+ fprintf(_file, "<div class='mini_toc' id='top'>\n\t");
+ for (f = 0, last_letter = -1; f < num; f++) {
+ /* Valid range? */
+ if (list[f][0] >= 'A' && list[f][0] <= 'z') {
+ /* Different letter? */
+ if (last_letter != list[f][0]) {
+ last_letter = list[f][0];
+ fprintf(_file, "<a href='#mini_toc_%c%d'>%c</a>\n\t",
+ last_letter, last_letter > '_', last_letter);
+ }
+ }
+ }
+ fprintf(_file, "\n</div>\n\n");
+
+ for (f = 0, last_letter = -1; f < num; f++) {
+ /* Did we change letter section? */
+ if (list[f][0] >= 'A' && list[f][0] <= 'z' && list[f][0] != last_letter) {
+ /* Is this the first section or another one? */
+ if (last_letter != -1)
+ fprintf(_file, "\n</ul>\n");
+
+ last_letter = list[f][0];
+ fprintf(_file, "<h1 class='mini_toc' "
+ "id='mini_toc_%c%d'><a href='#top'>%c</a></h1>\n<ul>\n",
+ last_letter, last_letter > '_', last_letter);
+ }
+
/* Before writing the string, remove possible short descriptions. */
char *p, *temp = m_strdup(list[f]);
p = strchr(temp, ',');
@@ -1527,6 +1555,7 @@
fprintf(_file, " — ");
_hfprintf("@SHORTDESC %s@xxxxxxxxxx", temp);
}
+ fprintf(_file, "</ul>");
}