function setUpOnce() { parent::setUpOnce(); $this->origEnabled = DocumentationService::automatic_registration_enabled(); DocumentationService::set_automatic_registration(false); $this->origModules = DocumentationService::get_registered_entities(); $this->origLinkBase = DocumentationViewer::get_link_base(); DocumentationViewer::set_link_base('dev/docs/'); foreach ($this->origModules as $module) { DocumentationService::unregister($module->getFolder()); } // We set 3.0 as current, and test most assertions against 2.4 - to avoid 'current' rewriting issues DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs/", '2.3'); DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '2.4', 'Doc Test', true); DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-v3.0/", '3.0', 'Doc Test'); DocumentationService::register("DocumentationViewerAltModule1", BASE_PATH . "/sapphiredocs/tests/docs-parser/", '1.0'); DocumentationService::register("DocumentationViewerAltModule2", BASE_PATH . "/sapphiredocs/tests/docs-search/", '1.0'); }
/** * Generate an array of every single documentation page installed on the system. * * @return DataObjectSet */ public static function get_all_documentation_pages() { DocumentationService::load_automatic_registration(); $modules = DocumentationService::get_registered_entities(); $output = new DataObjectSet(); if ($modules) { foreach ($modules as $module) { foreach ($module->getVersions() as $version) { try { $pages = DocumentationService::get_pages_from_folder($module, false, true, $version); if ($pages) { foreach ($pages as $page) { $output->push($page); } } } catch (Exception $e) { user_error($e, E_USER_WARNING); } } } } return $output; }
/** * Generate a list of entities which have been registered and which can * be documented. * * @return DataObject */ function getEntities($version = false, $lang = false) { $entities = DocumentationService::get_registered_entities($version, $lang); $output = new DataObjectSet(); $currentEntity = $this->getEntity(); if ($entities) { foreach ($entities as $entity) { $mode = $entity === $currentEntity ? 'current' : 'link'; $folder = $entity->getFolder(); $link = $this->Link(array(), $folder, false, $lang); $content = false; if ($page = $entity->getIndexPage($version, $lang)) { $content = DBField::create('HTMLText', DocumentationParser::parse($page, $link)); } $output->push(new ArrayData(array('Title' => $entity->getTitle(), 'Link' => $link, 'LinkingMode' => $mode, 'Content' => $content))); } } return $output; }