wip revive and split off doc generatin toolchain
[plcapi.git] / pakefile.php
index 30acead..956cc66 100644 (file)
@@ -3,7 +3,7 @@
  * Makefile for phpxmlrpc library.
  * To be used with the Pake tool: https://github.com/indeyets/pake/wiki
  *
- * @copyright (c) 2015 G. Giunta
+ * @copyright (c) 2015-2021 G. Giunta
  *
  * @todo !important allow user to specify location of docbook xslt instead of the one installed via composer
  */
@@ -22,7 +22,7 @@ class Builder
     );
     protected static $options = array(
         'repo' => 'https://github.com/gggeek/phpxmlrpc',
-        'branch' => 'php53'
+        'branch' => 'master'
     );
 
     public static function libVersion()
@@ -42,6 +42,11 @@ class Builder
         return self::buildDir().'/workspace';
     }
 
+    public static function toolsDir()
+    {
+        return self::buildDir().'/tools';
+    }
+
     /// most likely things will break if this one is moved outside of BuildDir
     public static function distDir()
     {
@@ -78,11 +83,19 @@ class Builder
         //pake_echo('---'.self::$libVersion.'---');
     }
 
+    /**
+     * @param string $name
+     * @return string
+     */
     public static function tool($name)
     {
         return self::$tools[$name];
     }
 
+    /**
+     * @param string $name
+     * @return string
+     */
     public static function option($name)
     {
         return self::$options[$name];
@@ -96,7 +109,6 @@ class Builder
      */
     public static function applyXslt($inFile, $xssFile, $outFileOrDir)
     {
-
         if (!file_exists($inFile)) {
             throw new \Exception("File $inFile cannot be found");
         }
@@ -248,9 +260,31 @@ function run_doc($task=null, $args=array(), $cliOpts=array())
 
     // API docs
 
+    /// @todo sami is anbandonware, whereas phpdocumentor is not. switch back to phpdocumentor
+
     // from phpdoc comments using phpdocumentor
+    //$cmd = Builder::tool('php');
+    //pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/phpdoc run -d ".Builder::workspaceDir().'/src'." -t ".Builder::workspaceDir().'/doc/api --title PHP-XMLRPC');
+
+    // from phpdoc comments using Sami
+    $samiConfig = <<<EOT
+<?php
+    \$iterator = Symfony\Component\Finder\Finder::create()
+      ->files()
+      ->exclude('debugger')
+      ->exclude('demo')
+      ->exclude('doc')
+      ->exclude('tests')
+      ->in('./build/workspace');
+    return new Sami\Sami(\$iterator, array(
+        'title' => 'PHP-XMLRPC',
+        'build_dir' => 'build/workspace/doc/api',
+        'cache_dir' => 'build/cache',
+    ));
+EOT;
+    file_put_contents('build/sami_config.php', $samiConfig);
     $cmd = Builder::tool('php');
-    pake_sh("$cmd vendor/phpdocumentor/phpdocumentor/bin/phpdoc run -d ".Builder::workspaceDir().'/src'." -t ".Builder::workspaceDir().'/doc/api --title PHP-XMLRPC');
+    pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/sami.php update -vvv build/sami_config.php");
 
     // User Manual
 
@@ -261,7 +295,7 @@ function run_doc($task=null, $args=array(), $cliOpts=array())
     // then docbook from asciidoc
     /// @todo create phpxmlrpc_manual.xml with the good version number
     /// @todo create phpxmlrpc_manual.xml with the date set to the one of last commit (or today?)
-    pake_sh("$cmd -d book  -b docbook $docDir/manual/phpxmlrpc_manual.adoc");
+    pake_sh("$cmd -d book -b docbook $docDir/manual/phpxmlrpc_manual.adoc");
 
     # Other tools for docbook...
     #