racket / scribble

Other
194 stars 89 forks source link

feat: support #:auto-value for defparam and defthing #391

Closed sorawee closed 6 months ago

sorawee commented 7 months ago

Manually specifying #:value could be cumbersome. An example is html-empty-tags from the xml collection, which is a list of more than 10 symbols. It is also error-prone, and could be out-of-sync from the actual value.

This PR adds a support for #:auto-value in defparam and defthing to automatically query the value from the for-label binding.

Thanks to @LiberalArtist for the help in https://github.com/racket/racket/pull/4807.

sorawee commented 7 months ago

This strategy is not foolproof though. For example, https://github.com/racket/scribble/blob/master/scribble-doc/scribblings/scribble/utils.rkt#L12-L13 bounces the for-label binding, but not the phase 0 binding. So without (require (for-label racket/base)), current-readtable would be identified as originated from utils.rkt, which is not the case. I'm not sure if there's a way to fix the problem. We could also just document the limitation and call it a day...

sorawee commented 7 months ago

Switching from the third result to the first result (nominal-from-mod -> from-mod) seems to help with the above issue.

sorawee commented 7 months ago

Addressed feedback by @rocketnia.

sorawee commented 6 months ago

Oof, I should have bumped the version and added a history note. Will push a fix.