diff options
author | Tomas Volf <~@wolfsden.cz> | 2024-03-14 17:45:04 +0100 |
---|---|---|
committer | Tomas Volf <~@wolfsden.cz> | 2024-03-14 17:45:04 +0100 |
commit | 2cccde1e3fb493ae4b1d523029b0b361080902d8 (patch) | |
tree | 4e0d3347b30788d001d0750a1ea08b6b29a59450 /src/geiser | |
parent | 635d312b9084fa2d4eea4b57f20a7ad5197da2ba (diff) | |
download | geiser-guile-2cccde1e3fb493ae4b1d523029b0b361080902d8.tar.gz geiser-guile-2cccde1e3fb493ae4b1d523029b0b361080902d8.tar.bz2 |
Allow processing of texinfo in docstrings.
This commit adds support for processing texinfo in docstrings. That allows
using texinfo in them while still having readable, nicely formatted plain text
representation in geiser-doc-symbol-at-point.
Fixes #43.
* geiser-guile.el (geiser-guile-doc-process-texinfo): New custom controlling the
behavior.
(geiser-guile-update-doc-process-texinfo): New procedure to apply change of the
controlling custom to a current REPL.
(geiser-guile--startup): Call it.
* geiser-guile.texi (Start up): Document the custom.
* src/geiser/doc.scm (%process-texinfo?): New variable.
(try-texinfo->plain-text): New procedure.
(docstring): Call it on doc iff doc.
Diffstat (limited to 'src/geiser')
-rw-r--r-- | src/geiser/doc.scm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/geiser/doc.scm b/src/geiser/doc.scm index b566b5e..dbd92fa 100644 --- a/src/geiser/doc.scm +++ b/src/geiser/doc.scm @@ -23,7 +23,12 @@ #:use-module (ice-9 regex) #:use-module (ice-9 format) #:use-module (oop goops) - #:use-module (srfi srfi-1)) + #:use-module (srfi srfi-1) + #:use-module (texinfo) + #:use-module (texinfo plain-text)) + +;;; Should texinfo in docstrings be processed? +(define %process-texinfo? #f) (define (autodoc ids) (if (not (list? ids)) @@ -194,6 +199,15 @@ `(("signature" . ,(or (obj-signature sym obj #f) sym)) ("docstring" . ,(docstring sym obj)))))) +(define (try-texinfo->plain-text str) + "Convert STR from texinfo into a plain text, assuming it is a valid texinfo +and %process-texinfo? is #t. + +Return either the resulting plain text or the original STR." + (or (and %process-texinfo? + (false-if-exception (stexi->plain-text (texi-fragment->stexi str)))) + str)) + (define (docstring sym obj) (define (valuable?) (not (or (macro? obj) (procedure? obj) (program? obj)))) @@ -212,7 +226,7 @@ (display modname) (display "."))) (newline) - (if doc (begin (newline) (display doc))) + (if doc (begin (newline) (display (try-texinfo->plain-text doc)))) (if (valuable?) (begin (newline) (display "Value:") (newline) |