-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix docs for ActionController::Metal#headers #45362
Conversation
129f95d
to
4325b08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that this comment recommends using
headers
,status
, etc. instead ofresponse.*
, but the examples in Action Controller Overview seem to useresponse.headers
:
Should this comment or the examples be changed to be consistent?
I also just noticed this example (added by c83e147) too. Based on the relative age of that example and the example in the Action Controller guide (present in e56b3e4), I would say the ship has sailed, and we should remove the "should never be used directly in controllers" admonition.
And if we do that, we should probably concentrate the documentation under ActionDispatch::Response#headers
, and then document ActionController::Metal#headers
as simply "Delegates to ActionDispatch::Response#headers." What do you think?
After looking to link to #response , I found its not actually documented because its attr_internal ... should it (and #request ) be documented and/or not attr_internal ?)
|
I think it would make sense to document them as well. Perhaps something simple like "Returns an ActionDispatch::Response object for the current request." As for |
02980f4
to
d0f56b5
Compare
## | ||
# Returns the ActionDispatch::Response object for the current request | ||
attr_internal :response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently being documented as a method, but we could also mark it as an attribute which may be more accurate?
## | |
# Returns the ActionDispatch::Response object for the current request | |
attr_internal :response | |
## | |
# :attr_accessor: response | |
# Returns the ActionDispatch::Response object for the current request | |
attr_internal :response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, perhaps so. The downside is that attributes don't show up when searching in the rendered docs sidebar. Also, attributes are linkable in the sense that references to them will become links, but attributes aren't rendered with destination anchors, so the links just go to the top of the page. I'm not sure whether those are RDoc issues or SDoc issues, though.
I hadn't actually looked, so I did not notice, but To get this over the finish line, I pushed a new commit. If you think it looks good, I can squash and merge. Here's what I did:
|
🤦 that's what I get for scope creeping haha, I guess I forgot to check that one
Yep, I went through the same things. I like the specific mention of the alias, I think this is probably better
Just double checking, I think there is a writer, but I'm not sure we should be telling people they can use it Other than that I think everything looks good 👍 |
This documentation was correct when it was written in 6e75455, however `headers` has moved a few times since: - added to ActionController::Http in 216309c as part of the new_base - Http was renamed to Metal in 52798fd - headers was changed from an independent hash to a delegation in 51c7ac1 and 54becd1 Added docs for Metal#request, Metal#response, and Metal#headers that can be linked to from Response. The recommendation to use Metal delegation methods instead of methods on Response was also removed due to a number of docs/guides demonstrating the opposite.
7e056f7
to
ab31e83
Compare
Yes, that is my thinking as well. Thank you, @skipkayhil! 👋 |
Summary
This documentation was correct when it was written in 6e75455, however
headers
has moved a few times since:51c7ac1 and 54becd1
Added docs for Metal#request, Metal#response, and Metal#headers that can
be linked to from Response. The recommendation to use Metal delegation
methods instead of methods on Response was also removed due to a number of
docs/guides demonstrating the opposite.
Other Information
Running CI per feedback in #45347 (comment)
I've noticed that this comment recommends usingheaders
,status
, etc. instead ofresponse.*
, but the examples in Action Controller Overview seem to useresponse.headers
:rails/guides/source/action_controller_overview.md
Line 907 in 4f6f3c9
Should this comment or the examples be changed to be consistent?Updated to remove this recommendation per discussion