scribble icon indicating copy to clipboard operation
scribble copied to clipboard

Search bindings by kind?

Open jackfirth opened this issue 8 years ago • 1 comments

When using Scribble's def forms, a #:kind argument is sometimes provided to document the binding as "procedure", "syntax", "class", "constructor", etc. I'd like to be able to filter by kind in a Scribble search, for example to find all documented "syntax class" bindings in the package catalog. Based on the help text of the Scribble search page, I believe this isn't implemented.

I'm not too familiar with Scribble's internals, but I think this would involve extending index-element and scribble/manual-struct. I'm not sure how to do that in a backwards-compatible way. Bonus points if Scribble could output the kind of every binding in search results.

jackfirth avatar Aug 31 '17 22:08 jackfirth

A small issue: right now the kind is just a user-supplied string. I have some bindings which are documented using "phase 1 function" or maybe "phase 1 match expander" as the kind.

Although a full-text search in that info would likely work, maybe we can add a struct and some built-in kinds.

;; Somewhere inside scribble
(struct kind (k) #:transparent)
(struct kind+phase kind (ph) #:transparent)
(define-syntax-rule (define-scribble-kind id text)
  (define id (case-lambda [() (kind text)] [(ph) (kind+phase text ph)])))

;; Default kinds
(define-scribble-kind procedure-kind "procedure")
(define-scribble-kind value-kind "value")
(define-scribble-kind syntax-kind "syntax")
(define-scribble-kind match-expander-kind "match expander")
(define-scribble-kind pattern-expander-kind "syntax-parse pattern expander")
;; …

;; In user libraries
(define-scribble-kind type-expander-kind "type-expander")
;; …

Then, we would use defproc and friends as follows:

@defform[#:kind (match-expander-kind 2)
         (a-match-expander-which-can-be-used-at-phase-2 [foo bar])]{
  description
}

Otherwise, maybe we can simply add a #:phase option in addition to the #:kind one. I just feel that indexing this information would work better if the strings were a bit more structured, and we followed some form of official convention.

SuzanneSoy avatar Sep 19 '17 09:09 SuzanneSoy