twitter / twitter-cldr-rb

Ruby implementation of the ICU (International Components for Unicode) that uses the Common Locale Data Repository to format dates, plurals, and more.
Apache License 2.0
672 stars 93 forks source link

doc with yard: examples #269

Closed noraj closed 1 year ago

noraj commented 1 year ago

As there is no documentation outside the README, I wanted to start introducing library documentation with yard. I showcased a few simple examples in this PR.

Yard is automatically used for https://www.rubydoc.info/.

Here is an example for what it can looks like on one of my projects:

https://rubydoc.info/gems/unisec/Unisec%2FSurrogates%2Ehigh_surrogate

image

https://rubydoc.info/gems/unisec/Unisec%2FSurrogates:initialize

image

For example here on property_values_for, @return [Array<String>|nil] indicates it can either return an Array of string or nil. It's nice to be able to read it from the doc rather than having to read all the source code to figures it out. Indeed, one could expect that when a property don't have values it returns an empty Array and not nil. Not all the code is explicit so it may be nice to explain it at least for complex methods or one with not trivial behavior.

Let me know what you think, if the style is ok, should I continue to PR some doc, etc?

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

camertron commented 1 year ago

Hey @noraj, thanks for this, I'd love to get everything annotated with YARD 😄 I'm happy to merge once the CLA has been signed 👍

noraj commented 1 year ago

Screenshot_20230819-030750_Navigateur.png

I signed it earlier, retried just now, I click the refresh link but the CLA app seems broken, it's never good on the issue.