Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9eb0ef4

Browse filesBrowse files
committed
doc: fix invalid path doc comments
The format of certain code comments in the `path` documentation results in the code blocks being invalid. I also find it confusing at least as formatted on the website. This change is intended to improve those comments. PR-URL: #5670 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent a97dfa0 commit 9eb0ef4
Copy full SHA for 9eb0ef4

File tree

Expand file treeCollapse file tree

1 file changed

+36
-56
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-56
lines changed
Open diff view settings
Collapse file

‎doc/api/path.markdown‎

Copy file name to clipboardExpand all lines: doc/api/path.markdown
+36-56Lines changed: 36 additions & 56 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ Example:
1616

1717
```js
1818
path.basename('/foo/bar/baz/asdf/quux.html')
19-
// returns
20-
'quux.html'
19+
// returns 'quux.html'
2120

2221
path.basename('/foo/bar/baz/asdf/quux.html', '.html')
23-
// returns
24-
'quux'
22+
// returns 'quux'
2523
```
2624

2725
## path.delimiter
@@ -35,8 +33,7 @@ console.log(process.env.PATH)
3533
// '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
3634

3735
process.env.PATH.split(path.delimiter)
38-
// returns
39-
['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
36+
// returns ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
4037
```
4138

4239
An example on Windows:
@@ -46,8 +43,7 @@ console.log(process.env.PATH)
4643
// 'C:\Windows\system32;C:\Windows;C:\Program Files\node\'
4744

4845
process.env.PATH.split(path.delimiter)
49-
// returns
50-
['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
46+
// returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
5147
```
5248

5349
## path.dirname(p)
@@ -58,8 +54,7 @@ Example:
5854

5955
```js
6056
path.dirname('/foo/bar/baz/asdf/quux')
61-
// returns
62-
'/foo/bar/baz/asdf'
57+
// returns '/foo/bar/baz/asdf'
6358
```
6459

6560
## path.extname(p)
@@ -71,24 +66,19 @@ an empty string. Examples:
7166

7267
```js
7368
path.extname('index.html')
74-
// returns
75-
'.html'
69+
// returns '.html'
7670

7771
path.extname('index.coffee.md')
78-
// returns
79-
'.md'
72+
// returns '.md'
8073

8174
path.extname('index.')
82-
// returns
83-
'.'
75+
// returns '.'
8476

8577
path.extname('index')
86-
// returns
87-
''
78+
// returns ''
8879

8980
path.extname('.index')
90-
// returns
91-
''
81+
// returns ''
9282
```
9383

9484
## path.format(pathObject)
@@ -117,9 +107,8 @@ path.format({
117107
base : "file.txt",
118108
ext : ".txt",
119109
name : "file"
120-
})
121-
// returns
122-
'/home/user/dir/file.txt'
110+
});
111+
// returns '/home/user/dir/file.txt'
123112

124113
// `root` will be used if `dir` is not specified and `name` + `ext` will be used
125114
// if `base` is not specified
@@ -128,8 +117,7 @@ path.format({
128117
ext : ".txt",
129118
name : "file"
130119
})
131-
// returns
132-
'/file.txt'
120+
// returns '/file.txt'
133121
```
134122

135123
## path.isAbsolute(path)
@@ -170,8 +158,7 @@ Example:
170158

171159
```js
172160
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
173-
// returns
174-
'/foo/bar/baz/asdf'
161+
// returns '/foo/bar/baz/asdf'
175162

176163
path.join('foo', {}, 'bar')
177164
// throws exception
@@ -195,8 +182,7 @@ Example:
195182

196183
```js
197184
path.normalize('/foo/bar//baz/asdf/quux/..')
198-
// returns
199-
'/foo/bar/baz/asdf'
185+
// returns '/foo/bar/baz/asdf'
200186
```
201187

202188
*Note:* If the path string passed as argument is a zero-length string then `'.'`
@@ -211,27 +197,27 @@ An example on \*nix:
211197
```js
212198
path.parse('/home/user/dir/file.txt')
213199
// returns
214-
{
215-
root : "/",
216-
dir : "/home/user/dir",
217-
base : "file.txt",
218-
ext : ".txt",
219-
name : "file"
220-
}
200+
// {
201+
// root : "/",
202+
// dir : "/home/user/dir",
203+
// base : "file.txt",
204+
// ext : ".txt",
205+
// name : "file"
206+
// }
221207
```
222208

223209
An example on Windows:
224210

225211
```js
226212
path.parse('C:\\path\\dir\\index.html')
227213
// returns
228-
{
229-
root : "C:\\",
230-
dir : "C:\\path\\dir",
231-
base : "index.html",
232-
ext : ".html",
233-
name : "index"
234-
}
214+
// {
215+
// root : "C:\\",
216+
// dir : "C:\\path\\dir",
217+
// base : "index.html",
218+
// ext : ".html",
219+
// name : "index"
220+
// }
235221
```
236222

237223
## path.posix
@@ -255,12 +241,10 @@ Examples:
255241

256242
```js
257243
path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
258-
// returns
259-
'..\\..\\impl\\bbb'
244+
// returns '..\\..\\impl\\bbb'
260245

261246
path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
262-
// returns
263-
'../../impl/bbb'
247+
// returns '../../impl/bbb'
264248
```
265249

266250
*Note:* If the arguments to `relative` have zero-length strings then the current
@@ -300,16 +284,14 @@ Examples:
300284

301285
```js
302286
path.resolve('/foo/bar', './baz')
303-
// returns
304-
'/foo/bar/baz'
287+
// returns '/foo/bar/baz'
305288

306289
path.resolve('/foo/bar', '/tmp/file/')
307-
// returns
308-
'/tmp/file'
290+
// returns '/tmp/file'
309291

310292
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
311293
// if currently in /home/myself/node, it returns
312-
'/home/myself/node/wwwroot/static_files/gif/image.gif'
294+
// '/home/myself/node/wwwroot/static_files/gif/image.gif'
313295
```
314296

315297
*Note:* If the arguments to `resolve` have zero-length strings then the current
@@ -323,16 +305,14 @@ An example on \*nix:
323305

324306
```js
325307
'foo/bar/baz'.split(path.sep)
326-
// returns
327-
['foo', 'bar', 'baz']
308+
// returns ['foo', 'bar', 'baz']
328309
```
329310

330311
An example on Windows:
331312

332313
```js
333314
'foo\\bar\\baz'.split(path.sep)
334-
// returns
335-
['foo', 'bar', 'baz']
315+
// returns ['foo', 'bar', 'baz']
336316
```
337317

338318
## path.win32

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.