racket / scribble

Other
194 stars 90 forks source link

Empty lines for grouping in `scribble/example` `@examples` #331

Open sschwarzer opened 2 years ago

sschwarzer commented 2 years ago

Sometimes I want to group lines in an @examples form, i.e. insert empty lines between groups of inputs and outputs.

Here's an example from the documentation of define-syntax to show what I mean:

Examples:

    > (define-syntax foo
        (syntax-rules ()
          ((_ a ...)
           (printf "~a\n" (list a ...)))))
    > (foo 1 2 3 4)
    (1 2 3 4)
    > (define-syntax (bar syntax-object)
        (syntax-case syntax-object ()
          ((_ a ...)
           #'(printf "~a\n" (list a ...)))))
    > (bar 1 2 3 4)
    (1 2 3 4)

However, since the foo and bar examples are independent, these examples would look clearer as

Examples:

    > (define-syntax foo
        (syntax-rules ()
          ((_ a ...)
           (printf "~a\n" (list a ...)))))
    > (foo 1 2 3 4)
    (1 2 3 4)

    > (define-syntax (bar syntax-object)
        (syntax-case syntax-object ()
          ((_ a ...)
           #'(printf "~a\n" (list a ...)))))
    > (bar 1 2 3 4)
    (1 2 3 4)

Note the empty line after the (foo 1 2 3 4) output.

I tried a lot to achieve this with scribble/example, but didn't succeed. Things that almost worked:

I found a few examples in the Racket documentation that do use empty lines as shown above, but they use mz-examples, or examples from the legacy scribble/eval module.