public function generate($basePath, $pretty)
    {
        $fileReflectorRegister = new ReflectorRegister();

        $rootPath = $this->executionPath;
        foreach ($this->files as $file) {
            $currentFileArr = $this->isComponent
                ? explode("/$basePath/", $file)
                : explode("$rootPath", $file);

            if (isset($currentFileArr[1])) {
                $currentFile = str_replace('src/', '', $currentFileArr[1]);
            } else {
                throw new \Exception(
                    sprintf('Failed to determine currentFile: %s', $file)
                );
            }

            $isPhp = strrpos($file, '.php') == strlen($file) - strlen('.php');
            $pathInfo = pathinfo($currentFile);
            $servicePath = $pathInfo['dirname'] === '.'
                ? strtolower($pathInfo['filename'])
                : strtolower($pathInfo['dirname'] . '/' . $pathInfo['filename']);
            $id = $this->isComponent
                ? strtolower($basePath) . '/' . $servicePath
                : $servicePath;

            if ($isPhp) {
                $parser = new CodeParser(
                    $file,
                    $fileReflectorRegister,
                    $rootPath,
                    $this->componentId,
                    $this->manifestPath,
                    $this->release,
                    $this->output,
                    $id,
                    $this->isComponent
                );
            } else {
                $content = file_get_contents($file);
                $parser = new MarkdownParser($currentFile, $content, $id);
            }

            $document = $parser->parse();
            if ($document) {
                $writer = new Writer($document, $this->outputPath, $pretty);
                $writer->write($currentFile);

                $this->types->addType([
                    'id' => $id,
                    'title' => $document['title'],
                    'contents' => $servicePath . '.json'
                ]);
            }
        }
    }