1010use Doctrine \RST \ErrorManager ;
1111use Doctrine \RST \Event \PostNodeCreateEvent ;
1212use Doctrine \RST \Meta \Metas ;
13- use Symfony \CodeBlockChecker \Issue \IssueCollection ;
1413use Symfony \CodeBlockChecker \Listener \CodeNodeCollector ;
14+ use Symfony \CodeBlockChecker \Service \Baseline ;
1515use Symfony \CodeBlockChecker \Service \CodeValidator ;
1616use Symfony \Component \Console \Command \Command ;
1717use Symfony \Component \Console \Input \InputArgument ;
@@ -27,25 +27,27 @@ class CheckDocsCommand extends Command
2727 protected static $ defaultName = 'verify:docs ' ;
2828
2929 private SymfonyStyle $ io ;
30- private IssueCollection $ errorManager ;
3130 private ParseQueueProcessor $ queueProcessor ;
3231 private CodeNodeCollector $ collector ;
3332 private CodeValidator $ validator ;
33+ private Baseline $ baseline ;
3434
35- public function __construct (CodeValidator $ validator )
35+ public function __construct (CodeValidator $ validator, Baseline $ baseline )
3636 {
3737 parent ::__construct (self ::$ defaultName );
3838 $ this ->validator = $ validator ;
39+ $ this ->baseline = $ baseline ;
3940 }
4041
4142 protected function configure ()
4243 {
4344 $ this
4445 ->addArgument ('source-dir ' , InputArgument::REQUIRED , 'RST files Source directory ' )
4546 ->addArgument ('files ' , InputArgument::IS_ARRAY + InputArgument::REQUIRED , 'RST files that should be verified. ' )
46- ->addOption ('output-format ' , null , InputOption::VALUE_OPTIONAL , 'Valid options are github and console ' , 'github ' )
47+ ->addOption ('output-format ' , null , InputOption::VALUE_REQUIRED , 'Valid options are github and console ' , 'github ' )
48+ ->addOption ('generate-baseline ' , null , InputOption::VALUE_REQUIRED , 'Generate a new baseline ' , false )
49+ ->addOption ('baseline ' , null , InputOption::VALUE_REQUIRED , 'Use a baseline ' , false )
4750 ->setDescription ('Make sure the docs blocks are valid ' )
48-
4951 ;
5052 }
5153
@@ -88,6 +90,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8890 $ this ->queueProcessor ->process ($ parseQueue );
8991 $ issues = $ this ->validator ->validateNodes ($ this ->collector ->getNodes ());
9092
93+ if ($ baselineFile = $ input ->getOption ('generate-baseline ' )) {
94+ $ this ->baseline ->generate ($ issues , $ baselineFile );
95+
96+ return Command::SUCCESS ;
97+ }
98+
99+ if ($ baselineFile = $ input ->getOption ('baseline ' )) {
100+ $ issues = $ this ->baseline ->filter ($ issues , $ baselineFile );
101+ }
102+
91103 $ issueCount = count ($ issues );
92104 if ($ issueCount > 0 ) {
93105 $ format = $ input ->getOption ('output-format ' );
0 commit comments