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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing + around a some literals. #26905

Merged
merged 1 commit into from
Nov 13, 2016
Merged

Conversation

bogdanvlviv
Copy link
Contributor

Hi! 馃槃 Today was inspired to improve our docs!

I added missing + around a some literals, mainly around nil.

[ci skip]

Mainly around `nil`

[ci skip]
@rails-bot
Copy link

r? @chancancode

(@rails-bot has picked a reviewer for you, use r? to override)

@pixeltrix pixeltrix merged commit 0ef5b6c into rails:master Nov 13, 2016
@@ -98,7 +98,7 @@ module Helpers
# to avoid warnings in the client about mixed media.
# Note that the request parameter might not be supplied, e.g. when the assets
# are precompiled via a Rake task. Make sure to use a Proc instead of a lambda,
# since a Proc allows missing parameters and sets them to nil.
# since a +Proc+ allows missing parameters and sets them to +nil+.
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why +Proc+ here but not on the line above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because @bogdanvlviv missed it? Will fix

# * <tt>require_layout</tt> - If set to true and layout is not found,
# an +ArgumentError+ exception is raised (defaults to false)
# * <tt>require_layout</tt> - If set to +true+ and layout is not found,
# an +ArgumentError+ exception is raised (defaults to +false+)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wrapping false and true in pluses isn't always what we want. That implies literally passing true or false when e usually mean truthy or falsy (and not putting those words in a fixed width font is our way of saying that).
cc @fxn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are hundreds of existing entries which have +true+ where the same condition applies and it's unlikely that anyone will call this method and it not be explicitly true or false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, true 馃憤

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I noticed that we don't have a test for _default_layout raising an error when require_layout is set to true 馃槃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, 馃槀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we configure stuff or document default values, unless the underlying code is doing a == false and the value has to be exactly that, we document just a flag. That is, the method does not require that users pass singletons, it just relies on standard boolean semantics, so we do not document singletons. We document just what the method needs.

For example, if the value comes from something dynamic, users can spare a !! to make sure the call satisfies the contract, they just pass the value with boolean semantics down.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxn there are loads of places that use +true+ in the docs but will accept a truthy value. Also whether it's true or +true+ is a very subtle way of indicating that difference to users who are likely to be novices. Perhaps we need to come up with a clearer indication of the difference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree Andrew, in practice it's a convention that has not worked very well.

Also, in code examples there is even no typography so historically some methods have needed to change their API because of examples like

obj.predicate? # => true

I brought this topic to discussion a while back in core, I think it needs to be addressed somehow, but we didn't reach any agreement.

@@ -255,7 +255,7 @@ def _conditional_layout?
# true:: raise an ArgumentError
# nil:: Force default layout behavior with inheritance
#
# Return value of Proc & Symbol arguments should be String, false, true or nil
# Return value of +Proc & Symbol+ arguments should be +String+, +false+, +true+ or +nil+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think +Proc & Symbol+ should be separate, and perhaps the ampersand should be spelled out ("and").

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will fix

@pixeltrix
Copy link
Contributor

@kaspth @jonathanhefner thanks for the review, perhaps next time we can do it before I merge it 馃槃

@kaspth
Copy link
Contributor

kaspth commented Nov 13, 2016

@pixeltrix yeah, sorry about that! Completely missed this PR when it was first opened 馃槃

pixeltrix added a commit that referenced this pull request Nov 13, 2016
@bogdanvlviv bogdanvlviv deleted the docs branch November 13, 2016 17:53
@bogdanvlviv
Copy link
Contributor Author

Thanks for the review!

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

Successfully merging this pull request may close these issues.

None yet

7 participants