Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
doc: add WHATWG file URLs in fs module#12670
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
anchnk commented Apr 26, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
jasnell left a comment
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.
Minor rewording suggestion. Thank you very much for doing this! :-)
doc/api/fs.md Outdated
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.
Suggestion:
For most `fs` module functions, the `path` or `filename` argument may be passed as a WHATWG [URL][] object. Only [URL][] objects using the `file:` protocol are supported. Use of [URL][] objects is currently still experimental. *Note*: `file:` URLs are always absolute paths. Then add a link at the end of the page:
[URL]: url.html#url_the_whatwg_url_api anchnk commented Apr 26, 2017
@jasnell Updated the PR in order to include your rewording suggestion ! Thanks a lot for helping me out 👍 |
doc/api/fs.md Outdated
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 not documentation for a method, but description of the payload of an event. Hence it cannot be a URL.
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.
Absolutely right, on my way to correct that.
addaleax left a comment
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.
LGTM with @TimothyGu’s comment addressed
doc/api/fs.md Outdated
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 think the ; here is a typo, you can remove it while you’re already here if you want
anchnkApr 26, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
Good catch @addaleax fixing it as well
anchnk commented Apr 26, 2017
Pushed a new commit including suggestions from @TimothyGu and @addaleax |
addaleax commented Apr 26, 2017
It’s a docs-only change, I think we’re good. :) We may have linting for the docs at some point in the future, but we haven’t integrated anything into CI or |
benjamingr commented Apr 26, 2017
Looks good but would love to see some examples added. |
TimothyGu left a comment
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.
Almost there!
doc/api/fs.md Outdated
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 should maintain the alphabetical order.
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.
Hi @TimothyGu what alphabetical order ? I was trying to figure it out if there was something like that when I included that change. However i couldn't guess what the logic was as list items seems a bit melted.
Does internal vs external links matters in the order ?
Does functions / classes matters ?
If you can describe me the logical structure beneath the list I will be happy to sort that :)
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.
the links are un-ordered ATM, sadly, this seems as good a place as any for now
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.
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.
Thank you @sam-github. I will wait that your PR is merged to rebase it in mine.
doc/api/fs.md Outdated
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.
Aside from the scheme limitation, we also have some other platform-specific restrictions. Documenting them through examples can be helpful.
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 second that. Examples may be helpful. Will work on that tomorrow. Thanks a lot !
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.
link experimental to the stability index, pls
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.
@sam-github You mean link experimental to documentation.html#documentation_stability_index ?
anchnk commented Apr 27, 2017
Created this gist with proposal of examples. Feedback is welcome ! Also I plan to add James description in his PR #10739 below the short description i previously made at the root module level.
|
sam-github commented Apr 27, 2017
Please don't use Fwiw, I'm not sure why we need this feature. Unlike https://www.npmjs.com/package/open-uri you need to already have parsed a url into a |
addaleax commented Apr 27, 2017
The WHATWG URL API is experimental, the usage of the term in this PR is correct. In this case, it’s the description of “experimental” in the Stability index that’s wrong – we haven’t been consistent about putting experimental features behind flags (which I am okay with, it can be a case-by-case decision, but we should probably document that better). |
Review was for an older iteration of the PR
jasnell commented Apr 27, 2017
The WHATWG URL stuff is still technically experimental, although I'm likely to be opening a PR very soon (ahem, later today) that proposes upgrading it to a fully supported feature. |
sam-github commented Apr 27, 2017
I think the URL stuff is technically NOT experimental :-). But as @jasnell says, it will be irrelevant soon. @anchika That still means you should remove the experimental text. @addaleax I'm opening an issue seeking confirmation that the text is correct as-is. Until the definition is changed, it is what it is. Full disclosure, I think that we should hide all experimental features behind a flag. Maybe we should talk about at collab summit. #10739 is absent of any information on why the feature should be added, I still think its odd. Not sure what use-case its for. Does it help browser compatibility? But they don't have "experimental" status or not, I doubt we are going to delete this feature now that its here, perhaps the docs can at least say what its useful for. Also, does the arg actually have to be a |
jasnell commented Apr 27, 2017
@sam-github ... this PR should be ready to land before my PR removing the experimental status so the experimental text should actually remain in this PR.
In practice, yes. See https://github.com/nodejs/node/blob/master/lib/internal/url.js#L1348. The code checks for the presence of the |
anchnk commented Apr 27, 2017
Pushed a new commit with platform specific description and examples as requested by @TimothyGu. |
doc/api/fs.md Outdated
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.
stability statement are usually linked to stability definitions
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.
@sam-github Same as above link the word experimental to documentation.html#documentation_stability_index
jasnell commented Apr 28, 2017
@anchnk ... looks like this needs a quick rebase :-) |
anchnk commented Apr 28, 2017
TimothyGu left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 PR still doesn't address restrictions like these:
// On POSIXfs.readFileSync(newURL('file:///path/%2F'));// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded / characters// On Windowsfs.readFileSync(newURL('file:///C:/path/%2F'));fs.readFileSync(newURL('file:///C:/path/%5C'));// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded \ or / characters// On Windowsfs.readFileSync(newURL('file:///notdriveletter/path/%5C'));// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute
You might want to split this part of the documentation into a new chapter "WHATWG URL object support" (or something like that). The section has grown too big IMO.
doc/api/fs.md Outdated
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.
nit: extra space before =
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.
fixed with last commits
doc/api/fs.md Outdated
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.
camelCase please.
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.
fixed with last commits
doc/api/fs.md Outdated
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 seems more common to have the drive letter capitalized.
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.
fixed
doc/api/fs.md Outdated
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.
Template string literal is unnecessary here. A ' should suffice.
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.
fixed
doc/api/fs.md Outdated
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.
Windows
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.
fixed
doc/api/fs.md Outdated
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.
IMO it would be easier to use the synchronous API (fs.readFileSync) instead. You can even leave off the encoding argument since it's not necessary to demonstrate URL support.
fs.readFileSync(fileURL);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 the last commits I tried to remove everything that wasn't meaningful for the examples. So now they are quite minimalistic. That was based on your suggestion, again let me know.
doc/api/fs.md Outdated
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.
[`URL`][] objectThere 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 created a new chapter on the last commit based on your suggestion @TimothyGu . Also the URL link formatting is fixed.
doc/api/fs.md Outdated
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.
You are missing a */ 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.
Oups ! thank you fixed !
doc/api/fs.md Outdated
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 you make sure to not have whitespace before :? ;)
anchnk commented Apr 30, 2017
I did quite a bunch of changes in the last commits, so feel free to give any feedback. |
TimothyGu left a comment
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.
One last comment. Otherwise LGTM.
doc/api/fs.md Outdated
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 entry shouldn't be necessary anymore.
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.
Fixed !
Thank you a lot.
Your feedback & suggestions greatly helped me.
TimothyGu left a comment
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.
Other than the tiniest of nits, LGTM.
doc/api/fs.md Outdated
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.
Extra space before :
(This is English, not French :)
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.
Oh so right, forgot about that difference. Sorry :) All fixed in latest commit
doc/api/fs.md Outdated
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.
Ditto.
doc/api/fs.md Outdated
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.
Here too.
doc/api/fs.md Outdated
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.
... and here.
jasnell commented May 4, 2017
@anchnk ... can you squash the commits down to prepare for landing? |
Update fs module documentation adding WHATWG file URLS support for relevant fs functions/classes. Fixes: nodejs#12341 Refs: nodejs#10739
anchnk commented May 4, 2017
@jasnell Squashing done. |
Update fs module documentation adding WHATWG file URLS support for relevant fs functions/classes. PR-URL: #12670Fixes: #12341 Ref: #10739 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
jasnell commented May 4, 2017
Landed in c1b3b95 |
Update
fsmodule documentation adding WHATWG file URLs support for relevant fs functions/classes.Fixes: #12341
Refs: #10739
Checklist
Affected core subsystem(s)
doc, fs
Description of change
fsroot level.Where relevant :
YAMLflags in order to update revision history.fsfunctions / classes arguments types.