Rough component documentation is possible now.
authorGunnar Wrobel <p@rdus.de>
Wed, 12 Jan 2011 11:05:45 +0000 (12:05 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 12 Jan 2011 11:05:45 +0000 (12:05 +0100)
components/data/html/index.html [new file with mode: 0644]
components/data/html/install.html [new file with mode: 0644]
components/lib/Components/Pear/Package.php
components/lib/Components/Runner/Document.php [new file with mode: 0644]
components/test/Components/Integration/Components/Module/DocumentTest.php
components/test/Components/StoryTestCase.php
components/test/Components/fixture/templates/html/index.html [new file with mode: 0644]
components/test/Components/fixture/templates/html/install.html [new file with mode: 0644]

diff --git a/components/data/html/index.html b/components/data/html/index.html
new file mode 100644 (file)
index 0000000..b6e985d
--- /dev/null
@@ -0,0 +1,76 @@
+<?php //Need to fix the template type recognition in components. ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+  <title><?php echo 'Component: "' . $package->getName() . '": ' . $package->getSummary(); ?></title>
+
+  <link href="http://dev.horde.org/routes/stylesheets/screen.css" media="screen" rel="stylesheet" type="text/css" />
+  
+</head>
+<body id="contents_home">
+  <div id="wrapper">
+
+  <div id="header" class="clr">
+    <div id="logo" class="left">
+      <span>
+      <img alt="Horde/Routes" src="http://dev.horde.org/routes/images/common/logo.gif" />
+      </span>
+    </div>
+      <ul id="nav" class="right">
+        <li>Home</li>
+        <li><a href="install.html">Install</a></li>
+      </ul>
+  </div>
+
+  <div id="content" class="clr">
+      
+  <h1>Component "<?php echo $package->getName(); ?>"</h1>
+
+  <div id="main">
+    <p class="top">
+      <?php echo $package->getDescription(); ?>
+    </p>
+  </div> <!-- /main -->
+
+  <div id="sidebar">
+  <div class="side_item">
+    <h4>Latest Version</h4>
+    <p><a href="install.html">Version <?php echo $package->getVersion(); ?></a></p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>Developers</h4>
+    <?php foreach ($package->getLeads() as $lead): ?>
+    <p>
+      <a href="mailto:<?php echo $lead['email']; ?>"><?php echo $lead['name'] ?></a>
+    </p>
+    <?php endforeach; ?>
+
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>License</h4>
+    <p>
+      <?php echo $package->getName(); ?> is free software, covered by a standard <a href="<?php $loc = $package->getLicenseLocation(); echo $loc['uri']; ?>"><?php echo $package->getLicense(); ?></a>.
+    </p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+</div>
+
+
+  </div>
+
+  <div id="footer" class="clr">
+    <span class="right">
+      <?php echo $package->getName();?> is part of the <a href="http://www.horde.org">Horde Project</a>.
+    </span>
+  </div>
+
+  
+
+  </div>
+</body>
+</html>
diff --git a/components/data/html/install.html b/components/data/html/install.html
new file mode 100644 (file)
index 0000000..569947e
--- /dev/null
@@ -0,0 +1,78 @@
+<?php //Need to fix the template type recognition in components. ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+  <title><?php echo 'Component: "' . $package->getName() . '": Installation'; ?></title>
+
+  <link href="http://dev.horde.org/routes/stylesheets/screen.css" media="screen" rel="stylesheet" type="text/css" />
+  
+</head>
+<body id="contents_home">
+  <div id="wrapper">
+
+  <div id="header" class="clr">
+    <div id="logo" class="left">
+      <span>
+      <img alt="Horde/Routes" src="http://dev.horde.org/routes/images/common/logo.gif" />
+      </span>
+    </div>
+      <ul id="nav" class="right">
+        <li><a href="index.html">Home</a></li>
+        <li>Install</li>
+      </ul>
+  </div>
+
+  <div id="content" class="clr">
+      
+  <h1>Installation"</h1>
+
+  <div id="main">
+    <p class="top">
+      <pre>
+       <?php echo 'pear install horde/' . $package->getName(); ?>
+      </pre>
+    </p>
+  </div> <!-- /main -->
+
+  <div id="sidebar">
+  <div class="side_item">
+    <h4>Latest Version</h4>
+    <p><a href="install.html">Version <?php echo $package->getVersion(); ?></a></p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>Developers</h4>
+    <?php foreach ($package->getLeads() as $lead): ?>
+    <p>
+      <a href="mailto:<?php echo $lead['email']; ?>"><?php echo $lead['name'] ?></a>
+    </p>
+    <?php endforeach; ?>
+
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>License</h4>
+    <p>
+      <?php echo $package->getName(); ?> is free software, covered by a standard <a href="<?php $loc = $package->getLicenseLocation(); echo $loc['uri']; ?>"><?php echo $package->getLicense(); ?></a>.
+    </p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+</div>
+
+
+  </div>
+
+  <div id="footer" class="clr">
+    <span class="right">
+      <?php echo $package->getName();?> is part of the <a href="http://www.horde.org">Horde Project</a>.
+    </span>
+  </div>
+
+  
+
+  </div>
+</body>
+</html>
index 13ebdd9..7b4fa91 100644 (file)
@@ -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 (file)
index 0000000..824fcde
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+/**
+ * Components_Runner_Document:: generates documentation for a component.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Components
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @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 <wrobel@pardus.de>
+ * @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)
+        );
+
+    }
+}
index 69d9c58..1f5b1e4 100644 (file)
@@ -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
index 5b69167..d93cad3 100644 (file)
@@ -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 (file)
index 0000000..b6e985d
--- /dev/null
@@ -0,0 +1,76 @@
+<?php //Need to fix the template type recognition in components. ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+  <title><?php echo 'Component: "' . $package->getName() . '": ' . $package->getSummary(); ?></title>
+
+  <link href="http://dev.horde.org/routes/stylesheets/screen.css" media="screen" rel="stylesheet" type="text/css" />
+  
+</head>
+<body id="contents_home">
+  <div id="wrapper">
+
+  <div id="header" class="clr">
+    <div id="logo" class="left">
+      <span>
+      <img alt="Horde/Routes" src="http://dev.horde.org/routes/images/common/logo.gif" />
+      </span>
+    </div>
+      <ul id="nav" class="right">
+        <li>Home</li>
+        <li><a href="install.html">Install</a></li>
+      </ul>
+  </div>
+
+  <div id="content" class="clr">
+      
+  <h1>Component "<?php echo $package->getName(); ?>"</h1>
+
+  <div id="main">
+    <p class="top">
+      <?php echo $package->getDescription(); ?>
+    </p>
+  </div> <!-- /main -->
+
+  <div id="sidebar">
+  <div class="side_item">
+    <h4>Latest Version</h4>
+    <p><a href="install.html">Version <?php echo $package->getVersion(); ?></a></p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>Developers</h4>
+    <?php foreach ($package->getLeads() as $lead): ?>
+    <p>
+      <a href="mailto:<?php echo $lead['email']; ?>"><?php echo $lead['name'] ?></a>
+    </p>
+    <?php endforeach; ?>
+
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>License</h4>
+    <p>
+      <?php echo $package->getName(); ?> is free software, covered by a standard <a href="<?php $loc = $package->getLicenseLocation(); echo $loc['uri']; ?>"><?php echo $package->getLicense(); ?></a>.
+    </p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+</div>
+
+
+  </div>
+
+  <div id="footer" class="clr">
+    <span class="right">
+      <?php echo $package->getName();?> is part of the <a href="http://www.horde.org">Horde Project</a>.
+    </span>
+  </div>
+
+  
+
+  </div>
+</body>
+</html>
diff --git a/components/test/Components/fixture/templates/html/install.html b/components/test/Components/fixture/templates/html/install.html
new file mode 100644 (file)
index 0000000..569947e
--- /dev/null
@@ -0,0 +1,78 @@
+<?php //Need to fix the template type recognition in components. ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+  <title><?php echo 'Component: "' . $package->getName() . '": Installation'; ?></title>
+
+  <link href="http://dev.horde.org/routes/stylesheets/screen.css" media="screen" rel="stylesheet" type="text/css" />
+  
+</head>
+<body id="contents_home">
+  <div id="wrapper">
+
+  <div id="header" class="clr">
+    <div id="logo" class="left">
+      <span>
+      <img alt="Horde/Routes" src="http://dev.horde.org/routes/images/common/logo.gif" />
+      </span>
+    </div>
+      <ul id="nav" class="right">
+        <li><a href="index.html">Home</a></li>
+        <li>Install</li>
+      </ul>
+  </div>
+
+  <div id="content" class="clr">
+      
+  <h1>Installation"</h1>
+
+  <div id="main">
+    <p class="top">
+      <pre>
+       <?php echo 'pear install horde/' . $package->getName(); ?>
+      </pre>
+    </p>
+  </div> <!-- /main -->
+
+  <div id="sidebar">
+  <div class="side_item">
+    <h4>Latest Version</h4>
+    <p><a href="install.html">Version <?php echo $package->getVersion(); ?></a></p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>Developers</h4>
+    <?php foreach ($package->getLeads() as $lead): ?>
+    <p>
+      <a href="mailto:<?php echo $lead['email']; ?>"><?php echo $lead['name'] ?></a>
+    </p>
+    <?php endforeach; ?>
+
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+
+  <div class="side_item">
+    <h4>License</h4>
+    <p>
+      <?php echo $package->getName(); ?> is free software, covered by a standard <a href="<?php $loc = $package->getLicenseLocation(); echo $loc['uri']; ?>"><?php echo $package->getLicense(); ?></a>.
+    </p>
+    <div class="side_bottom">&nbsp;</div>
+  </div>
+</div>
+
+
+  </div>
+
+  <div id="footer" class="clr">
+    <span class="right">
+      <?php echo $package->getName();?> is part of the <a href="http://www.horde.org">Horde Project</a>.
+    </span>
+  </div>
+
+  
+
+  </div>
+</body>
+</html>