Skip to content
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

Closed

Conversation

indranil
Copy link
Contributor

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

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Apr 15, 2018
doc/api/fs.md Outdated
The following flags are available wherever the `flag` option takes a
string:

* `'r'` - Open file for reading.
Copy link
Member

@trivikr trivikr Apr 15, 2018

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

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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!

Copy link
Member

@joyeecheung joyeecheung left a 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?

@indranil
Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Member

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 ?

Copy link
Contributor Author

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
Copy link
Member

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

doc/api/fs.md Outdated
the file contents.



Copy link
Member

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.

Copy link
Contributor Author

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!

@BridgeAR
Copy link
Member

@nodejs/documentation @nodejs/fs PTAL

@indranil indranil force-pushed the docs-fs-extract-flags-into-own-section branch from c73d576 to 5134ffc Compare April 15, 2018 20:57
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'`
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

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

Copy link
Member

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
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

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.

Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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`?

Copy link
Member

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.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

Choose a reason for hiding this comment

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

`path` -> the path?

Copy link
Member

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.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

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.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

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.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 15, 2018

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
Copy link
Contributor

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()`?

Copy link
Contributor

@vsemozhetbyt vsemozhetbyt left a 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!

@indranil indranil force-pushed the docs-fs-extract-flags-into-own-section branch from 5134ffc to 9ee3214 Compare April 16, 2018 06:47
@vsemozhetbyt

This comment has been minimized.

@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 16, 2018
@trivikr
Copy link
Member

trivikr commented Apr 18, 2018

@indranil Kindly remove merge commit and use rebase instead as described in contributing guidelines

@trivikr trivikr removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 18, 2018
@indranil indranil force-pushed the docs-fs-extract-flags-into-own-section branch from 26bdc14 to c57b08c Compare April 20, 2018 04:23
@indranil
Copy link
Contributor Author

sorry this took so long, but finally removed and rebased and repushed!

@trivikr

This comment has been minimized.

@trivikr trivikr added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Apr 20, 2018
@trivikr
Copy link
Member

trivikr commented Apr 20, 2018

@indranil The nits mentioned by @vsemozhetbyt still need to be addressed.

@indranil indranil force-pushed the docs-fs-extract-flags-into-own-section branch from c57b08c to f51eef1 Compare April 20, 2018 09:35
@indranil
Copy link
Contributor Author

omg so sorry my merge undid all those changes! redid them and pushed them, thank you!

@vsemozhetbyt

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
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Apr 20, 2018

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)

Copy link
Member

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.

Copy link
Contributor

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
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
@indranil indranil force-pushed the docs-fs-extract-flags-into-own-section branch from f51eef1 to 4b70819 Compare April 20, 2018 11:18
@indranil
Copy link
Contributor Author

thank you for that! fixed that now :)

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 20, 2018
@vsemozhetbyt
Copy link
Contributor

If there are no objections, I will land soon.

@trivikr
Copy link
Member

trivikr commented Apr 20, 2018

Landed in 53822f6

@trivikr trivikr closed this Apr 20, 2018
trivikr pushed a commit that referenced this pull request Apr 20, 2018
Adds a section at the very end to document all flags and links
to it from every function that takes a flag argument.

Fixes: #16971

PR-URL: #20042
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
jasnell pushed a commit that referenced this pull request Apr 20, 2018
Adds a section at the very end to document all flags and links
to it from every function that takes a flag argument.

Fixes: #16971

PR-URL: #20042
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs.createWriteStream docs does not define flags
6 participants