I\'m currently trying to dive into Racket/Scheme a bit. I have an instance of the (X)REPL running next to my editor, which helps me immensely to explore the language. Howeve
I'm not sure if this applies to Racket, but in MIT scheme there are a couple built-in procedures that will get you close. (Below, proc
just stands for any procedure)
(procedure-arity proc)
as you mentioned will give you the number of arguments(pa proc)
will print the argument list(pp proc)
will print the body of the procedureThis will work for many of the built in procedures as well any that you define yourself, but if you try to call any of these on a special form like define
or set!
you will get an error.
Eli Barzilay notes that the Geiser project includes code to extract this documentation.
I do have an experimental bit of source code that extracts the text out of the HTML documentation, though that code may have bitrotted.
See: https://github.com/dyoo/wescheme-docs/blob/master/test-extract-docstring.rkt
and its dependencies, which live in: https://github.com/dyoo/wescheme-docs.
The extract-docstring.rkt
library I wrote up works under Racket 5.2.1, but I'm admittedly doing some really icky, hacky things to extract text from the documentation.
It may be worthwhile to tell the folks on the Racket Users mailing list that being able to access the text-based documentation from xrepl
is an important thing; perhaps it'll get the impetus moving.
A couple weeks ago the XREPL ,describe
command was enhanced to print the function argument names and contract; source.
This is the "blue box" from Racket documentation -- so called because they used to be blue before the Racket 6 CSS redesign; now they're actually grey :).
You can get this by building Racket from HEAD. Otherwise, it should be in the next release after 6.1.
Keep in mind that this appears to be limited to functions that have Scribble documentation in installed packages.