Skip to content

doc: synchronize argument names for appendFile() - #20489

Closed
Trott wants to merge 1 commit into
nodejs:masterfrom
Trott:pathpathpath
Closed

doc: synchronize argument names for appendFile()#20489
Trott wants to merge 1 commit into
nodejs:masterfrom
Trott:pathpathpath

Conversation

@Trott

@TrottTrott commented May 3, 2018

Copy link
Copy Markdown
Member

The documentation used file for the first argument to appendFile()
functions. However, the code and (more importantly) thrown errors
referred to it as path. The latter is especially important because
context is not provided. So you're looking for a function that takes
path but that string doesn't appear in your code or in the
documentation. It's not until the end user looks at the source code of
Node.js that they can figure out what's going on. This is why it is
important that the names of variables in the documentation match that in
the code. If we want to change this to file, then that's OK, but we
need to do it in the source code and error messages too, not just in the
docs. Changing the docs is the smallest change to synchronize everything
so that's what this change does.

Checklist

The documentation used `file` for the first argument to `appendFile()`
functions. However, the code and (more importantly) thrown errors
referred to it as `path`. The latter is especially important because
context is not provided. So you're looking for a function that takes
`path` but that string doesn't appear in your code *or* in the
documentation. It's not until the end user looks at the source code of
Node.js that they can figure out what's going on. This is why it is
important that the names of variables in the documentation match that in
the code. If we want to change this to `file`, then that's OK, but we
need to do it in the source code and error messages too, not just in the
docs. Changing the docs is the smallest change to synchronize everything
so that's what this change does.
@nodejs-github-botnodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels May 3, 2018
@Trott

Trott commented May 3, 2018

Copy link
Copy Markdown
MemberAuthor

Why this matters:

$ node
> fs.appendFile(undefined, 'foo', () => {})TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type undefined at Object.fs.open (fs.js:523:3) at Object.fs.writeFile (fs.js:1253:6) at Object.fs.appendFile (fs.js:1308:6)
>

The error message refers to it as the "path" argument. So the documentation should do the same or else things are puzzling for the user until they look at the source code for Node.js.

@Trott

Trott commented May 3, 2018

Copy link
Copy Markdown
MemberAuthor

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Node.js Collaborators, please, add 👍 here if you approve fast-tracking.

@vsemozhetbytvsemozhetbyt added fast-track PRs that do not need to wait for 48 hours to land. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels May 3, 2018
@Trott

Trott commented May 3, 2018

Copy link
Copy Markdown
MemberAuthor

Landed in a00f76c

@TrottTrott closed this May 3, 2018
Trott added a commit to Trott/io.js that referenced this pull request May 3, 2018
The documentation used `file` for the first argument to `appendFile()`
functions. However, the code and (more importantly) thrown errors
referred to it as `path`. The latter is especially important because
context is not provided. So you're looking for a function that takes
`path` but that string doesn't appear in your code *or* in the
documentation. It's not until the end user looks at the source code of
Node.js that they can figure out what's going on. This is why it is
important that the names of variables in the documentation match that in
the code. If we want to change this to `file`, then that's OK, but we
need to do it in the source code and error messages too, not just in the
docs. Changing the docs is the smallest change to synchronize everything
so that's what this change does.
PR-URL: nodejs#20489
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 4, 2018
The documentation used `file` for the first argument to `appendFile()`
functions. However, the code and (more importantly) thrown errors
referred to it as `path`. The latter is especially important because
context is not provided. So you're looking for a function that takes
`path` but that string doesn't appear in your code *or* in the
documentation. It's not until the end user looks at the source code of
Node.js that they can figure out what's going on. This is why it is
important that the names of variables in the documentation match that in
the code. If we want to change this to `file`, then that's OK, but we
need to do it in the source code and error messages too, not just in the
docs. Changing the docs is the smallest change to synchronize everything
so that's what this change does.
PR-URL: #20489
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request May 8, 2018
MylesBorins pushed a commit that referenced this pull request May 8, 2018
The documentation used `file` for the first argument to `appendFile()`
functions. However, the code and (more importantly) thrown errors
referred to it as `path`. The latter is especially important because
context is not provided. So you're looking for a function that takes
`path` but that string doesn't appear in your code *or* in the
documentation. It's not until the end user looks at the source code of
Node.js that they can figure out what's going on. This is why it is
important that the names of variables in the documentation match that in
the code. If we want to change this to `file`, then that's OK, but we
need to do it in the source code and error messages too, not just in the
docs. Changing the docs is the smallest change to synchronize everything
so that's what this change does.
PR-URL: #20489
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@Trott
Trott deleted the pathpathpath branch January 13, 2022 22:49
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.docIssues and PRs related to the documentations.fast-trackPRs that do not need to wait for 48 hours to land.fsIssues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Trott@vsemozhetbyt@trivikr@nodejs-github-bot