@@ -124,7 +124,7 @@ namespace cucumber_cpp::library::engine
124124 return table;
125125
126126 for (const auto & dataTable = optionalPickleStepArgument.value ().data_table .value ();
127- const auto & row : dataTable.rows )
127+ const auto & row : dataTable.rows )
128128 {
129129 table.emplace_back ();
130130 auto & back = table.back ();
@@ -136,6 +136,17 @@ namespace cucumber_cpp::library::engine
136136 return table;
137137 }
138138
139+ std::string DocStringFactory (const std::optional<cucumber::messages::pickle_step_argument>& optionalPickleStepArgument)
140+ {
141+ if (!optionalPickleStepArgument)
142+ return " " ;
143+
144+ if (!optionalPickleStepArgument.value ().doc_string .has_value ())
145+ return " " ;
146+
147+ return optionalPickleStepArgument.value ().doc_string .value ().content ;
148+ }
149+
139150 std::set<std::string, std::less<>> TagsFactory (const std::vector<cucumber::messages::tag>& tags)
140151 {
141152 const auto range = tags | std::views::transform (&cucumber::messages::tag::name);
@@ -151,10 +162,11 @@ namespace cucumber_cpp::library::engine
151162 void ConstructStep (const FeatureTreeFactory& featureTreeFactory, ScenarioInfo& scenarioInfo, const cucumber::messages::step& step, const cucumber::messages::pickle_step& pickleStep)
152163 {
153164 auto table = TableFactory (pickleStep.argument );
165+ auto docString = DocStringFactory (pickleStep.argument );
154166
155167 try
156168 {
157- scenarioInfo.Children ().push_back (featureTreeFactory.CreateStepInfo (stepTypeLut.at (*pickleStep.type ), pickleStep.text , scenarioInfo, step.location .line , step.location .column .value_or (0 ), std::move (table)));
169+ scenarioInfo.Children ().push_back (featureTreeFactory.CreateStepInfo (stepTypeLut.at (*pickleStep.type ), pickleStep.text , scenarioInfo, step.location .line , step.location .column .value_or (0 ), std::move (table), std::move (docString) ));
158170 }
159171 catch (const std::out_of_range&)
160172 {
@@ -287,20 +299,20 @@ namespace cucumber_cpp::library::engine
287299 : stepRegistry{ stepRegistry }
288300 {}
289301
290- std::unique_ptr<StepInfo> FeatureTreeFactory::CreateStepInfo (StepType stepType, std::string stepText, const ScenarioInfo& scenarioInfo, std::size_t line, std::size_t column, std::vector<std::vector<TableValue>> table) const
302+ std::unique_ptr<StepInfo> FeatureTreeFactory::CreateStepInfo (StepType stepType, std::string stepText, const ScenarioInfo& scenarioInfo, std::size_t line, std::size_t column, std::vector<std::vector<TableValue>> table, std::string docString ) const
291303 {
292304 try
293305 {
294306 auto stepMatch = stepRegistry.Query (stepText);
295- return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table), std::move (stepMatch));
307+ return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table), std::move (docString), std::move ( stepMatch));
296308 }
297309 catch (const StepRegistry::StepNotFoundError&)
298310 {
299- return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table));
311+ return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table), std::move (docString) );
300312 }
301313 catch (StepRegistry::AmbiguousStepError& ase)
302314 {
303- return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table), std::move (ase.matches ));
315+ return std::make_unique<StepInfo>(scenarioInfo, std::move (stepText), stepType, line, column, std::move (table), std::move (docString), std::move ( ase.matches ));
304316 }
305317 }
306318
0 commit comments