Skip to content

Use Guile REPL's ,d over procedure-documentation for more robust documentation#680

Merged
Olical merged 1 commit intoOlical:mainfrom
seamusriordan:guile-use-repl-describe-for-docstring
Jul 4, 2025
Merged

Use Guile REPL's ,d over procedure-documentation for more robust documentation#680
Olical merged 1 commit intoOlical:mainfrom
seamusriordan:guile-use-repl-describe-for-docstring

Conversation

@seamusriordan
Copy link
Contributor

Using the REPL's provided ,d (,describe ) is more robust at providing documentation strings. ,d will provide the same functionality as procedure-documentation but also provide extended online documentation demonstrated below.

The output by ,d is caught by stray output which I find reads a little bit more naturally and is better formatted for multi-line doc strings. The current implementation writes literal \n for new lines and everything ends up on one line.

scheme@(guile-user)> (define (some-function) "This is a function" 42)
scheme@(guile-user)> (use-modules (ice-9 regex))
scheme@(guile-user)> (procedure-documentation some-function)
$1 = "This is a function"
scheme@(guile-user)> (procedure-documentation make-regexp)
$2 = #f
scheme@(guile-user)> ,d some-function
This is a function
scheme@(guile-user)> ,d make-regexp
- Scheme Procedure: make-regexp pat .  flags
     Compile the regular expression described by PAT, and return the
     compiled regexp structure.  If PAT does not describe a legal
     regular expression, `make-regexp' throws a
     `regular-expression-syntax' error.

     The FLAGS arguments change the behavior of the compiled regular
     expression.  The following flags may be supplied:

     regexp/icase
          Consider uppercase and lowercase letters to be the same when
          matching.

     regexp/newline
          If a newline appears in the target string, then permit the `^'
          and `$' operators to match immediately after or immediately
          before the newline, respectively.  Also, the `.' and `[^...]'
          operators will never match a newline character.  The intent of
          this flag is to treat the target string as a buffer containing
          many lines of text, and the regular expression as a pattern
          that may match a single one of those lines.

     regexp/basic
          Compile a basic (``obsolete'') regexp instead of the extended
          (``modern'') regexps that are the default.  Basic regexps do
          not consider `|', `+' or `?' to be special characters, and
          require the `{...}' and `(...)' metacharacters to be
          backslash-escaped (see Backslash Escapes).  There are several
          other differences between basic and extended regular
          expressions, but these are the most significant.

     regexp/extended
          Compile an extended regular expression rather than a basic
          regexp.  This is the default behavior; this flag will not
          usually be needed.  If a call to `make-regexp' includes both
          `regexp/basic' and `regexp/extended' flags, the one which
          comes last will override the earlier one.
@russtoku
Copy link
Contributor

russtoku commented Jul 3, 2025

Looks good and works as advertised!

Copy link
Owner

@Olical Olical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, great change!

@Olical Olical merged commit 460b146 into Olical:main Jul 4, 2025
8 checks passed
@seamusriordan seamusriordan deleted the guile-use-repl-describe-for-docstring branch August 8, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants