raco pkg create: support "source" and "binary" bundling

Adds `--from-dir' and `--from-install' flags to select the interpretation
of the argument as a directory or as the name of an installed package.
Relevant to PR 13669

Adds `--as-is' (the default), `--source', and `--binary' flags to
select a pruning mode.

The `raco setup' tool recognizes a `rendered-scribblings' specification
in "info.rkt" to trigger moving rendered documentation into place,
registering its tags in the cross-reference database, and fixing up
references to "local-redirect.js"; the presence of a "synced.rktd"
indicates when those fixups have been performed (since, if the package
is installed in a user-specific scope, the documentation doesn't actually
move anywhere). Finally, "out<n>.sxref" needs to report paths relative to
the documentation's directory, and then the relative-directory references
need to be suitably resolved at derserialization; some support for such
relative paths was in place, but it wasn't quite general enough before.

original commit: 198a65a5fc79649ec167d2407c35815768a119ba
This commit is contained in:
Matthew Flatt 2013-05-08 20:20:17 -04:00
parent 03c6b006e8
commit d8f2cc1bd9
4 changed files with 48 additions and 10 deletions

View File

@ -264,7 +264,8 @@
(define/public (root-relative->path p)
(if (root-relative? p)
(apply build-path (mobile-root-path (car p))
(apply build-path (or (mobile-root-path (car p))
(current-directory))
(map bytes->path-element (cdr p)))
p))
@ -336,7 +337,13 @@
(define/public (serialize-one-ht ri ht)
(parameterize ([current-serialize-resolve-info ri])
(serialize (cons root ht))))
(let ([rp (mobile-root-path root)])
(when rp
(set-mobile-root-path! root #f))
(begin0
(serialize (cons root ht))
(when rp
(set-mobile-root-path! root rp))))))
(define/public (deserialize-info v ci #:root [root-path #f])
(let ([root+ht (deserialize v)]

View File

@ -15,7 +15,9 @@
xref-tag->path+anchor
xref-tag->index-entry
xref-transfer-info
(struct-out entry))
(struct-out entry)
make-data+root
data+root?)
(define-struct entry
(words ; list of strings: main term, sub-term, etc.
@ -23,6 +25,8 @@
tag ; for generating a Scribble link
desc)) ; further info that depends on the kind of index entry
(define-struct data+root (data root))
;; Private:
(define-struct xrefs (renderer ri))
@ -44,7 +48,10 @@
(namespace-anchor->empty-namespace here)])
(let ([vs (src)])
(for ([v (in-list (if (procedure? vs) (vs) (list vs)))])
(when v (send renderer deserialize-info v ci #:root root-path))))))]
(when v
(define data (if (data+root? v) (data+root-data v) v))
(define root (if (data+root? v) (data+root-root v) root-path))
(send renderer deserialize-info data ci #:root root))))))]
[ci (send renderer collect null null fp
(lambda (key ci)
(define src (demand-source key))

View File

@ -19,7 +19,7 @@ Returns @racket[#t] if @racket[v] is a cross-reference record created
by @racket[load-xref], @racket[#f] otherwise.}
@defproc[(load-xref [sources (listof (-> any/c))]
@defproc[(load-xref [sources (listof (-> (or/c any/c (-> list?))))]
[#:demand-source demand-source
(tag? -> (or/c (-> any/c) #f))
(lambda (_tag) #f)]
@ -28,10 +28,19 @@ by @racket[load-xref], @racket[#f] otherwise.}
[#:root root-path (or/c path-string? false/c) #f])
xref?]{
Creates a cross-reference record given a list of functions that each
produce a serialized information obtained from @xmethod[render<%>
serialize-info]. If a @racket[sources] element produces @racket[#f],
its result is ignored.
Creates a cross-reference record given a list of functions,
@racket[sources].
Let @racket[_source] be a function in @racket[sources]. The
@racket[_source] function normally returns serialized information,
@racket[_info], which was formerly obtained from @xmethod[render<%>
serialize-info]. The result of @racket[_source] can optionally be
another function, which is in turn responsible for returning a list of
@racket[_info]s. Finally, each @racket[_info] can be either serialized
information, a @racket[#f] to be ignored, or a value produced by
@racket[make-data+root] from which @racket[_data] part is used as
serialized information and the @racket[_root] part overrides
@racket[root-path] for deserialization.
The @racket[demand-source] function can effectively add a new source
to @racket[sources] in response to a search for information on the
@ -46,7 +55,10 @@ Latex/PDF and text).
If @racket[root-path] is not @racket[#f], then file paths that are
serialized as relative to an instantiation-supplied @racket[root-path]
are deserialized as relative instead to the given @racket[root-path].
are deserialized as relative instead to the given @racket[root-path],
but a @racket[make-data+root] result for any @racket[_info] supplies
an alternate path for deserialization of the @racket[_info]'s
@racket[_data].
Use @racket[load-collections-xref] from @racketmodname[setup/xref] to
get all cross-reference information for installed documentation.}
@ -191,3 +203,13 @@ The @racket[words] list corresponds to
corresponds to @racket[index-element-entry-seq]. The @racket[desc]
value corresponds to @racket[index-element-desc]. The @racket[tag] is
the destination for the index link into the main document.}
@deftogether[(
@defproc[(data+root? [v any/c]) boolean?]
@defproc[(make-data+root [data any/c] [root (or/c #f path-string?)]) data+root?]
)]{
A value constructed by @racket[make-data+root] can be returned by a
source procedure for @racket[load-xref] to specify a path used for
deserialization.}

View File

@ -0,0 +1,2 @@
#lang setup/infotab