Skip to content

doc: update and modernize examples in api docs - #4282

Closed
jasnell wants to merge 3 commits into
nodejs:masterfrom
jasnell:fix-http-doc
Closed

doc: update and modernize examples in api docs#4282
jasnell wants to merge 3 commits into
nodejs:masterfrom
jasnell:fix-http-doc

Conversation

@jasnell

Copy link
Copy Markdown
Member
  • Use single quotes consistently
  • Modernize examples to use template strings and arrow funcs
  • Fix typos
  • Fix a few line wrap issues

/cc @nodejs/http

@jasnelljasnell added http Issues or PRs related to the http subsystem. doc Issues and PRs related to the documentations. labels Dec 14, 2015
Comment threaddoc/api/http.markdown Outdated

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

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.

-varhttp=require('http');+consthttp=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.

@MylesBorins

Copy link
Copy Markdown
Contributor

LGTM. Small comment regarding using const in docs above, but that is not relevant to this landing

@mscdex

Copy link
Copy Markdown
Contributor

Argh, the ES6 inline functions continue to creep in!

@jasnell

Copy link
Copy Markdown
MemberAuthor

lol ... they're not the prettiest thing in the world but it's the direction things are heading

Comment threaddoc/api/http.markdown Outdated

Copy link
Copy Markdown
Contributor

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) => {.

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Contributor

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 => {

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor

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.

@jasnell

Copy link
Copy Markdown
MemberAuthor

@thealphanerd@cjihrig ... ok, just pushed a big update. Fixed up all of the doc examples at once.

@jasnelljasnell changed the title doc: update examples in http.markdowndoc: update and modernize examples in api docsDec 15, 2015
@jasnell

Copy link
Copy Markdown
MemberAuthor

@nodejs/documentation

@chrisdickinson

Copy link
Copy Markdown
Contributor

Are you comfortable asserting that the code examples still work as authored? If so, this LGTM pending arrow function style nits!

@jasnell

Copy link
Copy Markdown
MemberAuthor

I'm going to be going through and testing the various cases. Gimme a day to
get through them. Pretty certain everything is good tho
On Dec 14, 2015 9:44 PM, "Chris Dickinson" notifications@github.com wrote:

Are you comfortable asserting that the code examples still work as
authored? If so, this LGTM pending arrow function style nits!


Reply to this email directly or view it on GitHub
#4282 (comment).

@chrisdickinson

Copy link
Copy Markdown
Contributor

@jasnell Awesome, thanks — great work!

@Fishrock123

Copy link
Copy Markdown
Contributor

While we're at it, is there a good reason to keep semicolons in these?

@cjihrig

Copy link
Copy Markdown
Contributor

LGTM

Comment threaddoc/api/assert.markdown Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what change happened here?

Copy link
Copy Markdown
MemberAuthor

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.

@cjihrig

Copy link
Copy Markdown
Contributor

New changes look good. Left one comment directly on the commit instead of the PR.

@jasnell

Copy link
Copy Markdown
MemberAuthor

const can be used without 'use strict', it's let that can't be used without it.

bash-3.2$ cat ~/tmp/test.js
const m = 1;
let n = 1;
bash-3.2$ node ~/tmp.test
module.js:339
throw err;
^
Error: Cannot find module '/Users/james/tmp.test'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3
bash-3.2$ 

@Trott

Copy link
Copy Markdown
Member

Uh, yeah, never mind my previous comments about strict mode...

@jasnell

Copy link
Copy Markdown
MemberAuthor

Pushed update to pull the "fix" for #4296 back out. That change isn't necessary for master or v5

@jasnell

Copy link
Copy Markdown
MemberAuthor

@cjihrig ... updated the 0022 to 0o022 per your suggestion

@jasnell

Copy link
Copy Markdown
MemberAuthor

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

@jasnell

Copy link
Copy Markdown
MemberAuthor

I'd like to get this landed soon but would appreciate a bit more eyes on it. /cc @nodejs/documentation

@jasnell

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
MemberAuthor

Getting this landed momentarily

jasnell added a commit that referenced this pull request Dec 17, 2015
* 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>
@jasnell

Copy link
Copy Markdown
MemberAuthor

Landed in 9b21119

@jasnelljasnell closed this Dec 17, 2015
@jasnelljasnell mentioned this pull request Dec 17, 2015
Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request Dec 22, 2015
* 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>
jasnell added a commit that referenced this pull request Dec 30, 2015
* 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>
Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request Jan 6, 2016
* 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>
MylesBorins pushed a commit that referenced this pull request Jan 19, 2016
* 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>
@MylesBorinsMylesBorins mentioned this pull request Jan 19, 2016
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
* 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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docIssues and PRs related to the documentations.httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@jasnell@MylesBorins@mscdex@chrisdickinson@Fishrock123@cjihrig@Trott@rvagg