Hello,

as a heavy user of scribble/srcdoc I've always missed a defclass provide
form equivalent. Therefore I wanted to implement my own. I decided to
use thing-doc as a starting point and noticed that it raises misleading
message if id is not an identifier. Minimal working example follows.

---- MWE: test.rkt ----
#lang racket
(require scribble/srcdoc)
(provide (thing-doc 5 number? "Just a number."))
---- MWE: test.scrbl ----
#lang scribble/manual
@(require scribble/extract)
@include-extracted["test.rkt"]
----

Running scribble --pdf test.scrbl produces:

test.rkt:4:12: parameter/doc: expected an identifier
  at: 5
  in: (thing-doc 5 number? "Just a number.")
  location...:
   test.rkt:4:12
  context...:

Looking at the sources file scribble-lib/srcdoc.rkt, the line 580 lists
the wrong exception identifier. A patch against current master follows:

====
diff --git a/scribble-lib/scribble/srcdoc.rkt
b/scribble-lib/scribble/srcdoc.rkt
index ee977a16..e9dd3311 100644
--- a/scribble-lib/scribble/srcdoc.rkt
+++ b/scribble-lib/scribble/srcdoc.rkt
@@ -577,7 +577,7 @@
       [(_ id contract desc)
        (begin
          (unless (identifier? #'id)
-           (raise-syntax-error 'parameter/doc
+           (raise-syntax-error 'thing-doc
                                "expected an identifier"
                                stx
                                #'id))
====

Also I implemented a simple defclass wrapper as a provide form named
class-doc:

==== class-doc syntax form ====
(define-provide/doc-transformer class-doc
  (lambda (stx)
    (syntax-case stx ()
      [(_ id super (intf-id ...) pre-flow)
       (begin
         (unless (identifier? #'id)
           (raise-syntax-error 'class-doc
                               "expected an identifier"
                               stx
                               #'id))
         (unless (identifier? #'super)
           (raise-syntax-error 'class-doc
                               "expected super class identifier"
                               stx
                               #'id))
         (values
          #'[id any/c] ; contract not used?
          #'(defclass id super (intf-id ...) . pre-flow)
          #'((only-in scribble/manual defclass))
          #'id))])))
====

It does not handle the maybe-link keyword argument as I am not using it
and I didn't dive into where it is used in order to test it.

 maybe-link             =               
                |               #:link-target? link-target?-expr

I would appreciate any feedback and/or improvement suggestions.

Is there a chance this new provide form can be merged into
scribble-lib/srcdoc.rkt in the future or is it better to create a
separate package for it?


Cheers,
Dominik

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/99cc1ba0-19f3-717b-b089-6cd6aa948144%40trustica.cz.

Reply via email to