X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fbin%2Fbuild-manual;h=ece227817a7e35195b55b5f4c2fa477c9f6cc9bf;hp=20fbfa4c21b1056f23f9170935d362733efa9ab1;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/psy/psysh/bin/build-manual b/vendor/psy/psysh/bin/build-manual index 20fbfa4c2..ece227817 100755 --- a/vendor/psy/psysh/bin/build-manual +++ b/vendor/psy/psysh/bin/build-manual @@ -53,8 +53,7 @@ function htmlwrap($text, $width = null) case '>': $inTag = false; - - default: + break; } if ($inTag) { @@ -198,23 +197,8 @@ function find_type($xml, $paramName) } } -$docs = array(); -foreach (glob($argv[1] . '/*/*/*.xml') as $function) { - $funcname = basename($function); - if ($funcname === 'main.xml' || strpos($funcname, 'entities.') === 0) { - continue; - } - - $xmlstr = str_replace('&', '&', file_get_contents($function)); - - $xml = new DOMDocument(); - $xml->preserveWhiteSpace = false; - - if (!@$xml->loadXml($xmlstr)) { - echo "XML Parse Error: $function\n"; - continue; - } - +function format_function_doc($xml) +{ $doc = array(); $refsect1s = $xml->getElementsByTagName('refsect1'); foreach ($refsect1s as $refsect1) { @@ -266,9 +250,52 @@ foreach (glob($argv[1] . '/*/*/*.xml') as $function) { $doc['description'] = trim($desc); } - $formatted = format_doc($doc); + $ids = array(); foreach ($xml->getElementsByTagName('refname') as $ref) { - $docs[$ref->textContent] = $formatted; + $ids[] = $ref->textContent; + } + + return array($ids, format_doc($doc)); +} + +function format_class_doc($xml) +{ + // @todo implement this + return array(array(), null); +} + +$dir = new RecursiveDirectoryIterator($argv[1]); +$filter = new RecursiveCallbackFilterIterator($dir, function ($current, $key, $iterator) { + return $current->getFilename()[0] !== '.' && + ($current->isDir() || $current->getExtension() === 'xml') && + strpos($current->getFilename(), 'entities.') !== 0 && + $current->getFilename() !== 'pdo_4d'; // Temporarily blacklist this one, the docs are weird. +}); +$iterator = new RecursiveIteratorIterator($filter); + +$docs = array(); +foreach ($iterator as $file) { + $xmlstr = str_replace('&', '&', file_get_contents($file)); + + $xml = new DOMDocument(); + $xml->preserveWhiteSpace = false; + + if (!@$xml->loadXml($xmlstr)) { + echo "XML Parse Error: $file\n"; + continue; + } + + if ($xml->getElementsByTagName('refentry')->length !== 0) { + list($ids, $doc) = format_function_doc($xml); + } elseif ($xml->getElementsByTagName('classref')->length !== 0) { + list($ids, $doc) = format_class_doc($xml); + } else { + $ids = array(); + $doc = null; + } + + foreach ($ids as $id) { + $docs[$id] = $doc; } }