Skip to content

Add support for (describe ...) in the REPL #67

Closed

Description

@oubiwann

So, I know that when we talked about adding support for docstrings, we agreed to simply discard the docstring data. In fact, I advised that, iirc ;-)

Now that our REPL is getting much cooler, I was hoping we could add support for (describe ...) :-)

Questions, of course, would be things like these:

  • where do we store docstrings?
  • how do we treat Erlang-style docs? (e.g., what happens when we (describe #'lists:map/2)?
  • what about parsing docstings for edoc markup?

Activity

  1. rvirding commented on Apr 28, 2014

    @rvirding
    Member

    The first bit is not too difficult, we just need to define a way to store the comment string inside the module. Either as attributes or have a function which returns the doc strings.

    This shouldn't be too difficult either once we have defined the formats. Unfortunately we can't call (describe '#foo:bar/1) as the #' results in a fun and not in the actual values. This is done very early.

    Edoc is worse as it know about erlang comments and syntax. We would need a new front-end to it, or some plugins if it supports that. Or use something else. I am not really an edoc fan. :-)

  2. oubiwann commented on Apr 28, 2014

    @oubiwann
    MemberAuthor

    On Sun, Apr 27, 2014 at 6:12 PM, Robert Virding [email protected]:

    The first bit is not too difficult, we just need to define a way to store
    the comment string inside the module. Either as attributes or have a
    function which returns the doc strings.

    That's good news!

    This shouldn't be too difficult either once we have defined the formats.
    Unfortunately we can't call (describe '#foo:bar/1) as the #' results in a
    fun and not in the actual values. This is done very early.

    Hrm, interesting. Didn't know that's how it worked... Would it be possible
    to do something like (describe 'module 'function) or (describe
    'module:function)?

    Edoc is worse as it know about erlang comments and syntax. We would need a
    new front-end to it, or some plugins if it supports that. Or use something
    else. I am not really an edoc fan. :-)

    Good to know! I've used Javadoc and Pydoc in the past... and it was more of
    a pain than anything else. I always ended up writing prose in my
    docstrings/comments instead, not using any of the markup. I'm cool with not
    even exploring this, then :-)

  3. oubiwann commented on Sep 1, 2014

    @oubiwann
    MemberAuthor

    Opened issue #87 to address the first part of this request.

  4. oubiwann commented on Jul 13, 2015

    @oubiwann
    MemberAuthor

    With regard to @rvirding's second point, I guess we could just do this:

    > (describe 'mod 'func n)

    where n is the arity. We could also provide a sane default for this:

    > (describe 'mod 'func)

    where perhaps the default arity selected would be the one with the longest docstring ...

  5. oubiwann commented on Jul 13, 2015

    @oubiwann
    MemberAuthor

    As to the docstring storage ... what about this:

    • put it in the module's attributes
    • make the key the atom docstrings
    • make the value a list of key/value tuples where each key would be #(func n) and the value would be the docstring for that function + arity.
    • look-ups would then be done like this: (lists:keyfind #(func n) 1 (mod:module_info 'docstrings)) (which, of course, would be wrappted by a REPL describe or help function (I kind of like the idea of re-using the help name with arities 2 and 3)
  6. yurrriq commented on Jul 13, 2015

    @yurrriq
    Contributor

    Sounds good to me!

  7. yurrriq commented on Jan 28, 2016

    @yurrriq
    Contributor

    Lodox might be of some use. I'd be down to make changes if it helps achieve the goals described here. An interesting feature to note is that lodox-parse:docs/1 produces a giant map of parsed metadata, including docstrings and arglists/patterns.

    For reference, parsed function (and macro) maps look like this:

    '#m(name     func
        arity    2
        patterns ((x y))
        doc      "func/2 does something really cool.")
  8. yurrriq commented on Apr 4, 2016

    @yurrriq
    Contributor

    See my comment on #211. I'm working on it here for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions