docread: link to source code

This commit is contained in:
puck 2024-10-04 03:45:40 +00:00
parent 145cf85e5d
commit 144702f70c

View file

@ -24,7 +24,7 @@
(call-with-port (open-input-string comments-fixed) (lambda (port) (read port))))
;; Iterate over the contents of a define-library, and collect comments on certain defines.
(define (parse-library-contents contents lib-comments)
(define (parse-library-contents fname contents lib-comments)
(define comments '())
(define defines '())
(define imports '())
@ -87,7 +87,7 @@
(define out-file (open-output-file out-path))
; Print out the comments
(fprintf out-file "= `~A`\n\n" (car contents))
(fprintf out-file "= `~A`\n\nhttps://puck.moe/git/zilch/tree~A[source code]\n\n" (car contents) fname)
(for-each (lambda (l) (fprintf out-file "~A\n" l)) lib-comments)
(fprintf out-file "\n:toc:\n\n")
(for-each (lambda (i)
@ -101,15 +101,15 @@
(define root (call-with-input-pipe "git rev-parse --show-toplevel" (lambda (p) (define path (read-string 9999999 p)) (string-copy path 0 (- (string-length path) 1)))))
(define (parse-file contents)
(define (parse-file fname contents)
(define comments '())
(for-each (lambda (j)
(cond ((eq? (car j) 'define-library) (parse-library-contents (cdr j) (reverse comments)))
(cond ((eq? (car j) 'define-library) (parse-library-contents fname (cdr j) (reverse comments)))
((eq? (car j) 'comment) (set! comments (cons (cadr j) comments))))) contents))
(define (process-file fname _)
(parse-file (read-file-with-rewritten-comments fname)))
(parse-file (string-copy fname (string-length root)) (read-file-with-rewritten-comments fname)))
(find-files root #:test ".*\\.(sld|scm)" #:action process-file)