Skip to content

Commit 75f723c

Browse files
TrottFishrock123
authored andcommitted
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]> Conflicts: doc/api/path.markdown
1 parent 724b87d commit 75f723c

File tree

1 file changed

+35
-54
lines changed

1 file changed

+35
-54
lines changed

doc/api/path.markdown

+35-54
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

125114
## path.isAbsolute(path)
@@ -160,8 +149,7 @@ Example:
160149

161150
```js
162151
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
163-
// returns
164-
'/foo/bar/baz/asdf'
152+
// returns '/foo/bar/baz/asdf'
165153

166154
path.join('foo', {}, 'bar')
167155
// throws exception
@@ -185,8 +173,7 @@ Example:
185173

186174
```js
187175
path.normalize('/foo/bar//baz/asdf/quux/..')
188-
// returns
189-
'/foo/bar/baz/asdf'
176+
// returns '/foo/bar/baz/asdf'
190177
```
191178

192179
*Note:* If the path string passed as argument is a zero-length string then `'.'`
@@ -201,27 +188,27 @@ An example on \*nix:
201188
```js
202189
path.parse('/home/user/dir/file.txt')
203190
// returns
204-
{
205-
root : "/",
206-
dir : "/home/user/dir",
207-
base : "file.txt",
208-
ext : ".txt",
209-
name : "file"
210-
}
191+
// {
192+
// root : "/",
193+
// dir : "/home/user/dir",
194+
// base : "file.txt",
195+
// ext : ".txt",
196+
// name : "file"
197+
// }
211198
```
212199

213200
An example on Windows:
214201

215202
```js
216203
path.parse('C:\\path\\dir\\index.html')
217204
// returns
218-
{
219-
root : "C:\\",
220-
dir : "C:\\path\\dir",
221-
base : "index.html",
222-
ext : ".html",
223-
name : "index"
224-
}
205+
// {
206+
// root : "C:\\",
207+
// dir : "C:\\path\\dir",
208+
// base : "index.html",
209+
// ext : ".html",
210+
// name : "index"
211+
// }
225212
```
226213

227214
## path.posix
@@ -245,12 +232,10 @@ Examples:
245232

246233
```js
247234
path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
248-
// returns
249-
'..\\..\\impl\\bbb'
235+
// returns '..\\..\\impl\\bbb'
250236

251237
path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
252-
// returns
253-
'../../impl/bbb'
238+
// returns '../../impl/bbb'
254239
```
255240

256241
*Note:* If the arguments to `relative` have zero-length strings then the current
@@ -290,16 +275,14 @@ Examples:
290275

291276
```js
292277
path.resolve('/foo/bar', './baz')
293-
// returns
294-
'/foo/bar/baz'
278+
// returns '/foo/bar/baz'
295279

296280
path.resolve('/foo/bar', '/tmp/file/')
297-
// returns
298-
'/tmp/file'
281+
// returns '/tmp/file'
299282

300283
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
301284
// if currently in /home/myself/node, it returns
302-
'/home/myself/node/wwwroot/static_files/gif/image.gif'
285+
// '/home/myself/node/wwwroot/static_files/gif/image.gif'
303286
```
304287

305288
*Note:* If the arguments to `resolve` have zero-length strings then the current
@@ -313,16 +296,14 @@ An example on \*nix:
313296

314297
```js
315298
'foo/bar/baz'.split(path.sep)
316-
// returns
317-
['foo', 'bar', 'baz']
299+
// returns ['foo', 'bar', 'baz']
318300
```
319301

320302
An example on Windows:
321303

322304
```js
323305
'foo\\bar\\baz'.split(path.sep)
324-
// returns
325-
['foo', 'bar', 'baz']
306+
// returns ['foo', 'bar', 'baz']
326307
```
327308

328309
## path.win32

0 commit comments

Comments
 (0)