Start working on gendoc.
This commit is contained in:
parent
7cab364c73
commit
3f21b99a0e
3 changed files with 111 additions and 1 deletions
16
src/Makefile
16
src/Makefile
|
@ -58,6 +58,8 @@ HACKERBASE-OBJS=hackerbase.o testing.o listing.o cal-month.o \
|
||||||
template-list-expander.o box-drawing.o util-list.o \
|
template-list-expander.o box-drawing.o util-list.o \
|
||||||
export-web-static.o util-dir.o racket-kwargs.o dokuwiki.o
|
export-web-static.o util-dir.o racket-kwargs.o dokuwiki.o
|
||||||
|
|
||||||
|
GENDOC-OBJS=gendoc.o duck-extract.o
|
||||||
|
|
||||||
.PHONY: imports
|
.PHONY: imports
|
||||||
imports: $(HACKERBASE-DEPS)
|
imports: $(HACKERBASE-DEPS)
|
||||||
|
|
||||||
|
@ -84,6 +86,9 @@ install-dev: static
|
||||||
install -m 0755 -d /usr/local/man/man1
|
install -m 0755 -d /usr/local/man/man1
|
||||||
install -m 0755 ../doc/hackerbase.1 /usr/local/man/man1/hackerbase-dev.1
|
install -m 0755 ../doc/hackerbase.1 /usr/local/man/man1/hackerbase-dev.1
|
||||||
|
|
||||||
|
../gendoc: $(GENDOC-OBJS)
|
||||||
|
$(CSC) -strip -static -o $@ $(GENDOC-OBJS)
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Module static and shared object and import source compilation
|
# Module static and shared object and import source compilation
|
||||||
|
|
||||||
|
@ -94,10 +99,14 @@ install-dev: static
|
||||||
$(CSC) -regenerate-import-libraries -P -J $<
|
$(CSC) -regenerate-import-libraries -P -J $<
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Main program
|
# Main programs
|
||||||
|
|
||||||
hackerbase.o: $(HACKERBASE-DEPS)
|
hackerbase.o: $(HACKERBASE-DEPS)
|
||||||
|
|
||||||
|
GENDOC-SOURCES=gendoc.scm duck-extract.import.scm
|
||||||
|
|
||||||
|
gendoc.o: $(GENDOC-SOURCES)
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Modules
|
# Modules
|
||||||
|
|
||||||
|
@ -495,3 +504,8 @@ dokuwiki.import.scm: $(DOKUWIKI-SOURCES)
|
||||||
DUCK-SOURCES=duck.scm
|
DUCK-SOURCES=duck.scm
|
||||||
|
|
||||||
duck.import.scm: $(DUCK-SOURCES)
|
duck.import.scm: $(DUCK-SOURCES)
|
||||||
|
|
||||||
|
DUCK-EXTRACT-SOURCES=duck-extract.scm
|
||||||
|
|
||||||
|
duck-extract.o: duck-extract.import.scm
|
||||||
|
duck-extract.import.scm: $(DUCK-EXTRACT-SOURCES)
|
||||||
|
|
92
src/duck-extract.scm
Normal file
92
src/duck-extract.scm
Normal 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)))))
|
||||||
|
|
||||||
|
)
|
4
src/gendoc.scm
Normal file
4
src/gendoc.scm
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
(import duck-extract)
|
||||||
|
|
||||||
|
(print "GENDOC")
|
Loading…
Add table
Add a link
Reference in a new issue