Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YARD support for Hashie::Dash? #158

Open
maxlinc opened this issue May 15, 2014 · 4 comments
Open

YARD support for Hashie::Dash? #158

maxlinc opened this issue May 15, 2014 · 4 comments

Comments

@maxlinc
Copy link
Contributor

maxlinc commented May 15, 2014

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/.
@maxlinc
Copy link
Contributor Author

maxlinc commented May 15, 2014

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

@michaelherold
Copy link
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.

@maxlinc
Copy link
Contributor Author

maxlinc commented Sep 8, 2014

@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.

@lsegal
Copy link

lsegal commented Sep 9, 2014

Hi there. Macros can be defined in a gem!

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

No branches or pull requests

4 participants