Start working on gendoc.

This commit is contained in:
Dominik Pantůček 2023-07-04 19:41:24 +02:00
parent 7cab364c73
commit 3f21b99a0e
3 changed files with 111 additions and 1 deletions

92
src/duck-extract.scm Normal file
View file

@ -0,0 +1,92 @@
;;
;; duck-extract.scm
;;
;; Duck - a CHICKEN in-source documentation: extraction tool.
;;
;; ISC License
;;
;; Copyright 2023 Dominik Pantůček <dominik.pantucek@trustica.cz>
;;
;; Permission to use, copy, modify, and/or distribute this software
;; for any purpose with or without fee is hereby granted, provided
;; that the above copyright notice and this permission notice appear
;; in all copies.
;;
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;;
(declare (unit duck-extract))
(module
duck-extract
(
print-module-duck
)
(import scheme
(chicken base)
(chicken string)
(chicken format))
(define (print-duck-text dt)
(print
(string-intersperse
(map (lambda (x)
(format "~A" x))
dt)
" ")))
(define (print-duck-module sec)
(print "## " (cadr sec) " [module]")
(newline)
(print-duck-text (caddr sec)))
(define (print-duck-variable sec)
(newline)
(print "### " (cadr sec) " [variable]")
(newline)
(print " (define " (cadr sec) " " (cadddr sec) ")")
(newline)
(print-duck-text (caddr sec)))
(define (print-duck-parameter sec)
(newline)
(print "### " (cadr sec) " [parameter]")
(newline)
(print " (define " (cadr sec) " (make-parameter " (list-ref sec 4) "))")
(print " (" (cadr sec) ")")
(print " (" (cadr sec) " " (cadddr sec) ")")
(newline)
(print-duck-text (caddr sec)))
(define (print-duck-procedure sec)
(newline)
(print "### " (cadr sec) " [procedure]")
(newline)
(print " " (cons (cadr sec) (cadddr sec)))
(newline)
(print-duck-text (caddr sec)))
(define (print-duck-unknown sec)
(print sec))
(define (print-module-duck mod)
(let loop ((mod mod))
(when (not (null? mod))
(when (car mod)
(case (caar mod)
((MOD) (print-duck-module (car mod)))
((VAR) (print-duck-variable (car mod)))
((PAR) (print-duck-parameter (car mod)))
((FUN) (print-duck-procedure (car mod)))
(else (print-duck-unknown (car mod)))))
(loop (cdr mod)))))
)