commit 389123af2fba9a9347c5a3892017eff9bbcb1a93
parent ffa98a1c115594cfc41ea43914f69b6f9522e56f
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Thu, 23 Oct 2014 07:59:12 -0600
Scribble HTML: included needed tag prefixes in "Link to this section"
original commit: f79ac7b510b1b0c6b65744f815f0cd1740904383
Diffstat:
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/pkgs/scribble-pkgs/scribble-doc/scribblings/scribble/core.scrbl b/pkgs/scribble-pkgs/scribble-doc/scribblings/scribble/core.scrbl
@@ -1586,11 +1586,13 @@ part. Clicking on a section title within the part may show
other documents can link to the section.
More specifically, the section title is given the HTML attributes
-@tt{x-source-module} and @tt{x-part-tag}. The
+@tt{x-source-module} and @tt{x-part-tag}, plus @tt{x-part-prefixes}
+if the section or enclosing sections declare tag prefixes. The
@racketmodname[scribble/manual] style recognizes those tags to make
clicking a title show cross-reference information.
-@history[#:added "1.2"]}
+@history[#:added "1.2"
+ #:changed "1.7" @elem{Added @tt{x-part-prefixes}.}]}
@defstruct[html-defaults ([prefix (or/c bytes? path-string?
diff --git a/pkgs/scribble-pkgs/scribble-lib/info.rkt b/pkgs/scribble-pkgs/scribble-lib/info.rkt
@@ -22,4 +22,4 @@
(define pkg-authors '(mflatt eli))
-(define version "1.6")
+(define version "1.7")
diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt
@@ -1116,6 +1116,10 @@
(cadr t)))])
(if (and src taglet)
`([x-source-module ,(format "~s" src)]
+ ,@(let ([prefixes (current-tag-prefixes)])
+ (if (null? prefixes)
+ null
+ `([x-part-prefixes ,(format "~s" prefixes)])))
[x-part-tag ,(format "~s" taglet)])
'()))
,@(format-number number '((tt nbsp)))
diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/manual-racket.js b/pkgs/scribble-pkgs/scribble-lib/scribble/manual-racket.js
@@ -19,6 +19,9 @@ function AddPartTitleOnClick(elem) {
var mod_path = elem.getAttribute("x-source-module");
var tag = elem.getAttribute("x-part-tag");
if (mod_path && tag) {
+ // Might not be present:
+ var prefixes = elem.getAttribute("x-part-prefixes");
+
var info = document.createElement("div");
info.className = "RPartExplain";
@@ -30,9 +33,13 @@ function AddPartTitleOnClick(elem) {
/* Break `secref` into two lines if the module path and tag
are long enough: */
- var is_long = (is_top ? false : (mod_path.length + tag.length > 60));
+ var is_long = (is_top ? false : ((mod_path.length
+ + tag.length
+ + (prefixes ? (16 + prefixes.length) : 0))
+ > 60));
var line1 = document.createElement("div");
+ var line1x = ((is_long && prefixes) ? document.createElement("div") : line1);
var line2 = (is_long ? document.createElement("div") : line1);
function add(dest, str, cn) {
@@ -49,9 +56,16 @@ function AddPartTitleOnClick(elem) {
if (!is_top)
add(line1, tag, "RktVal");
if (is_long) {
- /* indent second line: */
+ /* indent additional lines: */
+ if (prefixes)
+ add(line1x, "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0", "RktPn");
add(line2, "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0", "RktPn");
}
+ if (prefixes) {
+ add(line1x, " #:tag-prefixes ", "RktPn");
+ add(line1x, "'", "RktVal");
+ add(line1x, prefixes, "RktVal");
+ }
if (!is_top)
add(line2, " #:doc ", "RktPn");
add(line2, "'", "RktVal");
@@ -60,6 +74,8 @@ function AddPartTitleOnClick(elem) {
info.appendChild(line1);
if (is_long)
+ info.appendChild(line1x);
+ if (is_long)
info.appendChild(line2);
info.style.display = "none";