상속: extends ArrayObjec\ArrayObject
예제 #1
0
 public function getStaticRoot()
 {
     $config = new Config();
     $config->setDocumentationDirectory('');
     $config['mode'] = Daux::STATIC_MODE;
     $config['index_key'] = 'index.html';
     $config['valid_content_extensions'] = ['md'];
     return new Root($config);
 }
예제 #2
0
 protected function createContent($content)
 {
     $config = new Config();
     $config->setDocumentationDirectory('');
     $dir = new Directory(new Root($config), '');
     $obj = new Content($dir, '');
     $obj->setContent($content);
     return $obj;
 }
예제 #3
0
 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;
 }
예제 #4
0
 /**
  * @dataProvider providerSort
  */
 public function testSort($list, $expected)
 {
     shuffle($list);
     $config = new Config();
     $config->setDocumentationDirectory('');
     $directory = new Directory(new Root($config), 'dir');
     foreach ($list as $value) {
         $entry = new Content($directory, $value);
         $entry->setName($value);
     }
     $directory->sort();
     $final = [];
     foreach ($directory->getEntries() as $obj) {
         $final[] = $obj->getName();
     }
     $this->assertEquals($expected, $final);
 }
예제 #5
0
 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']);
 }
예제 #6
0
 /**
  * @param AbstractInline|Link $inline
  * @param ElementRendererInterface $htmlRenderer
  * @return HtmlElement
  * @throws Exception
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     // This can't be in the method type as
     // the method is an abstract and should
     // have the same interface
     if (!$inline instanceof Link) {
         throw new \RuntimeException('Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided");
     }
     $element = parent::render($inline, $htmlRenderer);
     $url = $inline->getUrl();
     // Absolute urls, empty urls and anchors
     // should not go through the url resolver
     if (empty($url) || $url[0] == '#' || preg_match('|^(?:[a-z]+:)?//|', $url)) {
         return $element;
     }
     $file = $this->resolveInternalFile($url);
     $url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
     $element->setAttribute('href', $url);
     return $element;
 }
예제 #7
0
 protected static function resolveVariant(Config $params)
 {
     if (array_key_exists('theme-variant', $params['html'])) {
         return;
     }
     if (is_dir(realpath($params->getThemesPath() . DIRECTORY_SEPARATOR . $params['html']['theme']))) {
         return;
     }
     $theme = explode('-', $params['html']['theme']);
     // do we have a variant or only a theme ?
     if (isset($theme[1])) {
         $params['html']['theme-variant'] = array_pop($theme);
         $params['html']['theme'] = implode('-', $theme);
     } else {
         $params['html']['theme'] = array_pop($theme);
     }
     if (!is_dir(realpath($params->getThemesPath() . DIRECTORY_SEPARATOR . $params['html']['theme']))) {
         throw new \RuntimeException("Theme '{$params['html']['theme']}' not found");
     }
 }
예제 #8
0
파일: Daux.php 프로젝트: rlugojr/daux.io
 /**
  * @return Config
  */
 public function getParams()
 {
     if ($this->tree && !$this->merged_tree) {
         $this->options['tree'] = $this->tree;
         $this->options['index'] = $this->tree->getIndexPage() ?: $this->tree->getFirstPage();
         if ($this->options->isMultilanguage()) {
             foreach ($this->options['languages'] as $key => $name) {
                 $this->options['entry_page'][$key] = $this->tree->getEntries()[$key]->getFirstPage();
             }
         } else {
             $this->options['entry_page'] = $this->tree->getFirstPage();
         }
         $this->merged_tree = true;
     }
     return $this->options;
 }
예제 #9
0
 /**
  * @param AbstractInline|Link $inline
  * @param ElementRendererInterface $htmlRenderer
  * @return HtmlElement
  * @throws LinkNotFoundException
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     // This can't be in the method type as
     // the method is an abstract and should
     // have the same interface
     if (!$inline instanceof Link) {
         throw new \RuntimeException('Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided");
     }
     $element = parent::render($inline, $htmlRenderer);
     $url = $inline->getUrl();
     // empty urls and anchors should
     // not go through the url resolver
     if (!$this->isValidUrl($url)) {
         return $element;
     }
     // Absolute urls, shouldn't either
     if ($this->isExternalUrl($url)) {
         $element->setAttribute('class', 'external');
         return $element;
     }
     // if there's a hash component in the url, ensure we
     // don't put that part through the resolver.
     $urlAndHash = explode('#', $url);
     $url = $urlAndHash[0];
     try {
         $file = $this->resolveInternalFile($url);
         $url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
     } catch (LinkNotFoundException $e) {
         if ($this->daux->isStatic()) {
             throw $e;
         }
         $element->setAttribute('class', 'broken');
     }
     if (isset($urlAndHash[1])) {
         $url .= '#' . $urlAndHash[1];
     }
     $element->setAttribute('href', $url);
     return $element;
 }
예제 #10
0
파일: Daux.php 프로젝트: LuziaSol/LuziaDocs
 /**
  * @return Config
  */
 public function getParams()
 {
     if (!$this->merged_defaults) {
         $default = ['multilanguage' => !empty($this->options['languages']), 'mode' => $this->mode, 'local_base' => $this->local_base, 'docs_path' => $this->docs_path, 'themes_path' => $this->themes_path, 'templates' => 'templates'];
         $this->options->conservativeMerge($default);
         $this->options['index_key'] = 'index.html';
         $this->options['base_page'] = $this->options['base_url'] = '';
         $this->merged_defaults = true;
     }
     if ($this->tree && !$this->merged_tree) {
         $this->options['tree'] = $this->tree;
         $this->options['index'] = $this->tree->getIndexPage() ?: $this->tree->getFirstPage();
         if ($this->options['multilanguage']) {
             foreach ($this->options['languages'] as $key => $name) {
                 $this->options['entry_page'][$key] = $this->tree->getEntries()[$key]->getFirstPage();
             }
         } else {
             $this->options['entry_page'] = $this->tree->getFirstPage();
         }
         $this->merged_tree = true;
     }
     return $this->options;
 }
예제 #11
0
 public function convert($raw, Content $node)
 {
     $this->config->setCurrentPage($node);
     return $this->converter->convertToHtml($raw);
 }
예제 #12
0
 function testHTMLConfigCreation()
 {
     $config = new MainConfig(['html' => ['edit_on' => 'test']]);
     $this->assertInstanceOf(Config::class, $config->getHTML());
     $this->assertEquals('test', $config->getHTML()['edit_on']);
 }