Skip to content

Commit 09487b6

Browse files
authored
docs: add image_providers jsdocs (#612)
1 parent f038937 commit 09487b6

3 files changed

Lines changed: 150 additions & 125 deletions

File tree

src/image_providers/lorempicsum.ts

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import type { Faker } from '..';
22

3+
/**
4+
* Module to generate links to random images on `https://picsum.photos/`.
5+
*/
6+
// TODO ST-DDT 2022-03-11: Rename to picsum?
37
export class LoremPicsum {
48
constructor(private readonly faker: Faker) {}
59

610
/**
7-
* Search image from unsplash
11+
* Generates a new picsum image url.
812
*
9-
* @param width
10-
* @param height
11-
* @param grayscale
12-
* @param blur 1-10
13+
* @param width The width of the image. Defaults to `640`.
14+
* @param height The height of the image. Defaults to `480`.
15+
* @param grayscale Whether to return a grayscale image. Default to `false`.
16+
* @param blur The optional level of blur to apply. Supports `1` - `10`.
1317
*/
1418
image(
1519
width?: number,
@@ -21,22 +25,22 @@ export class LoremPicsum {
2125
}
2226

2327
/**
24-
* Search grayscale image from unsplash
28+
* Generates a new picsum image url.
2529
*
26-
* @param width
27-
* @param height
28-
* @param grayscale
30+
* @param width The width of the image. Defaults to `640`.
31+
* @param height The height of the image. Defaults to `480`.
32+
* @param grayscale Whether to return a grayscale image. Default to `false`.
2933
*/
3034
imageGrayscale(width?: number, height?: number, grayscale?: boolean): string {
3135
return this.imageUrl(width, height, grayscale);
3236
}
3337

3438
/**
35-
* Search blurred image from unsplash
39+
* Generates a new picsum image url.
3640
*
37-
* @param width
38-
* @param height
39-
* @param blur 1-10
41+
* @param width The width of the image. Defaults to `640`.
42+
* @param height The height of the image. Defaults to `480`.
43+
* @param blur The optional level of blur to apply. Supports `1` - `10`.
4044
*/
4145
imageBlurred(
4246
width?: number,
@@ -47,13 +51,13 @@ export class LoremPicsum {
4751
}
4852

4953
/**
50-
* Search same random image from unsplash, based on a seed
54+
* Generates a new picsum image url.
5155
*
52-
* @param width
53-
* @param height
54-
* @param grayscale
55-
* @param blur 1-10
56-
* @param seed
56+
* @param width The width of the image. Defaults to `640`.
57+
* @param height The height of the image. Defaults to `480`.
58+
* @param grayscale Whether to return a grayscale image. Default to `false`.
59+
* @param blur The optional level of blur to apply. Supports `1` - `10`.
60+
* @param seed The optional seed to use.
5761
*/
5862
imageRandomSeeded(
5963
width?: number,
@@ -62,24 +66,30 @@ export class LoremPicsum {
6266
blur?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
6367
seed?: string
6468
): string {
69+
// TODO ST-DDT 2022-03-11: This method does the same as image url, maybe generate a seed, if it is missig?
6570
return this.imageUrl(width, height, grayscale, blur, seed);
6671
}
6772

6873
/**
69-
* avatar
74+
* Returns a random avatar url.
75+
*
76+
* @example
77+
* faker.internet.avatar()
78+
* // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
7079
*/
80+
// TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with lorempicsum.
7181
avatar(): string {
7282
return this.faker.internet.avatar();
7383
}
7484

7585
/**
76-
* imageUrl
86+
* Generates a new picsum image url.
7787
*
78-
* @param width
79-
* @param height
80-
* @param grayscale
81-
* @param blur 1-10
82-
* @param seed
88+
* @param width The width of the image. Defaults to `640`.
89+
* @param height The height of the image. Defaults to `480`.
90+
* @param grayscale Whether to return a grayscale image. Default to `false`.
91+
* @param blur The optional level of blur to apply. Supports `1` - `10`.
92+
* @param seed The optional seed to use.
8393
*/
8494
imageUrl(
8595
width?: number,

src/image_providers/lorempixel.ts

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import type { Faker } from '..';
22

3+
/**
4+
* Module to generate links to random images on `https://lorempixel.com/`.
5+
*/
36
export class Lorempixel {
47
constructor(private readonly faker: Faker) {}
58

69
/**
7-
* image
10+
* Generates a new lorempixel image url for a random supported category.
811
*
9-
* @param width
10-
* @param height
11-
* @param randomize
12+
* @param width The width of the image. Defaults to `640`.
13+
* @param height The height of the image. Defaults to `480`.
14+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
1215
*/
1316
image(width?: number, height?: number, randomize?: boolean): string {
1417
const categories = [
@@ -34,19 +37,24 @@ export class Lorempixel {
3437
}
3538

3639
/**
37-
* avatar
40+
* Returns a random avatar url.
41+
*
42+
* @example
43+
* faker.internet.avatar()
44+
* // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
3845
*/
46+
// TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with lorempixel.
3947
avatar(): string {
4048
return this.faker.internet.avatar();
4149
}
4250

4351
/**
44-
* imageUrl
52+
* Generates a new lorempixel image url.
4553
*
46-
* @param width
47-
* @param height
48-
* @param category
49-
* @param randomize
54+
* @param width The width of the image. Defaults to `640`.
55+
* @param height The height of the image. Defaults to `480`.
56+
* @param category The category of the image to generate.
57+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
5058
*/
5159
imageUrl(
5260
width?: number,
@@ -70,11 +78,11 @@ export class Lorempixel {
7078
}
7179

7280
/**
73-
* abstract
81+
* Generates a new lorempixel image url using the "abstract" category.
7482
*
75-
* @param width
76-
* @param height
77-
* @param randomize
83+
* @param width The width of the image. Defaults to `640`.
84+
* @param height The height of the image. Defaults to `480`.
85+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
7886
*/
7987
abstract(width?: number, height?: number, randomize?: boolean): string {
8088
return this.faker.image.lorempixel.imageUrl(
@@ -86,11 +94,11 @@ export class Lorempixel {
8694
}
8795

8896
/**
89-
* animals
97+
* Generates a new lorempixel image url using the "animals" category.
9098
*
91-
* @param width
92-
* @param height
93-
* @param randomize
99+
* @param width The width of the image. Defaults to `640`.
100+
* @param height The height of the image. Defaults to `480`.
101+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
94102
*/
95103
animals(width?: number, height?: number, randomize?: boolean): string {
96104
return this.faker.image.lorempixel.imageUrl(
@@ -102,11 +110,11 @@ export class Lorempixel {
102110
}
103111

104112
/**
105-
* business
113+
* Generates a new lorempixel image url using the "business" category.
106114
*
107-
* @param width
108-
* @param height
109-
* @param randomize
115+
* @param width The width of the image. Defaults to `640`.
116+
* @param height The height of the image. Defaults to `480`.
117+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
110118
*/
111119
business(width?: number, height?: number, randomize?: boolean): string {
112120
return this.faker.image.lorempixel.imageUrl(
@@ -118,11 +126,11 @@ export class Lorempixel {
118126
}
119127

120128
/**
121-
* cats
129+
* Generates a new lorempixel image url using the "cats" category.
122130
*
123-
* @param width
124-
* @param height
125-
* @param randomize
131+
* @param width The width of the image. Defaults to `640`.
132+
* @param height The height of the image. Defaults to `480`.
133+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
126134
*/
127135
cats(width?: number, height?: number, randomize?: boolean): string {
128136
return this.faker.image.lorempixel.imageUrl(
@@ -134,11 +142,11 @@ export class Lorempixel {
134142
}
135143

136144
/**
137-
* city
145+
* Generates a new lorempixel image url using the "city" category.
138146
*
139-
* @param width
140-
* @param height
141-
* @param randomize
147+
* @param width The width of the image. Defaults to `640`.
148+
* @param height The height of the image. Defaults to `480`.
149+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
142150
*/
143151
city(width?: number, height?: number, randomize?: boolean): string {
144152
return this.faker.image.lorempixel.imageUrl(
@@ -150,11 +158,11 @@ export class Lorempixel {
150158
}
151159

152160
/**
153-
* food
161+
* Generates a new lorempixel image url using the "food" category.
154162
*
155-
* @param width
156-
* @param height
157-
* @param randomize
163+
* @param width The width of the image. Defaults to `640`.
164+
* @param height The height of the image. Defaults to `480`.
165+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
158166
*/
159167
food(width?: number, height?: number, randomize?: boolean): string {
160168
return this.faker.image.lorempixel.imageUrl(
@@ -166,11 +174,11 @@ export class Lorempixel {
166174
}
167175

168176
/**
169-
* nightlife
177+
* Generates a new lorempixel image url using the "nightlife" category.
170178
*
171-
* @param width
172-
* @param height
173-
* @param randomize
179+
* @param width The width of the image. Defaults to `640`.
180+
* @param height The height of the image. Defaults to `480`.
181+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
174182
*/
175183
nightlife(width?: number, height?: number, randomize?: boolean): string {
176184
return this.faker.image.lorempixel.imageUrl(
@@ -182,11 +190,11 @@ export class Lorempixel {
182190
}
183191

184192
/**
185-
* fashion
193+
* Generates a new lorempixel image url using the "fashion" category.
186194
*
187-
* @param width
188-
* @param height
189-
* @param randomize
195+
* @param width The width of the image. Defaults to `640`.
196+
* @param height The height of the image. Defaults to `480`.
197+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
190198
*/
191199
fashion(width?: number, height?: number, randomize?: boolean): string {
192200
return this.faker.image.lorempixel.imageUrl(
@@ -198,11 +206,11 @@ export class Lorempixel {
198206
}
199207

200208
/**
201-
* people
209+
* Generates a new lorempixel image url using the "people" category.
202210
*
203-
* @param width
204-
* @param height
205-
* @param randomize
211+
* @param width The width of the image. Defaults to `640`.
212+
* @param height The height of the image. Defaults to `480`.
213+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
206214
*/
207215
people(width?: number, height?: number, randomize?: boolean): string {
208216
return this.faker.image.lorempixel.imageUrl(
@@ -214,11 +222,11 @@ export class Lorempixel {
214222
}
215223

216224
/**
217-
* nature
225+
* Generates a new lorempixel image url using the "nature" category.
218226
*
219-
* @param width
220-
* @param height
221-
* @param randomize
227+
* @param width The width of the image. Defaults to `640`.
228+
* @param height The height of the image. Defaults to `480`.
229+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
222230
*/
223231
nature(width?: number, height?: number, randomize?: boolean): string {
224232
return this.faker.image.lorempixel.imageUrl(
@@ -230,11 +238,11 @@ export class Lorempixel {
230238
}
231239

232240
/**
233-
* sports
241+
* Generates a new lorempixel image url using the "sports" category.
234242
*
235-
* @param width
236-
* @param height
237-
* @param randomize
243+
* @param width The width of the image. Defaults to `640`.
244+
* @param height The height of the image. Defaults to `480`.
245+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
238246
*/
239247
sports(width?: number, height?: number, randomize?: boolean): string {
240248
return this.faker.image.lorempixel.imageUrl(
@@ -246,11 +254,11 @@ export class Lorempixel {
246254
}
247255

248256
/**
249-
* technics
257+
* Generates a new lorempixel image url using the "technics" category.
250258
*
251-
* @param width
252-
* @param height
253-
* @param randomize
259+
* @param width The width of the image. Defaults to `640`.
260+
* @param height The height of the image. Defaults to `480`.
261+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
254262
*/
255263
technics(width?: number, height?: number, randomize?: boolean): string {
256264
return this.faker.image.lorempixel.imageUrl(
@@ -262,11 +270,11 @@ export class Lorempixel {
262270
}
263271

264272
/**
265-
* transport
273+
* Generates a new lorempixel image url using the "transport" category.
266274
*
267-
* @param width
268-
* @param height
269-
* @param randomize
275+
* @param width The width of the image. Defaults to `640`.
276+
* @param height The height of the image. Defaults to `480`.
277+
* @param randomize Whether to append a seed to the url. Defaults to `false`.
270278
*/
271279
transport(width?: number, height?: number, randomize?: boolean): string {
272280
return this.faker.image.lorempixel.imageUrl(

0 commit comments

Comments
 (0)