-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
tools/doc: improvements for types #11167
Conversation
The first commit LGTM. For the second, I would prefer a more generic syntax like |
I actually prefer primitives to stay lowercase. Can't we just fix the parser? Also on an unrelated note, in the particular example you showed, the inline 'pem' property description should actually have |
I don't have stats, but I estimate that > 80% of our types are currently capitalized.
That'd be quite hard to parse. It's not following the type convention of |
I'm not suggesting it should parse it necessarily, I'm mostly just pointing out a typo that should be corrected. |
tools/doc/type-parser.js
Outdated
@@ -62,6 +62,17 @@ module.exports = { | |||
typeUrl = nodeDocUrl + typeMap[typeText]; | |||
} | |||
|
|||
if (/\[]$/.test(typeText)) { | |||
const typeTextBare = typeText.slice(0, -2); | |||
if (jsPrimitives[typeTextBare]) { |
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.
Can we merge this if...else
chain with the previous one on line 57?
So on current master we have 571 occurences in docs with capitalized primitive types and 160 without. I could change those all to lowercase as suggested by @mscdex. MDN currently lists them capitalized and the |
I would consider this as a problem. |
2189a90
to
e8409ac
Compare
Updated:
Example: @nodejs/documentation PTAL. |
Consistency sounds great to me. Is the example in #11167 (comment) what it looks like now? How come |
Because |
@silverwind, have you seen my comment above? |
Yes, I think |
Not so sure that's a useful distinction that we need to convey to our doc readers, given that strings do have methods in practical cases, but at least its something we can point to in our docs, and say we are following jsdoc. Did you mean to write |
BTW flow and TypeScript are using lower-cased primitive types too(therefore used by definitely typed, where a lot of people get their types from in their tools nowadays even if they don't use TypeScript) |
FWIW, Tern also uses lowercased primitive types. |
My mind is trained to understand a name as a constructor function if it starts with a capital letter. So I am going to go with lowercase names. |
I think we are in agreement that lowercase primitives is the way to go. Can I get a few LGTMs? I'll rebase and land shortly after it's approved. |
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.
LTGM with a rebase
PR-URL: #11167 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
ping |
Backport in #13054 |
PR-URL: nodejs#11167 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: nodejs#11167 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: nodejs#11167 Backport-PR-URL: nodejs#13054 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: nodejs#11167 Backport-PR-URL: nodejs#13054 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
The first commit capitalizes all primitive types so the parser can pick them up.
The second commit adds logic to the doctool to allow parsing of
Type[]
array syntax.Before
After