function run()
    {
        $loader = new Twig_Loader_Filesystem($this->templateDir);

        $twig = new Twig_Environment($loader);

        $GLOBALS['PHPDocMD_classDefinitions'] = $this->classDefinitions;
        $GLOBALS['PHPDocMD_linkTemplate'] = $this->linkTemplate;

        $filter = new Twig_SimpleFilter('classLink', ['PHPDocMd\\Generator', 'classLink']);
        $twig->addFilter($filter);

        foreach ($this->classDefinitions as $className => $data) {
            $output = $twig->render('class.twig', $data);

            file_put_contents($this->outputDir . '/' . $data['fileName'], $output);
        }

        $index = $this->createIndex();

        $index = $twig->render('index.twig',
            [
                'index'            => $index,
                'classDefinitions' => $this->classDefinitions,
            ]
        );

        file_put_contents($this->outputDir . '/' . $this->apiIndexFile, $index);
    }