Skip to content

Commit e0713ef

Browse files
committed
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
- Added more information - Made deprecation warning specific to generate:docs
1 parent 00caa60 commit e0713ef

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected function configure()
5757
*/
5858
protected function execute(InputInterface $input, OutputInterface $output)
5959
{
60+
defined('COMMAND') || define('COMMAND', 'generate:docs');
6061
$config = $input->getOption('output');
6162
$clean = $input->getOption('clean');
6263

src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ActionGroupAnnotationExtractor extends AnnotationExtractor
1919
"description",
2020
"page",
2121
];
22+
const GENERATE_DOCS_COMMAND = 'generate:docs';
2223

2324
/**
2425
* This method trims away irrelevant tags and returns annotations used in the array passed. The annotations
@@ -39,8 +40,10 @@ public function extractAnnotations($testAnnotations, $filename)
3940
foreach ($annotations as $annotationKey => $annotationData) {
4041
$annotationObjects[$annotationKey] = $annotationData[parent::ANNOTATION_VALUE];
4142
}
43+
if(defined('COMMAND') and COMMAND == self::GENERATE_DOCS_COMMAND) {
44+
$this->validateMissingAnnotations($annotationObjects, $filename);
45+
}
4246

43-
$this->validateMissingAnnotations($annotationObjects, $filename);
4447
return $annotationObjects;
4548
}
4649

src/Magento/FunctionalTestingFramework/Util/DocGenerator.php

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,11 @@
66

77
namespace Magento\FunctionalTestingFramework\Util;
88

9-
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
10-
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
11-
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
129
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
13-
use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
14-
use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler;
1510
use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler;
16-
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
1711
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
18-
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
19-
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
20-
use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
2112
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
22-
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
23-
use Magento\FunctionalTestingFramework\Util\Manifest\BaseTestManifest;
24-
use Magento\FunctionalTestingFramework\Util\Manifest\TestManifestFactory;
25-
use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor;
26-
use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor;
27-
use Magento\FunctionalTestingFramework\Util\Filesystem\DirSetupUtil;
13+
2814

2915
/**
3016
* Class TestGenerator
@@ -44,6 +30,8 @@ class DocGenerator
4430
const ANNOTATION_MODULE = "";
4531
const ANNOTATION_PAGE = "page";
4632
const ANNOTATION_DESCRIPTION = "description";
33+
const FILENAMES = "filenames";
34+
const ARGUMENTS = "arguments";
4735

4836
/**
4937
* Single instance of class var
@@ -112,10 +100,12 @@ public function createDocumentation($annotatedObjects, $outputDir, $clean)
112100
foreach ($annotatedObjects as $name => $object) {
113101
$annotations = $object->getAnnotations();
114102
$filenames = $this->flattenArray($object->getFileNames());
103+
$arguments = $object->getArguments();
115104

116105
$info = [
117106
self::ANNOTATION_DESCRIPTION => $annotations[self::ANNOTATION_DESCRIPTION] ?? 'NO_DESCRIPTION_SPECIFIED',
118-
'filenames' => $filenames
107+
self::FILENAMES => $filenames,
108+
self::ARGUMENTS => $arguments
119109
];
120110
$pageGroups = array_merge_recursive(
121111
$pageGroups,
@@ -144,21 +134,44 @@ public function createDocumentation($annotatedObjects, $outputDir, $clean)
144134
*/
145135
private function transformToMarkdown($annotationList)
146136
{
147-
$markdown = "";
137+
$markdown = "#Action Group Information" . PHP_EOL;
138+
$markdown .= "This documentation contains a list of all" .
139+
" action groups on the pages on which they start" .
140+
PHP_EOL .
141+
PHP_EOL;
148142

143+
$markdown .= "##List of Pages" . PHP_EOL;
149144
foreach($annotationList as $group => $objects)
150145
{
151-
$markdown .= "###$group" . PHP_EOL . PHP_EOL;
146+
$markdown .= "- [ $group ](#$group)" . PHP_EOL;
147+
}
148+
$markdown .= "---" . PHP_EOL;
149+
foreach($annotationList as $group => $objects)
150+
{
151+
$markdown .= "<a name=\"$group\"></a>" . PHP_EOL;
152+
$markdown .= "##$group" . PHP_EOL . PHP_EOL;
152153
foreach($objects as $name => $annotations)
153154
{
154-
$markdown .= "####$name" . PHP_EOL;
155+
$markdown .= "###$name" . PHP_EOL;
155156
$markdown .= $annotations[self::ANNOTATION_DESCRIPTION] . PHP_EOL . PHP_EOL;
157+
if(!empty($annotations[self::ARGUMENTS])) {
158+
$markdown .= "Action Group Arguments:" . PHP_EOL . PHP_EOL;
159+
$markdown .= "| Name | Type |" . PHP_EOL;
160+
$markdown .= "| --- | --- |" . PHP_EOL;
161+
foreach($annotations[self::ARGUMENTS] as $argument) {
162+
$argumentName = $argument->getName();
163+
$argumentType = $argument->getDataType();
164+
$markdown .= "| $argumentName | $argumentType |" . PHP_EOL;
165+
}
166+
$markdown .= PHP_EOL;
167+
}
156168
$markdown .= "Located in:" . PHP_EOL;
157-
foreach($annotations['filenames'] as $filename)
169+
foreach($annotations[self::FILENAMES] as $filename)
158170
{
159-
$markdown .= "- $filename";
171+
$relativeFilename = str_replace(MAGENTO_BP . DIRECTORY_SEPARATOR, "", $filename);
172+
$markdown .= "- $relativeFilename";
160173
}
161-
$markdown .= PHP_EOL . PHP_EOL;
174+
$markdown .= PHP_EOL . "***" . PHP_EOL;
162175
}
163176
}
164177
return $markdown;

0 commit comments

Comments
 (0)