From: Gunnar Wrobel
Date: Wed, 12 Jan 2011 11:05:45 +0000 (+0100)
Subject: Rough component documentation is possible now.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5e98a19ff7e635c7c32b849f9663b205d09f2efa;p=horde.git
Rough component documentation is possible now.
---
diff --git a/components/data/html/index.html b/components/data/html/index.html
new file mode 100644
index 000000000..b6e985de7
--- /dev/null
+++ b/components/data/html/index.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+ getName() . '": ' . $package->getSummary(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
Component "getName(); ?>"
+
+
+
+ getDescription(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/data/html/install.html b/components/data/html/install.html
new file mode 100644
index 000000000..569947ec7
--- /dev/null
+++ b/components/data/html/install.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+ getName() . '": Installation'; ?>
+
+
+
+
+
+
+
+
+
+
+
+
Installation"
+
+
+
+
+ getName(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/lib/Components/Pear/Package.php b/components/lib/Components/Pear/Package.php
index 13ebdd956..7b4fa91f0 100644
--- a/components/lib/Components/Pear/Package.php
+++ b/components/lib/Components/Pear/Package.php
@@ -269,6 +269,16 @@ class Components_Pear_Package
}
/**
+ * Return the license location for this package.
+ *
+ * @return string The package license location.
+ */
+ public function getLicenseLocation()
+ {
+ return $this->_getPackageFile()->getLicenseLocation();
+ }
+
+ /**
* Return the summary for this package.
*
* @return string The package summary.
@@ -279,6 +289,26 @@ class Components_Pear_Package
}
/**
+ * Return the leads for this package.
+ *
+ * @return string The package leads.
+ */
+ public function getLeads()
+ {
+ return $this->_getPackageFile()->getLeads();
+ }
+
+ /**
+ * Return the maintainers for this package.
+ *
+ * @return string The package maintainers.
+ */
+ public function getMaintainers()
+ {
+ return $this->_getPackageFile()->getMaintainers();
+ }
+
+ /**
* Return the list of files that should be installed for this package.
*
* @return array The file list.
diff --git a/components/lib/Components/Runner/Document.php b/components/lib/Components/Runner/Document.php
new file mode 100644
index 000000000..824fcde4b
--- /dev/null
+++ b/components/lib/Components/Runner/Document.php
@@ -0,0 +1,95 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Components_Runner_Document:: generates documentation for a component.
+ *
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Runner_Document
+{
+ /**
+ * The configuration for the current job.
+ *
+ * @var Components_Config
+ */
+ private $_config;
+
+ /**
+ * The application configuration.
+ *
+ * @var Components_Config_Application
+ */
+ private $_config_application;
+
+ /**
+ * The factory for PEAR dependencies.
+ *
+ * @var Components_Pear_Factory
+ */
+ private $_factory;
+
+ /**
+ * Constructor.
+ *
+ * @param Components_Config $config The configuration for the current job.
+ * @param Components_Config_Application $cfgapp The application
+ * configuration.
+ * @param Components_Pear_Factory $factory The factory for PEAR
+ * dependencies.
+ */
+ public function __construct(
+ Components_Config $config,
+ Components_Config_Application $cfgapp,
+ Components_Pear_Factory $factory
+ ) {
+ $this->_config = $config;
+ $this->_config_application = $cfgapp;
+ $this->_factory = $factory;
+ }
+
+ public function run()
+ {
+ $options = $this->_config->getOptions();
+ $arguments = $this->_config->getArguments();
+
+ if (!isset($options['pearrc'])) {
+ $package = $this->_factory->createPackageForDefaultLocation(
+ $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'
+ );
+ } else {
+ $package = $this->_factory->createPackageForInstallLocation(
+ $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml',
+ $options['pearrc']
+ );
+ }
+
+ $build_template = new Components_Helper_Templates_Directory(
+ $this->_config_application->getTemplateDirectory(),
+ $options['document']
+ );
+ $build_template->write(
+ array('package' => $package)
+ );
+
+ }
+}
diff --git a/components/test/Components/Integration/Components/Module/DocumentTest.php b/components/test/Components/Integration/Components/Module/DocumentTest.php
index 69d9c58f5..1f5b1e4ee 100644
--- a/components/test/Components/Integration/Components/Module/DocumentTest.php
+++ b/components/test/Components/Integration/Components/Module/DocumentTest.php
@@ -44,4 +44,14 @@ extends Components_StoryTestCase
->when('calling the package with the help option')
->then('the help will contain the option', '-O\s*DOCUMENT,\s*--document=DOCUMENT');
}
+
+ /**
+ * @scenario
+ */
+ public function theTheOOptionGeneratesHtmlDocumentation()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the document option and a path to a Horde framework component')
+ ->then('the package documentation will be generated at the indicated location');
+ }
}
\ No newline at end of file
diff --git a/components/test/Components/StoryTestCase.php b/components/test/Components/StoryTestCase.php
index 5b69167c1..d93cad3db 100644
--- a/components/test/Components/StoryTestCase.php
+++ b/components/test/Components/StoryTestCase.php
@@ -300,6 +300,15 @@ extends PHPUnit_Extensions_Story_TestCase
);
$world['output'] = $this->_callUnstrictComponents();
break;
+ case 'calling the package with the document option and a path to a Horde framework component':
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--templatedir=' . dirname(__FILE__) . '/fixture/templates/html',
+ '--document=' . $this->_getTemporaryDirectory(),
+ dirname(__FILE__) . '/fixture/framework/Install'
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
default:
return $this->notImplemented($action);
}
@@ -615,6 +624,20 @@ extends PHPUnit_Extensions_Story_TestCase
)
);
break;
+ case 'the package documentation will be generated at the indicated location':
+ $this->assertTrue(
+ file_exists(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'index.html'
+ )
+ );
+ $this->assertTrue(
+ file_exists(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'install.html'
+ )
+ );
+ break;
case 'the output should indicate an invalid package.xml':
$this->assertContains(
'PEAR_Packagefile_v2::toTgz: invalid package.xml',
diff --git a/components/test/Components/fixture/templates/html/index.html b/components/test/Components/fixture/templates/html/index.html
new file mode 100644
index 000000000..b6e985de7
--- /dev/null
+++ b/components/test/Components/fixture/templates/html/index.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+ getName() . '": ' . $package->getSummary(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
Component "getName(); ?>"
+
+
+
+ getDescription(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/test/Components/fixture/templates/html/install.html b/components/test/Components/fixture/templates/html/install.html
new file mode 100644
index 000000000..569947ec7
--- /dev/null
+++ b/components/test/Components/fixture/templates/html/install.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+ getName() . '": Installation'; ?>
+
+
+
+
+
+
+
+
+
+
+
+
Installation"
+
+
+
+
+ getName(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+