Provided and added contracts to the exising get-doc and get-metas

functions in templte.rkt.

Added documentation for get-doc and get-metas to template.scrbl.
pull/108/merge^2
Henry Blevins 9 years ago
parent 70f3d46c1f
commit 2f589f93d8

@ -138,6 +138,13 @@ Note that if @racket[_meta-source] is a relative path or pagenode, it is treated
(select-from-metas 'nonexistent-key metas)
]
@defproc[
(get-metas
[source-file (or/c pagenode? pathish?)])
hash?]
Retrieve the @racket[metas] hashtable from @racket[_file-source]. The @racket[_file-source] argument can be either a pagenode or source path that identifies a source file that provides @racket[metas]. If @racket[_file-source] does not exist, an error is thrown.
Note that if @racket[_source-file] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
@defproc[
@ -160,6 +167,15 @@ Note that if @racket[_doc-source] is a relative path or pagenode, it is treated
(select-from-doc 'nonexistent-key doc)
]
@defproc[
(get-doc
[source-file (or/c pagenode? pathish?)])
(or/c txexpr? string?)]
Retrieve the @racket[_doc] from @racket[_file-source]. The @racket[_file-source] argument can be either a pagenode or source path that identifies a source file that provides @racket[metas]. If @racket[_file-source] does not exist, an error is thrown.
Note that if @racket[_source-file] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
@defproc[
(when/block
[condition any/c]

@ -11,7 +11,7 @@
(path->pagenode (or (select-from-metas (world:current-here-path-key) metas) 'unknown)))
(define (pagenode->path pagenode)
(define+provide (pagenode->path pagenode)
(build-path (world:current-project-root) (symbol->string pagenode)))
@ -80,8 +80,8 @@
(check-false (select-from-doc 'absent-key doc))))
(define (get-metas pagenode-or-path)
; ((or/c pagenode? pathish?) . -> . hash?)
(define+provide/contract (get-metas pagenode-or-path)
((or/c pagenode? pathish?) . -> . hash?)
(define source-path (->source-path (cond
[(pagenode? pagenode-or-path) (pagenode->path pagenode-or-path)]
[else pagenode-or-path])))
@ -90,8 +90,8 @@
(error (format "get-metas: no source found for '~a' in directory ~a" pagenode-or-path (current-directory)))))
(define (get-doc pagenode-or-path)
; ((or/c pagenode? pathish?) . -> . (or/c txexpr? string?))
(define+provide/contract (get-doc pagenode-or-path)
((or/c pagenode? pathish?) . -> . (or/c txexpr? string?))
(define source-path (->source-path (cond
[(pagenode? pagenode-or-path) (pagenode->path pagenode-or-path)]
[else pagenode-or-path])))
@ -157,4 +157,4 @@
#'(if condition (string-append*
(with-handlers ([exn:fail? (λ(exn) (error (format "within when/block, ~a" (exn-message exn))))])
(map ->string (list body ...))))
"")]))
"")]))

Loading…
Cancel
Save