From d4c7e13038ce2d51b4c0e41c45edeaa677f6a7c5 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 9 Apr 2004 18:43:02 +0000 Subject: [PATCH] Add a config directive to generate the INFO-DIR-ENTRY things that appear to be used to automatically construct /usr/info/dir. git-svn-id: svn://svn.tartarus.org/sgt/halibut@4049 cda61777-01e9-0310-a592-d414129be87e --- bk_info.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ doc/blurb.but | 5 ++++- error.c | 8 +++++++- halibut.h | 1 + 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/bk_info.c b/bk_info.c index 088c72d..9834610 100644 --- a/bk_info.c +++ b/bk_info.c @@ -3,10 +3,10 @@ * * TODO: * - * - basic vital configuration: Info dir entries in heading, and - * how to allocate node names + * - configurable choice of how to allocate node names * - escape, warn or simply remove commas and colons in node * names; also test colons in index terms. + * - might be helpful to diagnose duplicate node names too! * - test everything in info(1), and probably jed too * * Later: @@ -201,10 +201,8 @@ void info_backend(paragraph *sourceform, keywordlist *keywords, /* * An Info file begins with a piece of introductory text which * is apparently never shown anywhere. This seems to me to be a - * good place to put the copyright notice and the version IDs. - * - * FIXME: also Info directory entries are expected to go here. - * This will need to be a configurable thing of some sort. + * good place to put the copyright notice and the version IDs. + * Also, Info directory entries are expected to go here. */ rdaddsc(&intro_text, @@ -213,6 +211,51 @@ void info_backend(paragraph *sourceform, keywordlist *keywords, rdaddsc(&intro_text, "\n\n"); for (p = sourceform; p; p = p->next) + if (p->type == para_Config && + !ustricmp(p->keyword, L"info-dir-entry")) { + wchar_t *section, *shortname, *longname, *kw; + char *s; + + section = uadv(p->keyword); + shortname = *section ? uadv(section) : NULL; + longname = *shortname ? uadv(shortname) : NULL; + kw = *longname ? uadv(longname) : NULL; + + if (!*longname) { + error(err_infodirentry, &p->fpos); + continue; + } + + rdaddsc(&intro_text, "INFO-DIR-SECTION "); + s = utoa_dup(section); + rdaddsc(&intro_text, s); + sfree(s); + rdaddsc(&intro_text, "\nSTART-INFO-DIR-ENTRY\n* "); + s = utoa_dup(shortname); + rdaddsc(&intro_text, s); + sfree(s); + rdaddsc(&intro_text, ": ("); + s = dupstr(conf.filename); + if (strlen(s) > 5 && !strcmp(s+strlen(s)-5, ".info")) + s[strlen(s)-5] = '\0'; + rdaddsc(&intro_text, s); + sfree(s); + rdaddsc(&intro_text, ")"); + if (*kw) { + keyword *kwl = kw_lookup(keywords, kw); + if (kwl && kwl->para->private_data) { + node *n = (node *)kwl->para->private_data; + rdaddsc(&intro_text, n->name); + } + } + rdaddsc(&intro_text, ". "); + s = utoa_dup(longname); + rdaddsc(&intro_text, s); + sfree(s); + rdaddsc(&intro_text, "\nEND-INFO-DIR-ENTRY\n\n"); + } + + for (p = sourceform; p; p = p->next) if (p->type == para_Copyright) info_para(&intro_text, NULL, NULL, p->words, keywords, 0, 0, width); diff --git a/doc/blurb.but b/doc/blurb.but index e7f8e4c..0b6153f 100644 --- a/doc/blurb.but +++ b/doc/blurb.but @@ -9,6 +9,9 @@ \cfg{xhtml-template-filename}{%k.html} \cfg{xhtml-template-fragment}{%k} +\cfg{info-dir-entry}{Documentation}{Halibut}{Multi-format +documentation processing system} + Halibut is a free (MIT-licensed) documentation production system, able to generate multiple output formats from the same input data. This document is its user manual. @@ -17,4 +20,4 @@ This document is its user manual. rights reserved. You may distribute this documentation under the MIT licence. See \k{licence} for the licence text in full. -\versionid $Id: blurb.but,v 1.3 2004/04/01 17:54:53 simon Exp $ +\versionid $Id: blurb.but,v 1.4 2004/04/09 18:43:02 simon Exp $ diff --git a/error.c b/error.c index 5819e00..efa0eb8 100644 --- a/error.c +++ b/error.c @@ -200,7 +200,13 @@ static void do_error(int code, va_list ap) { sprintf(error, "section headings are not supported within \\%.100s", sp); flags = FILEPOS; - break; + break; + case err_infodirentry: + fpos = *va_arg(ap, filepos *); + sprintf(error, "\\cfg{info-dir-entry} expects at least three" + " parameters"); + flags = FILEPOS; + break; case err_whatever: sp = va_arg(ap, char *); vsprintf(error, sp, ap); diff --git a/halibut.h b/halibut.h index 3e600c7..66bb333 100644 --- a/halibut.h +++ b/halibut.h @@ -218,6 +218,7 @@ enum { err_multikw, /* keyword clash in sections */ err_misplacedlcont, /* \lcont not after a list item */ err_sectmarkerinblock, /* section marker appeared in block */ + err_infodirentry, /* \cfg{info-dir-entry} missing param */ err_whatever /* random error of another type */ }; -- 2.11.0