From 88e13c378dff75af8e69fc2480d56433eb6bc9e4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 3 Feb 2014 15:39:53 +0100 Subject: [PATCH] Modules/Doc: Add doc display per module refs #4820 --- doc/components.md | 8 +++--- .../controllers/IndexController.php | 10 ++----- .../controllers/ModuleController.php | 11 ++++++-- .../views/scripts/index/index.phtml | 19 ++++--------- .../views/scripts/module/index.phtml | 6 ++++ .../views/scripts/module/view.phtml | 18 ++++++++++++ modules/doc/library/Doc/Controller.php | 28 +++++++++++++++++++ .../library/Doc/{Parser.php => DocParser.php} | 2 +- 8 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 modules/doc/application/views/scripts/module/index.phtml create mode 100644 modules/doc/application/views/scripts/module/view.phtml create mode 100644 modules/doc/library/Doc/Controller.php rename modules/doc/library/Doc/{Parser.php => DocParser.php} (99%) diff --git a/doc/components.md b/doc/components.md index c61ff6695..f19986d6f 100644 --- a/doc/components.md +++ b/doc/components.md @@ -29,7 +29,7 @@ A component name consists of two parts: the namespace and the name of the compon is named exactly like its JavaScript file, while the namespace is the name of the Icinga2-Web module that contains the component. Each Icinga2-Web module can contain its own components in the folder *public/js*. - / + / NOTE: The namespace used for modules defined in the Icinga2-Web core application is "app". In opposition to @@ -45,10 +45,10 @@ The full name for the component *modules/monitoring/public/js/someComponent.js* "monitoring/someComponent" -The full component name for the component *public/js/icinga/components/datetime.js* in the Icinga2-Web - core application would: +The full component name for the component *public/js/icinga/components/datetime.js* in the Icinga2-Web core application +would: - "app/datetime" + "app/datetime" ## Creating a component diff --git a/modules/doc/application/controllers/IndexController.php b/modules/doc/application/controllers/IndexController.php index d18eff5db..88834b0e1 100644 --- a/modules/doc/application/controllers/IndexController.php +++ b/modules/doc/application/controllers/IndexController.php @@ -4,20 +4,16 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Application\Icinga; -use Icinga\Module\Doc\Parser as DocParser; -use Icinga\Web\Controller\ActionController; +use Icinga\Module\Doc\Controller as DocController; -class Doc_IndexController extends ActionController +class Doc_IndexController extends DocController { /** * Display the application's documentation */ public function indexAction() { - $parser = new DocParser(); - list($html, $toc) = $parser->parseDirectory(Icinga::app()->getApplicationDir('/../doc')); - $this->view->html = $html; - $this->view->toc = $toc; + $this->populateViewFromDocDirectory(Icinga::app()->getApplicationDir('/../doc')); } } // @codingStandardsIgnoreEnd diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index f59467505..dfb4ff7f9 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -4,22 +4,26 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Application\Icinga; -use Icinga\Web\Controller\ActionController; +use Icinga\Module\Doc\Controller as DocController; -class Doc_ModuleController extends ActionController +class Doc_ModuleController extends DocController { /** * Display module documentations index */ public function indexAction() { + $this->view->enabledModules = Icinga::app()->getModuleManager()->listEnabledModules(); } /** * Display a module's documentation */ - public function moduleAction() + public function viewAction() { + $this->populateViewFromDocDirectory( + Icinga::app()->getModuleManager()->getModuleDir($this->getParam('name'), '/doc') + ); } /** @@ -39,6 +43,7 @@ class Doc_ModuleController extends ActionController // TODO(el): Throw a not found exception once the code has been moved to the moduleAction (see TODO above) return parent::__call($methodName, $args); } + $this->_helper->redirector->gotoSimpleAndExit('view', null, null, array('name' => $moduleName)); } } // @codingStandardsIgnoreEnd diff --git a/modules/doc/application/views/scripts/index/index.phtml b/modules/doc/application/views/scripts/index/index.phtml index 9be7c042a..a178cc155 100644 --- a/modules/doc/application/views/scripts/index/index.phtml +++ b/modules/doc/application/views/scripts/index/index.phtml @@ -1,14 +1,5 @@ -
-
- -
-
- -
-
+

Icinga 2 Documentation

+partial('module/view.phtml', 'doc', array( + 'toc' => $toc, + 'html' => $html +)); ?> \ No newline at end of file diff --git a/modules/doc/application/views/scripts/module/index.phtml b/modules/doc/application/views/scripts/module/index.phtml new file mode 100644 index 000000000..3096e4517 --- /dev/null +++ b/modules/doc/application/views/scripts/module/index.phtml @@ -0,0 +1,6 @@ +

Module documentations

+
    + +
  • + +
\ No newline at end of file diff --git a/modules/doc/application/views/scripts/module/view.phtml b/modules/doc/application/views/scripts/module/view.phtml new file mode 100644 index 000000000..7ba353e31 --- /dev/null +++ b/modules/doc/application/views/scripts/module/view.phtml @@ -0,0 +1,18 @@ + +

Module is not documented.

+ +
+
+ +
+
+ +
+
+ \ No newline at end of file diff --git a/modules/doc/library/Doc/Controller.php b/modules/doc/library/Doc/Controller.php new file mode 100644 index 000000000..da829afe1 --- /dev/null +++ b/modules/doc/library/Doc/Controller.php @@ -0,0 +1,28 @@ +view->html = null; + } else { + $parser = new DocParser(); + list($html, $toc) = $parser->parseDirectory($dir); + $this->view->html = $html; + $this->view->toc = $toc; + } + } +} \ No newline at end of file diff --git a/modules/doc/library/Doc/Parser.php b/modules/doc/library/Doc/DocParser.php similarity index 99% rename from modules/doc/library/Doc/Parser.php rename to modules/doc/library/Doc/DocParser.php index 49f61229b..fd95c053b 100644 --- a/modules/doc/library/Doc/Parser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -14,7 +14,7 @@ use \Parsedown; /** * Parser for documentation written in Markdown */ -class Parser +class DocParser { /** * Retrieve table of contents and HTML converted from all Markdown files in the given directory sorted by filename