doc: fix nits in code examples of async_hooks.md#13400
doc: fix nits in code examples of async_hooks.md#13400vsemozhetbyt wants to merge 6 commits intonodejs:masterfrom vsemozhetbyt:async_hooks.md
Conversation
|
I am unsure about 2 fragments if there are typos there:
Let me know if these are to be addressed too. |
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
Yeah, something is wrong with the async_hooks.currentId() this is supposed to be 2.
edit: oh, it might be because of console.log. Then 6 is likely correct.
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
I don't care. But for me, this is not more readable than the original.
There was a problem hiding this comment.
FWIW, for me, mixing template literals with string concatenation seems a bit confusing. However, if there are some -1, I can revert.
There was a problem hiding this comment.
FWIW You know I like it when you assign expressions to consts, make it "less operations per line"
But if not I'm +1 for homogeneous templates vs. templates + contacts
There was a problem hiding this comment.
And now I see it's used for all hooks, so +4 on const indentString = ' '.repeat(indent)
There was a problem hiding this comment.
I agree with @AndreasMadsen , the previous version was more readable in my eyes.
There was a problem hiding this comment.
I think it is the lack of separation between formatting (' '.repeat(indent)) and information (${type}(${asyncId}). Maybe if ${indentString} ${type}(${asyncId}): is used we get the best of both worlds.
No, task it correct. Although "purpose" might be a better word.
Yes, those are good suggestions. |
|
New linter CI after rewording and fixing a typo: https://ci.nodejs.org/job/node-test-linter/9553/ |
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
I say remove both, snippets don't have to be complete, so this is cruft.
There was a problem hiding this comment.
Well, they need not, but many readers will test the snippets, so I prefer to be consistent towards completeness, not implying (RE: empathy :)
doc/api/async_hooks.md
Outdated
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
FWIW You know I like it when you assign expressions to consts, make it "less operations per line"
But if not I'm +1 for homogeneous templates vs. templates + contacts
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
And now I see it's used for all hooks, so +4 on const indentString = ' '.repeat(indent)
doc/api/async_hooks.md
Outdated
doc/api/async_hooks.md
Outdated
There was a problem hiding this comment.
less (because of the destructuring) but still cruft
There was a problem hiding this comment.
This is the only place where a reader can find out how to obtain AsyncResource.
|
cruft - https://en.wikipedia.org/wiki/Cruft
That sentence is too metaphorical (borderline poetry 😉). I would suggest: |
|
About the
|
|
One more thing. I know a guy who is a big contributor in StackExchange, he always puts tiny mistakes in his snippets so the users will have to understand them in order to fix the problem. |
|
@refack One nice thing about explicit
One problem that we might not notice much is that much of the Node documentation is written by people with an extensive understanding of how Node works, like everybody in this conversation. I can’t actually tell whether those extra bits of code are helpful, because how to create them is obvious to me even in the case of the destructuring ones, and I suspect the same might be true for you. ;) |
|
I've tried to address comments: Commit 1: remove 2 Commit 4: add a helper variable to reduce clutter. Commit 6: ID -> asyncId. |
That's a very laudable goal!
Definitely! I agree it's hard to find the right balance. |
refack
left a comment
There was a problem hiding this comment.
I think it's a good balance 💯
|
Landed in 5d9dc94 |
* Make `require()` consistent. * Add missing argument. * Add missing `\n` in outputs. * Reduce string concatenations. * Update outputs. * Reword and fix a typo. PR-URL: #13400 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
* Make `require()` consistent. * Add missing argument. * Add missing `\n` in outputs. * Reduce string concatenations. * Update outputs. * Reword and fix a typo. PR-URL: #13400 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Checklist
Affected core subsystem(s)
doc, async_hooks
require()consistent.\nin outputs.