diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-03 06:10:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-03 06:10:04 -0700 |
commit | bc1ff7680631671d089dd837fa4fba390de79d35 (patch) | |
tree | eca99ffef170bbf5dd327bda943516f8a3a6c751 /genman.txr | |
parent | b0ae3c5e66313a7f58d346a55c80df355b63c559 (diff) | |
download | txr-bc1ff7680631671d089dd837fa4fba390de79d35.tar.gz txr-bc1ff7680631671d089dd837fa4fba390de79d35.tar.bz2 txr-bc1ff7680631671d089dd837fa4fba390de79d35.zip |
Topic disambiguation "sub-pages" in HTML doc.
The purpose of this change is to handle situations where a
symbol has multiple meanings, resulting in different topic
areas of the document where we might want to navigate. For
instance, there is an equal function in the TXR Lisp library,
and an equal method that users can define.
* genman.txr (tochash, disamb, dist-counter): New variables.
(process-ambiguities): New Lisp function.
When collecting symbol/jump-tag associations, collect
the lists of jump tags rather than just the first jump tag.
Then process the hash using process-ambiguities to
handle the cases with multiple entries, which are prepared
in the disamb hash. The contents of the disamb hash turn
into HTML material at the end of the page.
An in-line style sheet is now added; it adds vertical space
between the navigation menus so they appear as if they
were separate web pages.
Diffstat (limited to 'genman.txr')
-rw-r--r-- | genman.txr | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -4,6 +4,7 @@ @(bind txlhash @(hash :equal-based)) @(bind tgthash txrhash) @(bind tagmap @(hash :equal-based)) +@(bind tochash @(hash :equal-based)) @(bind closedtxt "<TT>[+]</TT>") @(bind opentxt "<TT>[-]</TT>") @(bind xpnall "[expand all]") @@ -12,6 +13,8 @@ @(do (defvar dupes (hash)) (defvar tagnum (hash :equal-based)) + (defvarl disamb (hash :equal-based)) + (defvarl dist-counter 0) (sys:set-hash-str-limit 1000) @@ -31,7 +34,15 @@ (defun enumerate (title) (let ((num (inc [tagnum title 0]))) - `@title@(if (> num 1) `-@num` "")`))) + `@title@(if (> num 1) `-@num` "")`)) + + (defun process-ambiguities (hash) + (hash-update hash (do if (eql (length @1) 1) + (first @1) + (let ((new-tag (format nil "D-~,04X" + (inc dist-counter)))) + (set [disamb new-tag] (reverse @1)) + new-tag))))) Content-type: text/html @(skip 15) <h1>TXR</h1> @@ -100,8 +111,9 @@ Content-type: text/html @ (set tgthash txlhash) @ (and) <dt><a href="#@tag">@(coll :vars (sym))<tt>@sym</tt>@(end) -@ (do (mapdo (do unless [tgthash @1] (set [tgthash @1] [tagmap tag])) - sym)) +@ (do (let ((n-tag [tagmap tag])) + (mapdo (do pushnew n-tag [tgthash @1]) sym) + (set [tochash n-tag] rest))) @ (and) <dt><a href="#@tag">@num @nil <dl> @@ -119,6 +131,7 @@ Content-type: text/html This document was created by @(end) @(flatten TOC) +@(do [mapdo process-ambiguities (list txrhash txlhash)]) @(set BODY @(let ((inside-tt nil) (inside-syntax nil)) (mapcar (do cond @@ -158,11 +171,15 @@ This document was created by @1))) BODY LOOKUP))) +@(bind (d-tag n-tag) @(transpose (hash-pairs disamb))) @(output) <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head><title>Manpage for TXR @VERSION</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<style> +.disambiguations dl { margin-bottom: 2048px; } +</style> <script type="text/javascript"> function toggle(link, id) { var e = document.getElementById(id); @@ -234,6 +251,19 @@ function tocjump(hash) { @BODY @(first) @(end) +<div class="disambiguations"> +@(repeat) +<a name="@{d-tag}"> + <p>Topics matching <tt>@(or (hash-revget txrhash d-tag) + (hash-revget txlhash d-tag))</tt>: + <dl> +@ (repeat :counter (n 1)) + <dt><a href="#@{n-tag}">@n:</a> @[tochash n-tag]</dt> +@ (end) + </dl> +</a> +@(end) +</div> </body> </html> @(end) |