Scribble and main.rkt

43 views
Skip to first unread message

unlimitedscolobb

unread,
Dec 21, 2020, 12:05:42 PM12/21/20
to Racket Users
Hello,

This is mainly a question out of curiosity, because I think I figured out how to do what I want.

I'm setting up a small (8 functions and 2 macros) package called typed-compose.  I called the main file typed-compose.rkt (not main.rkt) and put the following in the preamble of typed-compose.scrbl:

@(require scribble/example racket/sandbox
      (for-label racket/base "typed-compose.rkt"
               (only-in typed/racket/base
                      -> compose)))

I then get the following undefined tag errors:

WARNING: undefined tag in <pkgs>/typed-compose/typed-compose.scrbl:
 ((lib "typed-compose/typed-compose.rkt") compose-3)
 ((lib "typed-compose/typed-compose.rkt") compose-4)
 ((lib "typed-compose/typed-compose.rkt") compose-n)
 ((lib "typed-compose/typed-compose.rkt") multi-chain)
 ((lib "typed-compose/typed-compose.rkt") multi-compose)

These symbols happen to be those for which typed-compose.scrbl has defproc or defform statements.

Weirdly, evaluators set up by the following code work no problem:

@(define typed-compose-evaluator
  (parameterize ([sandbox-output 'string]
           [sandbox-error-output 'string]
         [sandbox-memory-limit 50])
   (make-evaluator 'typed/racket/base #:requires '("typed-compose.rkt"))))

If I now rename typed-compose.rkt to main.rkt and update all the references to this file, everything works fine.  Everything also works fine if I replace "main.rkt" by typed-compose in typed-compose.scrbl.

I read up some docs and recalled that main.rkt is what require automatically looks for when I give it a collection name (not a file name).  However, I am somewhat surprised to see (require (for-label "typed-compose.rkt")) fail in this context.

Is it correct that calling the main file of the package something else than main.rkt is bad style, unsupported by Scribble?

-
Sergiu

Ben Greenman

unread,
Dec 22, 2020, 9:46:03 AM12/22/20
to Racket Users
> Is it correct that calling the main file of the package something else than
> main.rkt is bad style, unsupported by Scribble?

It's okay to call the main file something else, but you'll have to
tell Scribble about it.

Right now, I guess you have a @defmodule[typed-compose]{....}
somewhere. That would tell Scribble that the defprocs below come from
typed-compose/main.rkt

If the main module is typed-compose.rkt, then a
@defmodule[typed-compose/typed-compose]{....} should fix the broken
links.
(And, it'll tell readers how to require the things below.)

unlimitedscolobb

unread,
Dec 22, 2020, 3:06:49 PM12/22/20
to Racket Users
Thanks a lot, that's perfectly clear and worked for me!

I'll go with main.rkt though, because requiring the package is simpler this way.

-
Sergiu
Reply all
Reply to author
Forward
0 new messages