protected function getTree(Config $config) { $structure = ['Content' => ['Page.md' => 'some text content'], 'Widgets' => ['Page.md' => 'another page', 'Button.md' => 'another page']]; $root = vfsStream::setup('root', null, $structure); $config->setDocumentationDirectory($root->url()); $config['valid_content_extensions'] = ['md']; $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $tree = new Root($config); Builder::build($tree, []); return $tree; }
public function testCreateHierarchy() { $config = new Config(); $config->setDocumentationDirectory($this->root->url()); $config['valid_content_extensions'] = ['md']; $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $tree = new Root($config); Builder::build($tree, []); $this->assertCount(2, $tree); $this->assertTrue(array_key_exists('Contents', $tree->getEntries())); $this->assertInstanceOf(Directory::class, $tree['Contents']); $this->assertTrue(array_key_exists('Widgets', $tree->getEntries())); $this->assertInstanceOf(Directory::class, $tree['Widgets']); // TODO :: should not be Page.html, this should not depend on the mode $this->assertEquals('Page', $tree['Contents']['Page.html']->getTitle()); $this->assertInstanceOf(Content::class, $tree['Contents']['Page.html']); }
/** * Generate the tree that will be used */ public function generateTree() { $this->options['valid_content_extensions'] = $this->getContentExtensions(); $this->tree = new Root($this->getParams()); Builder::build($this->tree, $this->options['ignore']); if (!empty($this->options['languages'])) { foreach ($this->options['languages'] as $key => $node) { $this->tree->getEntries()[$key]->setTitle($node); } } // Enhance the tree with processors $this->getProcessor()->manipulateTree($this->tree); // Sort the tree one last time before it is finalized $this->sortTree($this->tree); $this->finalizeTree($this->tree); }
/** * Get the possible output file names for a source file. * * @param Config $config * @param string $part * @return string[] */ public static function getFilenames(Config $config, $part) { $extensions = implode('|', array_map('preg_quote', $config['valid_content_extensions'])) . '|html'; $raw = preg_replace('/(.*)?\\.(' . $extensions . ')$/', '$1', $part); $raw = Builder::removeSortingInformations($raw); return ["{$raw}.html", $raw]; }
public function testGetOrCreateRawPage() { $directory = new Directory($this->getStaticRoot(), 'dir'); $entry = Builder::getOrCreatePage($directory, 'file.json'); $this->assertSame($directory, $entry->getParent()); $this->assertEquals('dir/file.json', $entry->getUrl()); $this->assertEquals('file.json', $entry->getUri()); $this->assertInstanceOf('Todaymade\\Daux\\Tree\\ComputedRaw', $entry); }