Add procedure to get the uri of a particular doc

My thinking is that we can generate the URIs for every doc,
then use that to wire up the logic for the routing table
This commit is contained in:
TakeV 2023-12-17 00:21:12 -05:00
parent 04a226e5e0
commit 0ad70e4ada
Signed by: TakeV
GPG Key ID: A64F41345C7400AF
1 changed files with 12 additions and 1 deletions

View File

@ -1,11 +1,13 @@
(define-module (guile-docs docs)
#:use-module (srfi srfi-9)
#:use-module (web uri)
#:export (make-doc
doc?
doc-module
doc-symbol
doc-documentation
docs-in-module))
docs-in-module
document-uri))
(define-record-type <doc>
(make-doc module symbol documentation)
@ -14,6 +16,15 @@
(symbol doc-symbol)
(documentation doc-documentation))
(define (document-uri doc)
"Returns the URI for the provided <doc> argument"
(when (doc? doc)
(let ((symbol-list (append (doc-module doc)
(list (doc-symbol doc)))))
(build-uri 'guiledoc
#:path (string-join (map (lambda (x) (symbol->string x))
symbol-list)
"/")))))
(define (docs-in-module module)
"Returns a list of <doc> for each symbol in module mod"