Skip to content

Commit

Permalink
docs: normalize code block formatting (#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
roryokane committed May 6, 2020
1 parent 95829d4 commit 90d5de5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -44,7 +44,7 @@ npm i yargs@next

### Simple Example

````javascript
```javascript
#!/usr/bin/env node
const {argv} = require('yargs')

Expand All @@ -53,7 +53,7 @@ if (argv.ships > 3 && argv.distance < 53.5) {
} else {
console.log('Retreat from the xupptumblers!')
}
````
```

```bash
$ ./plunder.js --ships=4 --distance=22
Expand Down
28 changes: 14 additions & 14 deletions docs/api.md
Expand Up @@ -4,21 +4,21 @@ API
You can run Yargs without any configuration, and it will do its
best to parse `process.argv`:

````javascript
```javascript
require('yargs').argv
````
```

You can also pass in the `process.argv` yourself:

````javascript
```javascript
require('yargs')([ '-x', '1', '-y', '2' ]).argv
````
```

or use `.parse()` to do the same thing:

````javascript
```javascript
require('yargs').parse([ '-x', '1', '-y', '2' ])
````
```

Calling `.parse()` with no arguments is equivalent to calling `yargs.argv`:

Expand Down Expand Up @@ -1064,7 +1064,7 @@ customization, like `.alias()`, `.demandOption()` etc. for that option.

For example:

````javascript
```javascript
var argv = require('yargs')
.option('f', {
alias: 'file',
Expand All @@ -1075,11 +1075,11 @@ var argv = require('yargs')
})
.argv
;
````
```

is the same as

````javascript
```javascript
var argv = require('yargs')
.alias('f', 'file')
.demandOption('f')
Expand All @@ -1088,11 +1088,11 @@ var argv = require('yargs')
.string('f')
.argv
;
````
```

Optionally `.options()` can take an object that maps keys to `opt` parameters.

````javascript
```javascript
var argv = require('yargs')
.options({
'f': {
Expand All @@ -1105,7 +1105,7 @@ var argv = require('yargs')
})
.argv
;
````
```

Valid `opt` keys include:

Expand Down Expand Up @@ -1378,7 +1378,7 @@ message is output after the error message.

line_count.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Count the lines in a file.\nUsage: $0 -f <file>')
Expand All @@ -1391,7 +1391,7 @@ var argv = require('yargs')
.argv;

// etc.
````
```

***

Expand Down
48 changes: 24 additions & 24 deletions docs/examples.md
Expand Up @@ -9,7 +9,7 @@ With yargs, the options be just a hash!

plunder.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs').argv;

Expand All @@ -18,7 +18,7 @@ if (argv.ships > 3 && argv.distance < 53.5) {
} else {
console.log('Retreat from the xupptumblers!');
}
````
```

***

Expand All @@ -33,11 +33,11 @@ But don't walk the plank just yet! There be more! You can do short options:

short.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
````
```

***

Expand All @@ -49,7 +49,7 @@ And booleans, both long, short, and even grouped:

bool.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs').argv;

Expand All @@ -59,7 +59,7 @@ if (argv.s) {
console.log(
(argv.fr ? 'couac' : 'squawk') + (argv.p ? '!' : '')
);
````
```

***

Expand All @@ -77,12 +77,12 @@ And non-hyphenated options too! Just use `argv._`!

nonopt.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
````
```

***

Expand All @@ -99,7 +99,7 @@ Yargs even counts your booleans!

count.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.count('verbose')
Expand All @@ -115,7 +115,7 @@ function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments);
WARN("Showing only important stuff");
INFO("Showing semi-important stuff too");
DEBUG("Extra chatty mode");
````
```

***
$ node count.js
Expand All @@ -140,15 +140,15 @@ Tell users how to use your options and make demands.

area.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Usage: $0 -w [num] -h [num]')
.demandOption(['w','h'])
.argv;

console.log("The area is:", argv.w * argv.h);
````
```

***

Expand All @@ -169,13 +169,13 @@ After your demands have been met, demand more! Ask for non-hyphenated arguments!

demand_count.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.demandCommand(2)
.argv;
console.dir(argv);
````
```

***

Expand All @@ -194,15 +194,15 @@ EVEN MORE SHIVER ME TIMBERS!

default_singles.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.default('x', 10)
.default('y', 10)
.argv
;
console.log(argv.x + argv.y);
````
```

***

Expand All @@ -211,14 +211,14 @@ console.log(argv.x + argv.y);

default_hash.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.default({ x : 10, y : 10 })
.argv
;
console.log(argv.x + argv.y);
````
```

***

Expand All @@ -230,15 +230,15 @@ And if you really want to get all descriptive about it...

boolean_single.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.boolean(['r','v'])
.argv
;
console.dir([ argv.r, argv.v ]);
console.dir(argv._);
````
```

***

Expand All @@ -249,15 +249,15 @@ console.dir(argv._);

boolean_double.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.boolean(['x','y','z'])
.argv
;
console.dir([ argv.x, argv.y, argv.z ]);
console.dir(argv._);
````
```

***

Expand All @@ -273,7 +273,7 @@ out how to format a handy help string automatically.

line_count.js:

````javascript
```javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Usage: $0 <command> [options]')
Expand All @@ -299,7 +299,7 @@ s.on('data', function (buf) {
s.on('end', function () {
console.log(lines);
});
````
```

***
$ node line_count.js
Expand Down

0 comments on commit 90d5de5

Please sign in to comment.