From bd5ae0a140934d9590f3d666b41c3c7af967faad Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 24 Dec 2019 04:36:34 -0800 Subject: [PATCH] doc,module: use code markup/markdown in headers Backport-PR-URL: https://github.com/nodejs/node/pull/31108 PR-URL: https://github.com/nodejs/node/pull/31086 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- doc/api/modules.md | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index c7c57b064da6d7..e9d1e89b4327ea 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -132,7 +132,7 @@ variable. Since the module lookups using `node_modules` folders are all relative, and based on the real path of the files making the calls to `require()`, the packages themselves can be anywhere. -## Addenda: The .mjs extension +## Addenda: The `.mjs` extension It is not possible to `require()` files that have the `.mjs` extension. Attempting to do so will throw [an error][]. The `.mjs` extension is @@ -504,7 +504,7 @@ the module rather than the global object. ## The module scope -### \_\_dirname +### `__dirname` @@ -525,7 +525,7 @@ console.log(path.dirname(__filename)); // Prints: /Users/mjr ``` -### \_\_filename +### `__filename` @@ -563,7 +563,7 @@ References to `__filename` within `b.js` will return `/Users/mjr/app/node_modules/b/b.js` while references to `__filename` within `a.js` will return `/Users/mjr/app/a.js`. -### exports +### `exports` @@ -576,7 +576,7 @@ A reference to the `module.exports` that is shorter to type. See the section about the [exports shortcut][] for details on when to use `exports` and when to use `module.exports`. -### module +### `module` @@ -589,7 +589,7 @@ A reference to the current module, see the section about the [`module` object][]. In particular, `module.exports` is used for defining what a module exports and makes available through `require()`. -### require(id) +### `require(id)` @@ -616,7 +616,7 @@ const jsonData = require('./path/filename.json'); const crypto = require('crypto'); ``` -#### require.cache +#### `require.cache` @@ -633,7 +633,7 @@ native modules and if a name matching a native module is added to the cache, no require call is going to receive the native module anymore. Use with care! -#### require.extensions +#### `require.extensions` @@ -696,7 +696,7 @@ Module { '/node_modules' ] } ``` -#### require.resolve(request\[, options\]) +#### `require.resolve(request[, options])` @@ -745,7 +745,7 @@ representing the current module. For convenience, `module.exports` is also accessible via the `exports` module-global. `module` is not actually a global but rather local to each module. -### module.children +### `module.children` @@ -754,7 +754,7 @@ added: v0.1.16 The module objects required for the first time by this one. -### module.exports +### `module.exports` @@ -808,7 +808,7 @@ const x = require('./x'); console.log(x.a); ``` -#### exports shortcut +#### `exports` shortcut @@ -855,7 +855,7 @@ function require(/* ... */) { } ``` -### module.filename +### `module.filename` @@ -864,7 +864,7 @@ added: v0.1.16 The fully resolved filename of the module. -### module.id +### `module.id` @@ -874,7 +874,7 @@ added: v0.1.16 The identifier for the module. Typically this is the fully resolved filename. -### module.loaded +### `module.loaded` @@ -884,7 +884,7 @@ added: v0.1.16 Whether or not the module is done loading, or is in the process of loading. -### module.parent +### `module.parent` @@ -893,7 +893,7 @@ added: v0.1.16 The module that first required this one. -### module.paths +### `module.paths` @@ -902,7 +902,7 @@ added: v0.4.0 The search paths for the module. -### module.require(id) +### `module.require(id)` @@ -930,7 +930,7 @@ Provides general utility methods when interacting with instances of `Module` — the `module` variable often seen in file modules. Accessed via `require('module')`. -### module.builtinModules +### `module.builtinModules` @@ -968,7 +968,7 @@ const require = createRequire(import.meta.url); const siblingModule = require('./sibling-module'); ``` -### module.createRequireFromPath(filename) +### `module.createRequireFromPath(filename)`