From 2d6d1294d4d1433cf61684f2fe6a04022a365331 Mon Sep 17 00:00:00 2001 From: TakeV Date: Wed, 13 Dec 2023 10:11:33 -0500 Subject: [PATCH] Create templates file to handle rendering and move temp scripts into it Create docs module Add templates file to handle html wrapping and rendering Remove temp rendering files Add templates to hall file --- guile-docs/docs.scm | 9 ++++++- .../html/templates.scm | 25 ++++++++++++++++++- hall.scm | 4 ++- public/index.scm | 7 ------ public/module.scm | 18 ------------- 5 files changed, 35 insertions(+), 28 deletions(-) rename public/overall-wrapper.scm => guile-docs/html/templates.scm (59%) delete mode 100644 public/index.scm delete mode 100644 public/module.scm diff --git a/guile-docs/docs.scm b/guile-docs/docs.scm index cfef0de..53b1319 100644 --- a/guile-docs/docs.scm +++ b/guile-docs/docs.scm @@ -1,4 +1,11 @@ -(use-modules (srfi srfi-9)) +(define-module (guile-docs docs) + #:use-module (srfi srfi-9) + #:export (make-doc + doc? + doc-module + doc-symbol + doc-documentation + docs-in-module)) (define-record-type (make-doc module symbol documentation) diff --git a/public/overall-wrapper.scm b/guile-docs/html/templates.scm similarity index 59% rename from public/overall-wrapper.scm rename to guile-docs/html/templates.scm index 2ed01c1..75b2223 100644 --- a/public/overall-wrapper.scm +++ b/guile-docs/html/templates.scm @@ -1,4 +1,6 @@ -;; todo: module +(define-module (guile-docs html templates) + #:use-module (guile-docs docs)) + (define (overall-wrapper content) `(html (link (@ (rel "stylesheet") @@ -21,3 +23,24 @@ (li "srfi")))) ,content (footer (p (i "powered by solarpunks."))))))) + +(define index-page + (overall-wrapper + '(main + (h1 "Welcome") + (p "This is GuileDocs.")))) + +(define (render-doc doc) + `((hgroup + (h1 ,(doc-symbol doc)) + (p "In " ,(doc-module doc))) + (p ,(or (doc-documentation doc) "")))) + +(define (render-module module) + (let ((docs (docs-in-module module))) + (overall-wrapper + `(main ,(map render-doc docs))))) + +(define test-module (resolve-interface '(srfi srfi-9))) +(define (test-rendering) + (render-module test-module)) diff --git a/hall.scm b/hall.scm index 1eb2475..27c6bde 100644 --- a/hall.scm +++ b/hall.scm @@ -13,7 +13,9 @@ (files (libraries ((directory "guile-docs" - ((scheme-file "reflection") (scheme-file "docs"))))) + ((directory "html" ((scheme-file "templates"))) + (scheme-file "reflection") + (scheme-file "docs"))))) (tests ()) (programs ((scheme-file "guile-docs") diff --git a/public/index.scm b/public/index.scm deleted file mode 100644 index ec5001a..0000000 --- a/public/index.scm +++ /dev/null @@ -1,7 +0,0 @@ -;; TODO: move to modules - need to set up pre-inst-env or w/e -(load "overall-wrapper.scm") - -(overall-wrapper - '(main - (h1 "Welcome") - (p "This is GuileDocs."))) diff --git a/public/module.scm b/public/module.scm deleted file mode 100644 index 1adc54d..0000000 --- a/public/module.scm +++ /dev/null @@ -1,18 +0,0 @@ -(load "overall-wrapper.scm") - -(load "../guile-docs/docs.scm") - -(define (render-module module) - (let ((docs (docs-in-module module))) - (overall-wrapper - `(main ,(map render-doc docs))))) - - -(define (render-doc doc) - `((hgroup - (h1 ,(doc-symbol doc)) - (p "In " ,(doc-module doc))) - (p ,(or (doc-documentation doc) "")))) - - -(render-module (resolve-interface '(srfi srfi-19)))