(define-module (fancy-docstrings) #:use-module (srfi srfi-1) #:use-module (texinfo) #:use-module (ice-9 documentation) #:use-module (ice-9 match) #:use-module (ice-9 pretty-print)) (define ansi-begin-bold "\x1b[1m") (define ansi-begin-underline "\x1b[4m") (define ansi-end-it-all "\x1b[0m") ;;;(pretty-print texi-command-specs) (define (display-fancy-string str) "Display a fancy @var{str}." (display ansi-begin-underline) (display ansi-begin-bold) (display str) (display ansi-end-it-all)) (define (display-fancy-stexi-para stexi) "Display fancy @var{stexi} paragraph." (let loop ((stexi stexi)) (match stexi (() '()) ((('var (and (? string?) str)) . rest-of-elements) (display-fancy-string str) (loop rest-of-elements)) ((('code (and (? string?) str)) . rest-of-elements) (display-fancy-string str) (loop rest-of-elements)) (((some-tag (and (? string?) str)) . rest-of-items) ;; TODO: What about the rest of them? (error "Still unsupported stexi element:" some-tag str) (loop rest-of-items)) (((and (? string?) str) . rest-of-items) (display str) (loop rest-of-items)) (_ (error "Unknown stexi value:" stexi))))) (define (display-fancy-stexi-fragment stexi) (let loop ((stexi stexi)) (match stexi (() '()) (('*fragment* ('para . first-paragraph) . rest-of-paragraphs) (display-fancy-stexi-para first-paragraph) (loop rest-of-paragraphs)) ((('para . paragraph) . rest-of-paragraphs) (display "\n\n") (display-fancy-stexi-para paragraph) (loop rest-of-paragraphs)) ((element . rest-of-elements) (error "Unknown stexi element" element)))))