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: missing require calls in some code examples #6596

Closed
janriemer opened this issue May 5, 2016 · 6 comments
Closed

doc: missing require calls in some code examples #6596

janriemer opened this issue May 5, 2016 · 6 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@janriemer
Copy link
Contributor

Hi,
wandering through the api docs, I recognized that some code examples do
not have a const foo = require('foo'); in it, but just use foo without requiring it.

Obviously when we talk about global modules like Buffer or process this is totally correct.
However some require calls are really missing, among others, in e.g. net module or querystring module.

I would like to create a PR for it, adding the missing require calls.


In this context, I would also like to mention the PR about introducing ESLint for the docs, where this ESLint rule seems to be a good fit for this issue.


Do you guys have any thoughts or proposals for this issue before I dive in?
Thanks for your feedback. 😉

@mscdex mscdex added the doc Issues and PRs related to the documentations. label May 5, 2016
@Trott
Copy link
Member

Trott commented May 27, 2017

Feel free to open a pull request for any sample code that is missing a non-obvious require() call. (As you suggest, I don't think we need to add const buffer = require('buffer') to every example in the buffer docs, but if sample code in there also uses assert, then adding a require() for assert totally makes sense to me.)

/cc @nodejs/documentation especially @vsemozhetbyt who may have already fixed this?

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented May 27, 2017

@Trott As I recall, we have a huge amount of omissions here, and this is partly the cause the no-undef rule is off in the doc/.eslintrc.yaml. I also recall some of the collaborators told the docs examples need not be a full runnable code, they imply a lot of prerequisites and omissions of require() are included in this implying.

@Trott
Copy link
Member

Trott commented May 27, 2017

I also recall some of the collaborators told the docs examples need not be a full runnable code, they imply a lot of prerequisites and omissions of require() are included in this implying.

In that case, should we close this issue?

@vsemozhetbyt
Copy link
Contributor

If nobody has an objection, maybe we could.

@Trott
Copy link
Member

Trott commented May 27, 2017

Closing, but if anyone (including original poster) thinks that's misguided, feel free to comment (or re-open if GitHub permits you to).

@Trott Trott closed this as completed May 27, 2017
@janriemer
Copy link
Contributor Author

Hi guys,
thanks for your engagement in this issue.
I've seen that e.g. in Query String module there is now a dedicated section showing how to access this module with require, so this issue has become obsolete and can remain closed.

Just in case you want to know, why I'm so picky about this (feel free to ignore this): 😉
It is important to me that we are always explicit in the docs, so that there are no open questions about basic usage of a module.
E.g. just look at the Child Process module:
it is require('child_process') and not e.g. require('childprocess') (w/o '_')
When we now look at the Query String module, it wouldn't be obvious how to require it:
is it require('query_string') or require('querystring')?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests

4 participants