Skip to content

Commit 3fcd0be

Browse files
committed
Truncate snippet options during docs generation
1 parent be4897d commit 3fcd0be

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ fetch('$1'$2).then(res => res.json())
816816
<td>
817817

818818
```javascript
819-
const ${1|data,{ data }|} = await fetch('$2'$3).then(res => res.json())
819+
const ${1|data,...|} = await fetch('$2'$3).then(res => res.json())
820820
```
821821

822822
</td>
@@ -2276,7 +2276,7 @@ Array.isArray($0)
22762276
<td>
22772277
22782278
```javascript
2279-
typeof ${1:value} === '${2|undefined,string,number,object,function,boolean,symbol,bigint|}'
2279+
typeof ${1:value} === '${2|undefined,...|}'
22802280
```
22812281
22822282
</td>
@@ -2430,7 +2430,7 @@ Internationalization API
24302430
<td>
24312431
24322432
```javascript
2433-
new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}'$3).format($2);
2433+
new Intl.NumberFormat('${1|en-US,...|}'$3).format($2);
24342434
```
24352435
24362436
</td>
@@ -2442,8 +2442,8 @@ new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP
24422442
<td>
24432443
24442444
```javascript
2445-
new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}', {
2446-
style: '${3|decimal,currency,percent,unit|}',$4
2445+
new Intl.NumberFormat('${1|en-US,...|}', {
2446+
style: '${3|decimal,...|}',$4
24472447
}).format($2);
24482448
```
24492449
@@ -2456,9 +2456,9 @@ new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP
24562456
<td>
24572457
24582458
```javascript
2459-
new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}', {
2459+
new Intl.NumberFormat('${1|en-US,...|}', {
24602460
style: 'currency',
2461-
currency: '${3|USD,EUR,GBP,AUD,CAD,JPY|}',$4
2461+
currency: '${3|USD,...|}',$4
24622462
}).format($2);
24632463
```
24642464
@@ -2471,7 +2471,7 @@ new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP
24712471
<td>
24722472
24732473
```javascript
2474-
new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}', {
2474+
new Intl.NumberFormat('${1|en-US,...|}', {
24752475
style: 'percent',$3
24762476
}).format($2);
24772477
```
@@ -2485,10 +2485,10 @@ new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP
24852485
<td>
24862486
24872487
```javascript
2488-
new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}', {
2488+
new Intl.NumberFormat('${1|en-US,...|}', {
24892489
style: 'unit',
2490-
unit: '${3|acceleration-g-force,acceleration-meter-per-square-second,angle-arc-minute,angle-arc-second,angle-degree,angle-radian,angle-revolution,area-acre,area-hectare,area-square-centimeter,area-square-foot,area-square-inch,area-square-kilometer,area-square-meter,area-square-mile,area-square-yard,area-dunam,concentr-karat,concentr-milligram-ofglucose-per-deciliter,concentr-millimole-per-liter,concentr-percent,concentr-permille,concentr-permyriad,concentr-permillion,concentr-mole,concentr-item,concentr-portion,concentr-ofglucose,consumption-liter-per-100-kilometer,consumption-liter-per-kilometer,consumption-mile-per-gallon,consumption-mile-per-gallon-imperial,digital-bit,digital-byte,digital-gigabit,digital-gigabyte,digital-kilobit,digital-kilobyte,digital-megabit,digital-megabyte,digital-petabyte,digital-terabit,digital-terabyte,duration-century,duration-decade,duration-day,duration-day-person,duration-hour,duration-microsecond,duration-millisecond,duration-minute,duration-month,duration-month-person,duration-nanosecond,duration-quarter,duration-second,duration-week,duration-week-person,duration-year,duration-year-person,electric-ampere,electric-milliampere,electric-ohm,electric-volt,energy-calorie,energy-foodcalorie,energy-joule,energy-kilocalorie,energy-kilojoule,energy-kilowatt-hour,energy-electronvolt,energy-therm-us,energy-british-thermal-unit,force-pound-force,force-newton,force-kilowatt-hour-per-100-kilometer,frequency-gigahertz,frequency-hertz,frequency-kilohertz,frequency-megahertz,graphics-dot,graphics-dot-per-centimeter,graphics-dot-per-inch,graphics-em,graphics-megapixel,graphics-pixel,graphics-pixel-per-centimeter,graphics-pixel-per-inch,length-100-kilometer,length-astronomical-unit,length-centimeter,length-decimeter,length-fathom,length-foot,length-furlong,length-inch,length-kilometer,length-light-year,length-meter,length-micrometer,length-mile,length-mile-scandinavian,length-millimeter,length-nanometer,length-nautical-mile,length-parsec,length-picometer,length-point,length-yard,length-earth-radius,length-solar-radius,light-candela,light-lumen,light-lux,light-solar-luminosity,mass-carat,mass-grain,mass-gram,mass-kilogram,mass-tonne,mass-microgram,mass-milligram,mass-ounce,mass-ounce-troy,mass-pound,mass-stone,mass-ton,mass-dalton,mass-earth-mass,mass-solar-mass,power-gigawatt,power-horsepower,power-kilowatt,power-megawatt,power-milliwatt,power-watt,pressure-atmosphere,pressure-hectopascal,pressure-inch-ofhg,pressure-bar,pressure-millibar,pressure-millimeter-ofhg,pressure-pound-force-per-square-inch,pressure-pascal,pressure-kilopascal,pressure-megapascal,pressure-ofhg,speed-kilometer-per-hour,speed-knot,speed-meter-per-second,speed-mile-per-hour,temperature-celsius,temperature-fahrenheit,temperature-generic,temperature-kelvin,torque-pound-force-foot,torque-newton-meter,volume-acre-foot,volume-bushel,volume-centiliter,volume-cubic-centimeter,volume-cubic-foot,volume-cubic-inch,volume-cubic-kilometer,volume-cubic-meter,volume-cubic-mile,volume-cubic-yard,volume-cup,volume-cup-metric,volume-deciliter,volume-dessert-spoon,volume-dessert-spoon-imperial,volume-drop,volume-dram,volume-jigger,volume-pinch,volume-quart-imperial,volume-fluid-ounce,volume-fluid-ounce-imperial,volume-gallon,volume-gallon-imperial,volume-hectoliter,volume-liter,volume-megaliter,volume-milliliter,volume-pint,volume-pint-metric,volume-quart,volume-tablespoon,volume-teaspoon,volume-barrel|}',
2491-
unitDisplay: '${4|long,short,narrow|}',$0
2490+
unit: '${3|acceleration-g-force,...|}',
2491+
unitDisplay: '${4|long,...|}',$0
24922492
}).format($2);
24932493
```
24942494
@@ -2501,7 +2501,7 @@ new Intl.NumberFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP
25012501
<td>
25022502
25032503
```javascript
2504-
new Intl.DateTimeFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}'$3).format($2);
2504+
new Intl.DateTimeFormat('${1|en-US,...|}'$3).format($2);
25052505
```
25062506
25072507
</td>
@@ -2513,7 +2513,7 @@ new Intl.DateTimeFormat('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-
25132513
<td>
25142514
25152515
```javascript
2516-
new Intl.DateTimeFormat ('${1|en-US,en-GB,en-CA,de-DE,fr-FR,es-ES,zh-CN,ru-RU,ja-JP|}', {
2516+
new Intl.DateTimeFormat ('${1|en-US,...|}', {
25172517
dateStyle: '$3',$0
25182518
}).format($2);
25192519
```
@@ -2586,7 +2586,7 @@ $1.at(${2:0})
25862586
<td>
25872587
25882588
```javascript
2589-
parseInt($1, ${2|10,2,8,16|})
2589+
parseInt($1, ${2|10,...|})
25902590
```
25912591
25922592
</td>
@@ -2622,7 +2622,7 @@ parseFloat($1)
26222622
<td>
26232623
26242624
```javascript
2625-
throw new ${1|Error,TypeError,RangeError|}($0);
2625+
throw new ${1|Error,...|}($0);
26262626
```
26272627
26282628
</td>

src/docs-gen/snippets.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ type SnippetRow = {
1818
body: string | string[];
1919
};
2020

21+
const truncateOptions = (str: string) => {
22+
const regex = /\|([^|]+)\|/g;
23+
return str.replace(regex, (_match, p1) => {
24+
const [first] = p1.split(",").map((o: string) => o.trim());
25+
return `|${first},...|`;
26+
});
27+
};
28+
2129
const snippetRow = ({ prefix, name, body }: SnippetRow) => {
2230
const cols = joinByNewLine([
2331
$colCode(prefix),
2432
$col(name),
25-
$colCodeBlock(parseMultiline(body)),
33+
$colCodeBlock(truncateOptions(parseMultiline(body))),
2634
]);
2735

2836
return $row(cols);

0 commit comments

Comments
 (0)