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: improve module.builtinModules documentation #17712

Closed
wants to merge 1 commit into from

Conversation

watson
Copy link
Member

@watson watson commented Dec 16, 2017

In this PR I've kept the original casing of the object module, but I think it might be easier to understand if we changed the entire section to use the uppercase version: Module. This have two benefits:

  1. It matches what's actually exported when requiring "module"
  2. It's easier to distinguish from the other module object that's available by default to all file modules

That change would instead look like this:

-### module.builtinModules
+### Module.builtinModules
 <!-- YAML
 added: v9.3.0
 -->

 * {string[]}

 A list of  the names of all modules provided by Node.js. Can be used to verify
 if a module is maintained by a third-party module or not.

+Note that `Module` in this context isn't the same object that's
+available by default inside file modules. To access it you need to
+require the `Module` module:
+
+```js
+const Module = require('module');
+
+const builtin = Module.builtinModules;
+```
+
Checklist
Affected core subsystem(s)
  • doc

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem. labels Dec 16, 2017
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Almost there

@@ -841,6 +841,14 @@ added: v9.3.0
A list of the names of all modules provided by Node.js. Can be used to verify
if a module is maintained by a third-party module or not.

Note that `module` in this context isn't the same object that's
available by default inside file modules. To access it you need to
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid using 'you' in the docs

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -841,6 +841,14 @@ added: v9.3.0
A list of the names of all modules provided by Node.js. Can be used to verify
if a module is maintained by a third-party module or not.

Note that `module` in this context isn't the same object that's
available by default inside file modules. To access it you need to
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of saying "available by default inside file modules" maybe say "provided by the module wrapper" and you can link to the module wrapper section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed


```js
const builtin = require('module').builtinModules;
```
Copy link
Member

Choose a reason for hiding this comment

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

That part is somewhat explained by the brief Accessed via 'require("module")' above.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, but to be honest I didn't see this my self. I needed to ask an adult for help. So I think it's worth showing an extra time. But maybe it's just me 😅

@maclover7
Copy link
Contributor

@@ -841,11 +841,19 @@ added: v9.3.0
A list of the names of all modules provided by Node.js. Can be used to verify
if a module is maintained by a third-party module or not.

Note that `module` in this context isn't the same object that's provided
Copy link
Member

@Trott Trott Dec 17, 2017

Choose a reason for hiding this comment

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

Should this note be moved to below the example for accessing builtinModules? Its placement here makes it in To access it (the next sentence) seem like it refers to the module wrapper which is kind of the opposite of the sentences intention, I think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was actually referring to the module mentioned in the headline of this section just above. But I can see that this can be a bit confusing. Not sure if moving it below the code example helps much unless I also change the code example to assign the required module to a constant like I did in the alternative code example in the PR description. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is why I like to refer to this module with an uppercase M as it makes it much easier to distinguish between the two

@@ -841,11 +841,19 @@ added: v9.3.0
A list of the names of all modules provided by Node.js. Can be used to verify
if a module is maintained by a third-party module or not.

Note that `module` in this context isn't the same object that's provided
by the [module wrapper][]. To access it require the `Module` module:
Copy link
Member

@Trott Trott Dec 17, 2017

Choose a reason for hiding this comment

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

I don't believe we typically capitalize module names so I suspect this should be the `module` module?

Copy link
Member

@Trott Trott Dec 17, 2017

Choose a reason for hiding this comment

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

Regardless, please insert a comma in the last sentence between it and require: To access it, require the...

Copy link
Member

Choose a reason for hiding this comment

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

Whoops, ignore my comment on casing (module vs. Module) since, you know, that's the whole point... 🙃 Sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comma added 👍

@Trott
Copy link
Member

Trott commented Dec 17, 2017

I left some comments/nits, but nothing that I would consider a blocking objection.

@maclover7
Copy link
Contributor

@maclover7
Copy link
Contributor

Landing...

@maclover7 maclover7 self-assigned this Dec 22, 2017
@maclover7
Copy link
Contributor

Thank you for your contribution, landed in f4ab204.
❤️ 💚 💙 💛 💜

@maclover7 maclover7 closed this Dec 22, 2017
maclover7 pushed a commit to maclover7/node that referenced this pull request Dec 22, 2017
PR-URL: nodejs#17712
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 8, 2018
PR-URL: #17712
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 9, 2018
PR-URL: #17712
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 9, 2018
PR-URL: #17712
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 10, 2018
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. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants