Compare commits
9 Commits
main
...
charli-bra
Author | SHA1 | Date |
---|---|---|
TakeV | 95c2843175 | |
TakeV | 77fc9f6c99 | |
TakeV | bde327be02 | |
TakeV | 6217b13504 | |
TakeV | a537c855cf | |
TakeV | 974363cf5a | |
TakeV | fc895ad637 | |
TakeV | 6e64bd9d2f | |
TakeV | 0ad70e4ada |
|
@ -9,3 +9,6 @@ Like janetdocs or clojuredocs, but for guile!
|
|||
Either run src_bash{scripts/launch-dev-shell} or run src_bash{guix shell -Df guix.scm -m manifest.scm} to get a developer environment.
|
||||
|
||||
manifest.scm is intended for dev tools related programs.
|
||||
* Resources
|
||||
** Useful Links
|
||||
- https://systemreboot.net/post/live-hacking-a-guile-web-server
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
(define-module (guile-docs server rendering)
|
||||
#:use-module (guile-docs docs)
|
||||
#:use-module (guile-docs html templates)
|
||||
#:use-module (haunt html)
|
||||
#:export (get-renderer-for-data
|
||||
render-html))
|
||||
|
||||
(define (get-renderer-for-data data-payload)
|
||||
"Returns the renderer for the data-payload"
|
||||
(cond ((doc? data-payload) render-doc)
|
||||
(else index-page)))
|
||||
|
||||
(define (render-html data-payload)
|
||||
"Renders the data-payload into HTML. The template used for rendering depends on the type of data-payload."
|
||||
(let ((renderer (get-renderer-for-data data-payload)))
|
||||
(sxml->html-string (overall-wrapper (renderer data-payload)))))
|
|
@ -0,0 +1,13 @@
|
|||
(define-module (guile-docs server routing)
|
||||
#:use-module (guile-docs docs)
|
||||
#:export (generate-routing-table
|
||||
default-routing-table))
|
||||
|
||||
(define (generate-routing-table)
|
||||
"Creates an alist of URIs and associated <doc> for the guile namespace"
|
||||
(let* ((default-module (resolve-interface '(guile)))
|
||||
(docs (docs-in-module default-module)))
|
||||
(map (lambda (doc) `(,(document-uri doc) . ,doc))
|
||||
docs)))
|
||||
|
||||
(define default-routing-table (generate-routing-table))
|
|
@ -37,6 +37,14 @@
|
|||
(define (directory? file-name)
|
||||
(eq? (stat:type (stat file-name)) 'directory))
|
||||
|
||||
(define (get-payload-for-path path routing-table)
|
||||
"Returns the first payload that matches the routing-table path"
|
||||
(let ((filtered-table
|
||||
(filter (lambda (routing-entry)
|
||||
(not (equal? path (uri-path (car routing-entry)))))
|
||||
routing-table)))
|
||||
(cdr (car filtered-table))))
|
||||
|
||||
(define (serve-file path)
|
||||
(define %prefix `(,(getcwd) "public"))
|
||||
(define (prepend-prefix path) (string-join (append %prefix `(,path)) file-name-separator-string))
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
;; You can store it in a file that you may then pass to any 'guix' command
|
||||
;; that accepts a '--manifest' (or '-m') option.
|
||||
|
||||
(specifications->manifest (list "guile-hall" "guix" "git"))
|
||||
(specifications->manifest (list "guile-colorized"
|
||||
"guile-hall"
|
||||
"guile-readline"
|
||||
"git"))
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
guile --listen -L . -c '((@ (guile-docs) launch-server))'
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
guile --listen -L .
|
Loading…
Reference in New Issue