55use Doctrine \Common \EventManager ;
66use Doctrine \RST \Builder ;
77use Doctrine \RST \Configuration ;
8+ use Doctrine \RST \ErrorManager ;
89use Doctrine \RST \Event \PostBuildRenderEvent ;
10+ use Doctrine \RST \Event \PreNodeRenderEvent ;
911use Doctrine \RST \Meta \Metas ;
1012use Symfony \Component \Console \Command \Command ;
1113use Symfony \Component \Console \Input \InputArgument ;
2123use SymfonyDocsBuilder \KernelFactory ;
2224use SymfonyDocsBuilder \Listener \AssetsCopyListener ;
2325use SymfonyDocsBuilder \Listener \BuildProgressListener ;
24- use SymfonyDocsBuilder \Listener \CopyImagesDirectoryListener ;
26+ use SymfonyDocsBuilder \Listener \CopyImagesListener ;
2527
2628class BuildDocsCommand extends Command
2729{
@@ -96,6 +98,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
9698 $ filesystem ->remove ($ htmlOutputDir );
9799 }
98100
101+ $ filesystem ->mkdir ($ htmlOutputDir );
102+
99103 $ parseSubPath = $ input ->getOption ('parse-sub-path ' );
100104 if ($ parseSubPath && $ input ->getOption ('output-json ' )) {
101105 throw new \InvalidArgumentException ('Cannot pass both --parse-sub-path and --output-json options. ' );
@@ -120,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
120124 KernelFactory::createKernel ($ this ->buildContext , $ this ->urlChecker ?? null )
121125 );
122126
123- $ this ->initializeListeners ($ builder ->getConfiguration ()->getEventManager ());
127+ $ this ->addProgressListener ($ builder ->getConfiguration ()->getEventManager ());
124128
125129 $ builder ->build (
126130 $ this ->buildContext ->getSourceDir (),
@@ -175,20 +179,8 @@ private function renderDocForPDF(Metas $metas)
175179 $ htmlForPdfGenerator ->generateHtmlForPdf ();
176180 }
177181
178- private function initializeListeners (EventManager $ eventManager )
182+ private function addProgressListener (EventManager $ eventManager )
179183 {
180- $ eventManager ->addEventListener (
181- PostBuildRenderEvent::POST_BUILD_RENDER ,
182- new CopyImagesDirectoryListener ($ this ->buildContext )
183- );
184-
185- if (!$ this ->buildContext ->getParseSubPath ()) {
186- $ eventManager ->addEventListener (
187- [PostBuildRenderEvent::POST_BUILD_RENDER ],
188- new AssetsCopyListener ($ this ->buildContext ->getOutputDir ())
189- );
190- }
191-
192184 $ progressListener = new BuildProgressListener ($ this ->io );
193185 $ progressListener ->attachListeners ($ eventManager );
194186 }
0 commit comments