-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
doc: update and modernize examples in api docs #4282
Conversation
@@ -103,7 +103,7 @@ of these values set to their respective defaults. | |||
To configure any of them, you must create your own [`http.Agent`][] object. | |||
|
|||
```javascript | |||
var http = require('http'); | |||
const http = require('http'); |
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.
should we do a pass at replacing all instances of require in docs with const?
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.
Incrementally, perhaps. I don't think it's critical enough to do all at once
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.
fair enough. my only thought on this is that it might be weird to have things in the docs inconsistent, but it makes sense to avoid massive churn
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.
It might actually be better to have huge docs only churn in a single commit, instead of 32 commits. People are a lot less likely to bisect and blame the docs.
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.
Looking it over, I agree. It's not a huge chunk of work. Already have it
mostly done. Will update this PR with the other updates.
On Dec 14, 2015 4:51 PM, "Colin Ihrig" notifications@github.com wrote:
In doc/api/http.markdown
#4282 (comment):@@ -103,7 +103,7 @@ of these values set to their respective defaults.
To configure any of them, you must create your own [http.Agent
][] object.-var http = require('http'); +const http = require('http');It might actually be better to have huge docs only churn in a single
commit, instead of 32 commits #3662.
People are a lot less likely to bisect and blame the docs.—
Reply to this email directly or view it on GitHub
https://github.com/nodejs/node/pull/4282/files#r47583137.
LGTM. Small comment regarding using const in docs above, but that is not relevant to this landing |
Argh, the ES6 inline functions continue to creep in! |
lol ... they're not the prettiest thing in the world but it's the direction things are heading |
@@ -64,10 +64,10 @@ a `'close'` event or a special `'agentRemove'` event. This means that if | |||
you intend to keep one HTTP request open for a long time and don't | |||
want it to stay in the pool you can do something along the lines of: | |||
|
|||
http.get(options, function(res) { | |||
http.get(options, (res)=> { |
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 don't think we have any linting rules for arrow functions yet, but from a quick code search, it looks like the convention has been to put spaces on each side of the arrow. So, in this case (res) => {
.
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.
agreed, I'm only seeing (args) => {
in use in the wild at the moment with the extra space (not that I'm looking very widely)
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.
In this case it's probably fine to omit the parens, as well — http.get(options, res => {
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.
my vote would be to never omit parens to be explicit what's going on, I personally find the paren-free version little too terse
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.
It's definitely a brand new 🚲🏡; I don't feel strongly enough either way to propose setting a hard-and-fast rule for it. In my own projects, I lean towards minimizing characters in code examples to give other info more room, but two characters is not a huge amount of savings so I'm comfortable leaving this as a personal preference of the doc author for the time being.
b1aaf1e
to
49414c1
Compare
@thealphanerd @cjihrig ... ok, just pushed a big update. Fixed up all of the doc examples at once. |
@nodejs/documentation |
Are you comfortable asserting that the code examples still work as authored? If so, this LGTM pending arrow function style nits! |
I'm going to be going through and testing the various cases. Gimme a day to
|
@jasnell Awesome, thanks — great work! |
While we're at it, is there a good reason to keep semicolons in these? |
LGTM |
@@ -135,4 +135,4 @@ Custom error validation: | |||
[`assert.throws()`]: #assert_assert_throws_block_error_message | |||
[`Error`]: errors.html#errors_class_error | |||
[`RegExp`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions | |||
[`TypeError`]: errors.html#errors_class_typeerror |
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.
what change happened here?
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.
Not a clue. Likely a whitespace change. Will fix.
New changes look good. Left one comment directly on the commit instead of the PR. |
|
Uh, yeah, never mind my previous comments about strict mode... |
184623b
to
6912a17
Compare
Pushed update to pull the "fix" for #4296 back out. That change isn't necessary for master or v5 |
@cjihrig ... updated the |
I marked this for LTS watch but it likely won't land cleanly. If/when it lands, I'll put together a modified version for v4.x-staging |
I'd like to get this landed soon but would appreciate a bit more eyes on it. /cc @nodejs/documentation |
0961cf3
to
866efa0
Compare
Rebased and updated... |
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos
Additional example edits for consistency
Per @cjihrig's suggestion
866efa0
to
aab18d0
Compare
Getting this landed momentarily |
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: #4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 9b21119 |
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: nodejs#4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: #4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: nodejs#4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: #4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: nodejs#4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
/cc @nodejs/http