-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: add flags section to document all flags #20042
doc: add flags section to document all flags #20042
Conversation
doc/api/fs.md
Outdated
The following flags are available wherever the `flag` option takes a | ||
string: | ||
|
||
* `'r'` - Open file for reading. |
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'll be helpful if flags are sorted in 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.
ok, I'm on it!
Would it also make sense to rearrange the existing flag on open() to also be rearranged, or is there a reason to keep the other ones in their original 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.
I'll let @nodejs/fs take a call, in fs.open()
the flags are separated into read and write ones.
I don't think the description for flags
should be repeated in the documentation. In my opinion, fs.open()
should also link to this description for flags.
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 sorting the flags is a good idea.
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.
Thanks, they should now be sorted and consolidated in one area!
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 replace the description of flags in fs.open
with a link to the newly added section to avoid duplication?
Removed any other area where the flag descriptions were being duplicated into one area that is being linked from everywhere. |
doc/api/fs.md
Outdated
Modifying a file rather than replacing it may require a flags mode of `'r+'` | ||
rather than the default mode `'w'`. | ||
|
||
The behavior of some flags are platform-specific. As such, opening a directory |
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 behavior of fs.open()
is platform-specific for some flags
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 fsPromises.open()
, a FileHandle
instead of file descriptor is returned. Are those different @joyeecheung ?
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 point!
I thought that both fs.open()
and fsPromises.open()
have the same caveats, so I included those together. If FileHandle
differs from the file descriptor, then it might make sense to put them within their respective function descriptions.
doc/api/fs.md
Outdated
@@ -4719,6 +4573,95 @@ The following constants are meant for use with the [`fs.Stats`][] object's | |||
</tr> | |||
</table> | |||
|
|||
### File System Flags |
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.
File System flags is not part of FS Constants, this should be a separate section by changing to ## File System Flags
c5a7c21
to
c73d576
Compare
doc/api/fs.md
Outdated
the file contents. | ||
|
||
|
||
|
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: please always just use single line breaks. So all the added line breaks here are obsolete.
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 for the pointer! Fixed in latest commit!
@nodejs/documentation @nodejs/fs PTAL |
c73d576
to
5134ffc
Compare
doc/api/fs.md
Outdated
@@ -910,7 +910,7 @@ changes: | |||
* `options` {Object|string} | |||
* `encoding` {string|null} **Default:** `'utf8'` | |||
* `mode` {integer} **Default:** `0o666` | |||
* `flag` {string} **Default:** `'a'` | |||
* `flag` {string} See [support of file system `flags`][] **Default:** `'a'` |
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 we have two full sentences here now, so we need to add periods after the both to be consistent with other docs:
See [support of file system `flags`][]. **Default:** `'a'`.
The same for all the cases below (if Default
is missing then only one period is needed).
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.
Resolved in commit 14da387
doc/api/fs.md
Outdated
@@ -4761,6 +4701,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's | |||
[Caveats]: #fs_caveats | |||
[Common System Errors]: errors.html#errors_common_system_errors | |||
[FS Constants]: #fs_fs_constants_1 | |||
[support of file system `flags`]: #fs_file_system_flags |
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 are only 2 references here out of ASCII sorting, so let's do not increase the disorder and add this at the end of the list, after [inode]:
and two other stray references.
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.
Resolved in 14da387
The following flags are available wherever the `flag` option takes a | ||
string: | ||
|
||
* `'a'` - Open file for appending. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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 be taken care of as well :)
doc/api/fs.md
Outdated
|
||
The behavior of some flags are platform-specific. As such, opening a directory | ||
on macOS and Linux with the `'a+'` flag - see example below - will return an | ||
error. In contrast, on Windows and FreeBSD, a file descriptor will be returned. |
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.
a file descriptor
-> a file descriptor or a `FileHandle`
?
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.
Resolved in 14da387
doc/api/fs.md
Outdated
* `'a'` - Open file for appending. | ||
The file is created if it does not exist. | ||
|
||
* `'ax'` - Like `'a'` but fails if `path` exists. |
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.
`path`
-> the path
?
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.
All path
-> the path
resolved in 14da387
doc/api/fs.md
Outdated
* `'a+'` - Open file for reading and appending. | ||
The file is created if it does not exist. | ||
|
||
* `'ax+'` - Like `'a+'` but fails if `path` exists. |
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.
`path`
-> the path
?
doc/api/fs.md
Outdated
* `'w'` - Open file for writing. | ||
The file is created (if it does not exist) or truncated (if it exists). | ||
|
||
* `'wx'` - Like `'w'` but fails if `path` exists. |
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.
`path`
-> the path
?
doc/api/fs.md
Outdated
* `'w+'` - Open file for reading and writing. | ||
The file is created (if it does not exist) or truncated (if it exists). | ||
|
||
* `'wx+'` - Like `'w+'` but fails if `path` exists. |
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.
`path`
-> the path
?
doc/api/fs.md
Outdated
``` | ||
|
||
On Windows, opening an existing hidden file using the `'w'` flag (either | ||
through `fs.open` or `fs.writeFile` or `fsPromises.open()`) will fail with |
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.
`fs.open` or `fs.writeFile`
-> `fs.open()` or `fs.writeFile()`
?
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 nothing is missed while merging.
LGTM with nits addressed.
Thank you!
5134ffc
to
9ee3214
Compare
This comment has been minimized.
This comment has been minimized.
@indranil Kindly remove merge commit and use rebase instead as described in contributing guidelines |
26bdc14
to
c57b08c
Compare
sorry this took so long, but finally removed and rebased and repushed! |
This comment has been minimized.
This comment has been minimized.
@indranil The nits mentioned by @vsemozhetbyt still need to be addressed. |
c57b08c
to
f51eef1
Compare
omg so sorry my merge undid all those changes! redid them and pushed them, thank you! |
This comment has been minimized.
This comment has been minimized.
doc/api/fs.md
Outdated
* `'rs+'` - Open file for reading and writing in synchronous mode. Instructs | ||
the operating system to bypass the local file system cache. | ||
|
||
This is primarily useful for opening files on NFS mounts as it allows |
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.
Md-lint finds trailing tab 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.
Resolved in 4b70819
doc/api/fs.md
Outdated
on macOS and Linux with the `'a+'` flag - see example below - will return an | ||
error. In contrast, on Windows and FreeBSD, a file descriptor or a `FileHandle` | ||
will be returned. | ||
|
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.
Md-lint finds trailing tab here)
Adds a section at the very end to document all flags and links to it from every function that takes a flag argument. Fixes: nodejs#16971
Removed description of flags into one place, linking to it from all other references. Also rearranged the flags alphabetically, keeping connected ones together. Fixes: nodejs#16971
Addressing comments
Removed unnecessary newlines from the end of document
Finally able to resolve the merge conflicts
All changes in the previous commits, consolidated location, adding periods, putting notes together were wiped away by my clumsy merge. Redid them all!
Two trailing tabs caught by the linter removed
f51eef1
to
4b70819
Compare
thank you for that! fixed that now :) |
If there are no objections, I will land soon. |
Landed in 53822f6 |
Adds a section at the very end to document all flags and links to it from every function that takes a flag argument.
I kept the flags that were in fs.open() for people who are familiar with the docs already.
Fixes: #16971
Checklist