parent
af33599e19
commit
75577cec51
|
@ -266,8 +266,6 @@ class ActionController extends Zend_Controller_Action
|
|||
return call_user_func_array(array($this, $deprecatedMethod), $params);
|
||||
}
|
||||
|
||||
parent::__call($name, $params);
|
||||
|
||||
return null;
|
||||
return parent::__call($name, $params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,21 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Module\Doc\Parser as DocParser;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
|
||||
class Doc_IndexController extends ActionController
|
||||
{
|
||||
/**
|
||||
* Display the application's documentation
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_forward('index', 'view');
|
||||
$parser = new DocParser();
|
||||
list($html, $toc) = $parser->parseDirectory(Icinga::app()->getApplicationDir('/../doc'));
|
||||
$this->view->html = $html;
|
||||
$this->view->toc = $toc;
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
|
||||
class Doc_ModuleController extends ActionController
|
||||
{
|
||||
/**
|
||||
* Display module documentations index
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a module's documentation
|
||||
*/
|
||||
public function moduleAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide run-time dispatching of module documentation
|
||||
*
|
||||
* @param string $methodName
|
||||
* @param array $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($methodName, $args)
|
||||
{
|
||||
// TODO(el): Setup routing to retrieve module name as param and point route to moduleAction
|
||||
$moduleManager = Icinga::app()->getModuleManager();
|
||||
$moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix
|
||||
if (!$moduleManager->hasEnabled($moduleName)) {
|
||||
// TODO(el): Throw a not found exception once the code has been moved to the moduleAction (see TODO above)
|
||||
return parent::__call($methodName, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Module\Doc\Parser as DocParser;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
|
||||
class Doc_ViewController extends ActionController
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->_helper->viewRenderer->setRender('view');
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate view
|
||||
*
|
||||
* @param string $dir
|
||||
*/
|
||||
private function populateView($dir)
|
||||
{
|
||||
$parser = new DocParser();
|
||||
list($html, $toc) = $parser->parseDirectory($dir);
|
||||
$this->view->html = $html;
|
||||
$this->view->toc = $toc;
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->populateView(Icinga::app()->getApplicationDir('/../doc'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide run-time dispatching of module documentation
|
||||
*
|
||||
* @param string $methodName
|
||||
* @param array $args
|
||||
*/
|
||||
public function __call($methodName, $args)
|
||||
{
|
||||
$moduleManager = Icinga::app()->getModuleManager();
|
||||
$moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix
|
||||
if ($moduleManager->hasEnabled($moduleName)) {
|
||||
$this->populateView($moduleManager->getModuleDir($moduleName, '/doc'));
|
||||
} else {
|
||||
parent::__call($methodName, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
|
@ -0,0 +1,14 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-12 col-xs-12 col-md-2 col-lg-2">
|
||||
<ul class="nav nav-pills nav-stacked" role="navigation">
|
||||
<?php foreach ($toc as $i): ?>
|
||||
<li class="toc-h<?= $i['level'] ?>">
|
||||
<a href="#<?= $i['fragment'] ?>"><?= $this->escape($i['heading']); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-12 col-xs-12 col-md-10 col-lg-10">
|
||||
<?= $html ?>
|
||||
</div>
|
||||
</div>
|
|
@ -1,10 +0,0 @@
|
|||
<div class="doc-toc pull-left">
|
||||
<ul class="nav nav-stacked">
|
||||
<?php foreach ($toc as $i): ?>
|
||||
<li class="toc-h<?= $i['level'] ?>">
|
||||
<a href="#<?= $i['fragment'] ?>"><?= $this->escape($i['heading']); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?= $html ?>
|
|
@ -6,6 +6,9 @@ namespace Icinga\Module\Doc;
|
|||
|
||||
use \RecursiveFilterIterator;
|
||||
|
||||
/**
|
||||
* Iterator over Markdown files recursively
|
||||
*/
|
||||
class MarkdownFileIterator extends RecursiveFilterIterator
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -4,21 +4,20 @@
|
|||
|
||||
namespace Icinga\Module\Doc;
|
||||
|
||||
require_once 'vendor/Michelf/Markdown.php';
|
||||
require_once 'vendor/Michelf/MarkdownExtra.php';
|
||||
require_once 'vendor/Parsedown/Parsedown.php';
|
||||
|
||||
use \RecursiveIteratorIterator;
|
||||
use \RecursiveDirectoryIterator;
|
||||
use \Exception;
|
||||
use Michelf\MarkdownExtra;
|
||||
use \Parsedown;
|
||||
|
||||
/**
|
||||
* Markdown parser
|
||||
* Parser for documentation written in Markdown
|
||||
*/
|
||||
class Parser
|
||||
{
|
||||
/**
|
||||
* Retrieve table of contents and HTML converted from all markdown files in the given directory sorted by filename
|
||||
* Retrieve table of contents and HTML converted from all Markdown files in the given directory sorted by filename
|
||||
*
|
||||
* @param $dir
|
||||
*
|
||||
|
@ -87,7 +86,7 @@ class Parser
|
|||
}
|
||||
$fileObject->flock(LOCK_UN);
|
||||
}
|
||||
$html = MarkdownExtra::defaultTransform(implode('', $cat));
|
||||
$html = Parsedown::instance()->parse(implode('', $cat));
|
||||
return array($html, $toc);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue