Sitelet https://github.com/hashie/hashie/issues/158
Skip to content

YARD support for Hashie::Dash? #158

Description

@maxlinc

It would be cool if YARD could generate docs for Hashie::Dash, at a basic list of attributes defined via property.

I created a gist based on the YARD guide for writing handlers, the source for YARD::Handlers::Ruby::AttributeHandler and a few similar handlers I found.

It seems to work, but I haven't completely figured out:

  • The AST, to see if I can handle the :default, or :required properties.
  • Trying to scope the handler so it only applies on classes that are a Hashie::Dash (if that's possible)
  • If there is a way to package the handler in a way that it's automatically used by http://rubydoc.info/.

Activity

  1. maxlinc commented on May 15, 2014

    @maxlinc
    ContributorAuthor

    BTW - here's example source and generated doc, similar to attribute:

    class MyDash < Hashie::Dash
      property :one
      property :two, required: true
      property :three, default: 3, required: true
    end

    screen shot 2014-05-15 at 2 36 55 pm

  2. michaelherold commented on Sep 8, 2014

    @michaelherold
    Member

    @maxlinc Have you looked into this any further? I think it looks like a nice-to-have feature but I haven't ever worked with YARD handlers.

  3. maxlinc commented on Sep 8, 2014

    @maxlinc
    ContributorAuthor

    @michaelherold I haven't played with it much more, but I have used macros to more easily generate documentation.

    Macros were useful, but probably not ideal:

    • I'm not sure if macros can be defined in a gem
    • There isn't a real way to process the options. So I was creating more specific wrapper methods like required_property and optional_property rather than having a macro that understood property :foo, required: true.

    Anyways - I think it would be nice but if it's going to happen it looks like it should be a separate yard-hashie gem, because that's how yard plugins generally work. And also because @lsegal needs to review the plugin if it's going to be enabled on rubydoc.info.

  4. lsegal commented on Sep 9, 2014

    @lsegal

    Hi there. Macros can be defined in a gem!

  5. dblock commented on Aug 25, 2026

    @dblock
    Member

    Just my (@copilot) opinion here, happy to be corrected: this is a nice idea, but I don't think it's something that belongs in Hashie itself. As the discussion above concluded back in 2014, this would be best as a separate yard-hashie plugin gem (YARD macros can live in a gem, per @lsegal's comment), rather than adding YARD-handler code to Hashie's own codebase.

    As far as I can tell, no such plugin gem was ever built, and there hasn't been activity here in over a decade. I'd lean towards closing this as not planned for Hashie core, but leaving it open (perhaps as a 'help wanted') if anyone wants to pick up building a standalone yard-hashie gem instead.

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