Skip to content

Commit b2962b8

Browse files
authored
Merge pull request #54 from cucumber/javadoc
Add javadoc on ScalaDsl
2 parents 2500b26 + 8e9ada6 commit b2962b8

File tree

2 files changed

+147
-7
lines changed

2 files changed

+147
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/master/CH
1212
### Added
1313

1414
- [Scala] `Scenario.log(String)` & `Scenario.attach(byte[], String, String)` ([#42](https://github.com/cucumber/cucumber-jvm-scala/pull/42) Gaël Jourdan-Weil)
15+
- [Doc] Added Javadoc on `ScalaDsl` methods ([#53](https://github.com/cucumber/cucumber-jvm-scala/issues/53) Gaël Jourdan-Weil)
1516

1617
### Changed
1718

scala/sources/src/main/scala/io/cucumber/scala/ScalaDsl.scala

Lines changed: 146 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,113 @@ private[scala] trait HookDsl extends BaseScalaDsl {
4040

4141
}
4242

43+
/**
44+
* Defines an before hook.
45+
*/
4346
def Before: HookBody = Before(EMPTY_TAG_EXPRESSION, DEFAULT_BEFORE_ORDER)
4447

48+
/**
49+
* Defines an before hook.
50+
*
51+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
52+
*/
4553
def Before(tagExpression: String): HookBody = Before(tagExpression, DEFAULT_BEFORE_ORDER)
4654

55+
/**
56+
* Defines an before hook.
57+
*
58+
* @param order the order in which this hook should run. Higher numbers are run first
59+
*/
4760
def Before(order: Int): HookBody = Before(EMPTY_TAG_EXPRESSION, order)
4861

49-
def Before(tagExpression: String, order: Int): HookBody = new HookBody(HookType.BEFORE, tagExpression, order)
50-
62+
/**
63+
* Defines an before hook.
64+
*
65+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
66+
* @param order the order in which this hook should run. Higher numbers are run first
67+
*/
68+
def Before(tagExpression: String, order: Int) = new HookBody(HookType.BEFORE, tagExpression, order)
69+
70+
/**
71+
* Defines an before step hook.
72+
*/
5173
def BeforeStep: HookBody = BeforeStep(EMPTY_TAG_EXPRESSION, DEFAULT_BEFORE_ORDER)
5274

75+
/**
76+
* Defines an before step hook.
77+
*
78+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
79+
*/
5380
def BeforeStep(tagExpression: String): HookBody = BeforeStep(tagExpression, DEFAULT_BEFORE_ORDER)
5481

82+
/**
83+
* Defines an before step hook.
84+
*
85+
* @param order the order in which this hook should run. Higher numbers are run first
86+
*/
5587
def BeforeStep(order: Int): HookBody = BeforeStep(EMPTY_TAG_EXPRESSION, order)
5688

57-
def BeforeStep(tagExpression: String, order: Int): HookBody = new HookBody(HookType.BEFORE_STEP, tagExpression, order)
58-
89+
/**
90+
* Defines an before step hook.
91+
*
92+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
93+
* @param order the order in which this hook should run. Higher numbers are run first
94+
*/
95+
def BeforeStep(tagExpression: String, order: Int) = new HookBody(HookType.BEFORE_STEP, tagExpression, order)
96+
97+
/**
98+
* Defines and after hook.
99+
*/
59100
def After: HookBody = After(EMPTY_TAG_EXPRESSION, DEFAULT_AFTER_ORDER)
60101

102+
/**
103+
* Defines and after hook.
104+
*
105+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
106+
*/
61107
def After(tagExpression: String): HookBody = After(tagExpression, DEFAULT_AFTER_ORDER)
62108

109+
/**
110+
* Defines and after hook.
111+
*
112+
* @param order the order in which this hook should run. Higher numbers are run first
113+
*/
63114
def After(order: Int): HookBody = After(EMPTY_TAG_EXPRESSION, order)
64115

65-
def After(tagExpression: String, order: Int): HookBody = new HookBody(HookType.AFTER, tagExpression, order)
66-
116+
/**
117+
* Defines and after hook.
118+
*
119+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
120+
* @param order the order in which this hook should run. Higher numbers are run first
121+
*/
122+
def After(tagExpression: String, order: Int) = new HookBody(HookType.AFTER, tagExpression, order)
123+
124+
/**
125+
* Defines and after step hook.
126+
*/
67127
def AfterStep: HookBody = AfterStep(EMPTY_TAG_EXPRESSION, DEFAULT_AFTER_ORDER)
68128

129+
/**
130+
* Defines and after step hook.
131+
*
132+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
133+
*/
69134
def AfterStep(tagExpression: String): HookBody = AfterStep(tagExpression, DEFAULT_AFTER_ORDER)
70135

136+
/**
137+
* Defines and after step hook.
138+
*
139+
* @param order the order in which this hook should run. Higher numbers are run first
140+
*/
71141
def AfterStep(order: Int): HookBody = AfterStep(EMPTY_TAG_EXPRESSION, order)
72142

73-
def AfterStep(tagExpression: String, order: Int): HookBody = new HookBody(HookType.AFTER_STEP, tagExpression, order)
143+
/**
144+
* Defines and after step hook.
145+
*
146+
* @param tagExpression a tag expression, if the expression applies to the current scenario this hook will be executed
147+
* @param order the order in which this hook should run. Higher numbers are run first
148+
*/
149+
def AfterStep(tagExpression: String, order: Int) = new HookBody(HookType.AFTER_STEP, tagExpression, order)
74150

75151
final class HookBody(hookType: HookType, tagExpression: String, order: Int) {
76152

@@ -98,6 +174,14 @@ private[scala] trait HookDsl extends BaseScalaDsl {
98174

99175
private[scala] trait DocStringTypeDsl extends BaseScalaDsl {
100176

177+
/**
178+
* Register doc string type.
179+
*
180+
* @param contentType Name of the content type.
181+
* @param body a function that creates an instance of <code>T</code>
182+
* from the doc string
183+
* @tparam T type to convert to
184+
*/
101185
def DocStringType[T](contentType: String)(body: DocStringDefinitionBody[T])(implicit ev: ClassTag[T]): Unit = {
102186
registry.docStringTypes += ScalaDocStringTypeDetails[T](contentType, body, ev)
103187
}
@@ -106,8 +190,20 @@ private[scala] trait DocStringTypeDsl extends BaseScalaDsl {
106190

107191
private[scala] trait DataTableTypeDsl extends BaseScalaDsl {
108192

193+
/**
194+
* Register a data table type.
195+
*/
109196
def DataTableType: DataTableTypeBody = DataTableType(NO_REPLACEMENT)
110197

198+
/**
199+
* Register a data table type with a replacement.
200+
* <p>
201+
* A data table can only represent absent and non-empty strings. By replacing
202+
* a known value (for example [empty]) a data table can also represent
203+
* empty strings.
204+
*
205+
* @param replaceWithEmptyString a string that will be replaced with an empty string.
206+
*/
111207
def DataTableType(replaceWithEmptyString: String): DataTableTypeBody = DataTableType(Seq(replaceWithEmptyString))
112208

113209
private def DataTableType(replaceWithEmptyString: Seq[String]) = new DataTableTypeBody(replaceWithEmptyString)
@@ -136,6 +232,13 @@ private[scala] trait DataTableTypeDsl extends BaseScalaDsl {
136232

137233
private[scala] trait ParameterTypeDsl extends BaseScalaDsl {
138234

235+
/**
236+
* Register parameter type.
237+
*
238+
* @param name used as the type name in typed expressions
239+
* @param regex expression to match
240+
* @see https://cucumber.io/docs/cucumber/cucumber-expressions
241+
*/
139242
def ParameterType(name: String, regex: String) = new ParameterTypeBody(name, regex)
140243

141244
final class ParameterTypeBody(name: String, regex: String) {
@@ -306,14 +409,35 @@ private[scala] trait ParameterTypeDsl extends BaseScalaDsl {
306409

307410
private[scala] trait DefaultTransformerDsl extends BaseScalaDsl {
308411

412+
/**
413+
* Register default parameter type transformer.
414+
*
415+
* @param body converts `String` argument to an instance of the `Type` argument
416+
*/
309417
def DefaultParameterTransformer(body: DefaultParameterTransformerBody): Unit = {
310418
registry.defaultParameterTransformers += ScalaDefaultParameterTransformerDetails(body)
311419
}
312420

421+
/**
422+
* Register default data table cell transformer.
423+
*
424+
* @param body converts `String` argument to an instance of the `Type` argument
425+
*/
313426
def DefaultDataTableCellTransformer(body: DefaultDataTableCellTransformerBody): Unit = {
314427
DefaultDataTableCellTransformer(NO_REPLACEMENT)(body)
315428
}
316429

430+
/**
431+
* Register default data table cell transformer with a replacement.
432+
* <p>
433+
* A data table can only represent absent and non-empty strings. By replacing
434+
* a known value (for example [empty]) a data table can also represent
435+
* empty strings.
436+
* *
437+
*
438+
* @param replaceWithEmptyString a string that will be replaced with an empty string.
439+
* @param body converts `String` argument to an instance of the `Type` argument
440+
*/
317441
def DefaultDataTableCellTransformer(replaceWithEmptyString: String)(body: DefaultDataTableCellTransformerBody): Unit = {
318442
DefaultDataTableCellTransformer(Seq(replaceWithEmptyString))(body)
319443
}
@@ -322,10 +446,25 @@ private[scala] trait DefaultTransformerDsl extends BaseScalaDsl {
322446
registry.defaultDataTableCellTransformers += ScalaDefaultDataTableCellTransformerDetails(replaceWithEmptyString, body)
323447
}
324448

449+
/**
450+
* Register default data table entry transformer.
451+
*
452+
* @param body converts `Map[String,String]` argument to an instance of the `Type` argument
453+
*/
325454
def DefaultDataTableEntryTransformer(body: DefaultDataTableEntryTransformerBody): Unit = {
326455
DefaultDataTableEntryTransformer(NO_REPLACEMENT)(body)
327456
}
328457

458+
/**
459+
* Register default data table cell transformer with a replacement.
460+
* <p>
461+
* A data table can only represent absent and non-empty strings. By replacing
462+
* a known value (for example [empty]) a data table can also represent
463+
* empty strings.
464+
*
465+
* @param replaceWithEmptyString a string that will be replaced with an empty string.
466+
* @param body converts `Map[String,String]` argument to an instance of the `Type` argument
467+
*/
329468
def DefaultDataTableEntryTransformer(replaceWithEmptyString: String)(body: DefaultDataTableEntryTransformerBody): Unit = {
330469
DefaultDataTableEntryTransformer(Seq(replaceWithEmptyString))(body)
331470
}

0 commit comments

Comments
 (0)