diff --git a/scribblings/template.scrbl b/scribblings/template.scrbl index 828ae21..cc1845a 100644 --- a/scribblings/template.scrbl +++ b/scribblings/template.scrbl @@ -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] diff --git a/template.rkt b/template.rkt index c1896bb..e30f138 100644 --- a/template.rkt +++ b/template.rkt @@ -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 ...)))) - "")])) \ No newline at end of file + "")]))