[racket] Review request: Partially expanding to make "blue boxes"

From: Greg Hendershott (greghendershott at gmail.com)
Date: Wed Aug 13 11:09:11 EDT 2014

I was hoping someone more-experienced might have time to review

For possible use in racket-mode, I've been experimenting with
extracting "blue boxes" and "blue lines" from arbitrary Racket
sources (not just functions with installed documentation):


More background explanation is in the README.md.

An early version analyzed fully-unexpanded syntax. But of course that
misses things created by definer macros. On the other hand, trying to
extract contracts from fully-expanded syntax is... ugly; I started
down that road and realized it was insane.

Instead I'm trying to work with the warm bowl of porridge: Wrap each
module-level form in a macro that uses `local-expand` to partially
expand stopping at forms like define, provide, define/contract,
provide/contract, and so on. Then walk the form looking for function
definitions, contracts, and renamings, storing this in a "database"
consisting of a bunch of hash tables.

On the source files I've tried so far, "it works".  However:

1. This is my first ever need to use `local-expand`.

2. I'm not sure if my `munge-module` function is the best way to go
about this?

3. In a couple cases I have to match on datums not literals. Usually
that would be a red flag. I'm not sure in this case?

If you search for "QUESTION" in main.rkt you'll see what I mean wrt 2
and 3.

I'd welcome any feedback, either posted here or as GitHub comments
(whichever you prefer). Thanks in advance!

Posted on the users mailing list.