commit 6556e9f92a593f76028d71ce23756b4102751b39
parent a8024d16ed2cff9b881b702d35395a2ea9fb416d
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Sun, 15 Feb 2015 10:26:43 -0700
add `x-source-pkg` to HTML output
Diffstat:
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/scribble-doc/scribblings/scribble/core.scrbl b/scribble-doc/scribblings/scribble/core.scrbl
@@ -1587,12 +1587,14 @@ 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}, plus @tt{x-part-prefixes}
-if the section or enclosing sections declare tag prefixes. The
+if the section or enclosing sections declare tag prefixes, and
+@tt{x-source-pkg} if the source is found within a package at document-build time. The
@racketmodname[scribble/manual] style recognizes those tags to make
clicking a title show cross-reference information.
@history[#:added "1.2"
- #:changed "1.7" @elem{Added @tt{x-part-prefixes}.}]}
+ #:changed "1.7" @elem{Added @tt{x-part-prefixes}.}
+ #:changed "1.9" @elem{Added @tt{x-source-pkg}.}]}
@defstruct[html-defaults ([prefix (or/c bytes? path-string?
diff --git a/scribble-lib/info.rkt b/scribble-lib/info.rkt
@@ -22,4 +22,4 @@
(define pkg-authors '(mflatt eli))
-(define version "1.8")
+(define version "1.9")
diff --git a/scribble-lib/scribble/html-render.rkt b/scribble-lib/scribble/html-render.rkt
@@ -19,6 +19,7 @@
net/base64
scheme/serialize
racket/draw/gif
+ pkg/path
(prefix-in xml: xml/xml)
(for-syntax scheme/base)
"search.rkt"
@@ -312,6 +313,7 @@
root-relative?)
(define path-cache (make-hash))
+ (define pkg-cache (make-hash))
(define (path->relative p)
(let ([p (path->main-doc-relative p)])
@@ -1116,6 +1118,14 @@
(cadr t)))])
(if (and src taglet)
`([x-source-module ,(format "~s" src)]
+ ,@(let* ([path (resolved-module-path-name
+ (module-path-index-resolve
+ (module-path-index-join src #f)))]
+ [pkg (and (path? path)
+ (path->pkg path #:cache pkg-cache))])
+ (if pkg
+ `([x-source-pkg ,pkg])
+ null))
,@(let ([prefixes (current-tag-prefixes)])
(if (null? prefixes)
null