Scribble and structs

32 views
Skip to first unread message

Deren Dohoda

unread,
Aug 12, 2020, 7:07:58 AM8/12/20
to Racket Users
Hi racketeers,

I have two questions. The first is: is there a way to have scribble / sandbox use the gen:custom-write property of a structure? When I use @examples the output is just the bare structure output, not using the gen:custom-write procedure.

Second, I am working on a very simple polynomial library using 7.7 and during the creation of the docs I receive this warning:
"WARNING: collected information for key multiple times: '(dep ((lib "simple-polynomial/main.rkt") polynomial?)); values: #t #t"
among other similar warnings all seeming to point to the procedure polynomial?.

This would lead me to believe I have somehow required or defined things multiple times. However my "main.rkt" is just a one file require and an all-from-out. The underlying library does not use (provide (struct-out ...)), I only (provide polynomial?). 

Do structs somehow mess with scribble here? A small search reveals only a single posting from the developers library with the comment "fix your library." Love to, but what's the problem? 

Thanks for any thoughts,
Deren

Laurent

unread,
Aug 12, 2020, 7:35:43 AM8/12/20
to Deren Dohoda, Racket Users
I have no idea about custom-write, but for the duplicate keys, maybe you installed the collection multiple times? Take a look at the output of `raco pkg show` maybe.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/2ffd6a24-8437-4a7e-b688-74135a866673n%40googlegroups.com.

Matthew Flatt

unread,
Aug 12, 2020, 8:11:36 AM8/12/20
to Deren Dohoda, Racket Users
At Wed, 12 Aug 2020 04:07:58 -0700 (PDT), Deren Dohoda wrote:
> I have two questions. The first is: is there a way to have scribble /
> sandbox use the gen:custom-write property of a structure? When I use
> @examples the output is just the bare structure output, not using the
> gen:custom-write procedure.
>
> Second, I am working on a very simple polynomial library using 7.7 and
> during the creation of the docs I receive this warning:
> "WARNING: collected information for key multiple times: '(dep ((lib
> "simple-polynomial/main.rkt") polynomial?)); values: #t #t"
> among other similar warnings all seeming to point to the procedure
> polynomial?.
>
> This would lead me to believe I have somehow required or defined things
> multiple times. However my "main.rkt" is just a one file require and an
> all-from-out. The underlying library does not use (provide (struct-out
> ...)), I only (provide polynomial?).
>
> Do structs somehow mess with scribble here?

Structs should not cause any particular problem for Scribble. I'm
puzzled by the problem with `gen:custom-write`, because that should
certainly work with sandboxes and `@examples`.

The "collected information multiple times" error would be caused by
multiple declarations of `polynominal?` in the docs, as opposed to
multiple definitions in the code. Depending on when the error happens,
though, it could be due to multiple instances of a whole document, as
Laurent suggests.


Matthew

Deren Dohoda

unread,
Aug 12, 2020, 8:32:35 AM8/12/20
to Matthew Flatt, Racket Users

Hi Matthew,

Structs should not cause any particular problem for Scribble. I'm
puzzled by the problem with `gen:custom-write`, because that should
certainly work with sandboxes and `@examples`.
I will try to look at some included documents with the main distribution to see if I can figure out what I'm doing wrong then.

The "collected information multiple times" error would be caused by
multiple declarations of `polynominal?` in the docs, as opposed to
multiple definitions in the code. Depending on when the error happens,
though, it could be due to multiple instances of a whole document, as
Laurent suggests.
If I remove the @defproc of polynomial? then I do not get the error, though then of course that definition never appears in the document. However, if I instead remove the @defstruct* then the error also disappears. But @defstruct* does not document the automatically generated procedure so it seems that it shouldn't introduce it as far as scribble is concerned. Is this a bug?

Deren

Matthew Flatt

unread,
Aug 12, 2020, 8:50:37 AM8/12/20
to Deren Dohoda, Racket Users
At Wed, 12 Aug 2020 08:32:25 -0400, Deren Dohoda wrote:
> If I remove the @defproc of polynomial? then I do not get the error, though
> then of course that definition never appears in the document. However, if I
> instead remove the @defstruct* then the error also disappears. But
> @defstruct* does not document the automatically generated procedure so it
> seems that it shouldn't introduce it as far as scribble is concerned. Is
> this a bug?

A `@defstruct*[polynomial .....]` form does document `polynomial?`.
Although the word `polynomial?` doesn't appear on the page, it's
implied by the `struct` form on the page.

As another example, if you search the docs for `exn?`, you'll arrive at
a `struct` declaration for `exn`, and not a separate `exn?` entry.


Matthew

Deren Dohoda

unread,
Aug 12, 2020, 9:04:31 AM8/12/20
to Matthew Flatt, Racket Users
Hi Matthew,
A `@defstruct*[polynomial .....]` form does document `polynomial?`.
Although the word `polynomial?` doesn't appear on the page, it's
implied by the `struct` form on the page.
Thank you, I understand.

Deren 

Deren Dohoda

unread,
Aug 12, 2020, 10:31:51 AM8/12/20
to Racket Users
Solved some of which was offline.

First was my misunderstanding about having to document implied procedures when using a struct. Second was that I missed a parameter print-as-expression which should be parameterized as #f for the evaluator. 

Thanks everyone!
Deren

--
You received this message because you are subscribed to a topic in the Google Groups "Racket Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/racket-users/oKtKqyQZDg4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to racket-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages