Skip to content

Commit fc6ad61

Browse files
ST-DDTdemipel8
authored andcommitted
docs: add examples to animal jsdocs (faker-js#417)
1 parent 21327a7 commit fc6ad61

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/animal.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { Faker } from '.';
22

3+
/**
4+
* Module to generate animal related entries.
5+
*/
36
export class Animal {
47
constructor(private readonly faker: Faker) {
58
// Bind `this` so namespaced is working correctly
@@ -14,6 +17,8 @@ export class Animal {
1417
/**
1518
* Returns a random dog breed.
1619
*
20+
* @example
21+
* faker.animal.dog() // 'Irish Water Spaniel'
1722
*/
1823
dog(): string {
1924
return this.faker.random.arrayElement(this.faker.definitions.animal.dog);
@@ -22,6 +27,8 @@ export class Animal {
2227
/**
2328
* Returns a random cat breed.
2429
*
30+
* @example
31+
* faker.animal.cat() // 'Singapura'
2532
*/
2633
cat(): string {
2734
return this.faker.random.arrayElement(this.faker.definitions.animal.cat);
@@ -30,6 +37,8 @@ export class Animal {
3037
/**
3138
* Returns a random snake species.
3239
*
40+
* @example
41+
* faker.animal.snake() // 'Eyelash viper'
3342
*/
3443
snake(): string {
3544
return this.faker.random.arrayElement(this.faker.definitions.animal.snake);
@@ -38,6 +47,8 @@ export class Animal {
3847
/**
3948
* Returns a random bear species.
4049
*
50+
* @example
51+
* faker.animal.bear() // 'Asian black bear'
4152
*/
4253
bear(): string {
4354
return this.faker.random.arrayElement(this.faker.definitions.animal.bear);
@@ -46,6 +57,8 @@ export class Animal {
4657
/**
4758
* Returns a random lion species.
4859
*
60+
* @example
61+
* faker.animal.lion() // 'Northeast Congo Lion'
4962
*/
5063
lion(): string {
5164
return this.faker.random.arrayElement(this.faker.definitions.animal.lion);
@@ -54,7 +67,8 @@ export class Animal {
5467
/**
5568
* Returns a random cetacean species.
5669
*
57-
* @method faker.animal.cetacean
70+
* @example
71+
* faker.animal.cetacean() // 'Spinner Dolphin'
5872
*/
5973
cetacean(): string {
6074
return this.faker.random.arrayElement(
@@ -65,6 +79,8 @@ export class Animal {
6579
/**
6680
* Returns a random horse breed.
6781
*
82+
* @example
83+
* faker.animal.horse() // 'Swedish Warmblood'
6884
*/
6985
horse(): string {
7086
return this.faker.random.arrayElement(this.faker.definitions.animal.horse);
@@ -73,6 +89,8 @@ export class Animal {
7389
/**
7490
* Returns a random bird species.
7591
*
92+
* @example
93+
* faker.animal.bird() // 'Buller's Shearwater'
7694
*/
7795
bird(): string {
7896
return this.faker.random.arrayElement(this.faker.definitions.animal.bird);
@@ -81,6 +99,8 @@ export class Animal {
8199
/**
82100
* Returns a random cow species.
83101
*
102+
* @example
103+
* faker.animal.cow() // 'Brava'
84104
*/
85105
cow(): string {
86106
return this.faker.random.arrayElement(this.faker.definitions.animal.cow);
@@ -89,6 +109,8 @@ export class Animal {
89109
/**
90110
* Returns a random fish species.
91111
*
112+
* @example
113+
* faker.animal.fish() // 'Mandarin fish'
92114
*/
93115
fish(): string {
94116
return this.faker.random.arrayElement(this.faker.definitions.animal.fish);
@@ -97,6 +119,8 @@ export class Animal {
97119
/**
98120
* Returns a random crocodilian species.
99121
*
122+
* @example
123+
* faker.animal.crocodilia() // 'Philippine Crocodile'
100124
*/
101125
crocodilia(): string {
102126
return this.faker.random.arrayElement(
@@ -107,14 +131,18 @@ export class Animal {
107131
/**
108132
* Returns a random insect species.
109133
*
134+
* @example
135+
* faker.animal.insect() // 'Pyramid ant'
110136
*/
111137
insect(): string {
112138
return this.faker.random.arrayElement(this.faker.definitions.animal.insect);
113139
}
114140

115141
/**
116-
* Returns a random rabbit species
142+
* Returns a random rabbit species.
117143
*
144+
* @example
145+
* faker.animal.rabbit() // 'Florida White'
118146
*/
119147
rabbit(): string {
120148
return this.faker.random.arrayElement(this.faker.definitions.animal.rabbit);
@@ -123,6 +151,8 @@ export class Animal {
123151
/**
124152
* Returns a random animal type.
125153
*
154+
* @example
155+
* faker.animal.type() // 'crocodilia'
126156
*/
127157
type(): string {
128158
return this.faker.random.arrayElement(this.faker.definitions.animal.type);

0 commit comments

Comments
 (0)