Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sschwarzer opened this issue Jun 17, 2022 · 0 comments
Open

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

sschwarzer opened this issue Jun 17, 2022 · 0 comments

Comments

@sschwarzer
Copy link

sschwarzer commented Jun 17, 2022

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:

  • (code:comment "") still prints the semicolon
  • code:blank and (code:line) add a prompt in front of the otherwise empty line
  • (eval:no-prompt code:blank) adds two or three empty lines
  • (eval:no-prompt (code:line)) gives an exception because (code:line) doesn't seem to be recognized inside (eval:no-prompt).
  • (eval:no-prompt) adds a tiny gap. I was (kinda) able to get an "empty line" with a sequence of (eval:no-prompt), but that's quite a dirty hack, isn't it? ;-)
  • Split the @examples[...] invocations into several, one for each group. This requires #:label #f for the groups after the first and duplication of possible setup / keyword arguments from the first @examples[...] of the group.

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.

sschwarzer added a commit to sschwarzer/racket-glossary that referenced this issue Jun 17, 2022
I want a visual separation of the independent examples, but didn't find
a straightforward way to do this. Splitting `@examples` into several is
my current workaround.

I entered an issue at racket/scribble#331 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant