[Umts-tools-commits] r648 - umts-tools/trunk
sharky at cartier.jerryweb.org
sharky at cartier.jerryweb.org
Fri Jul 21 23:50:10 BST 2006
Author: sharky
Date: 2006-07-21 23:50:09 +0100 (Fri, 21 Jul 2006)
New Revision: 648
Modified:
umts-tools/trunk/gendocs.php
Log:
refactor POD importer
Modified: umts-tools/trunk/gendocs.php
===================================================================
--- umts-tools/trunk/gendocs.php 2006-07-21 22:49:55 UTC (rev 647)
+++ umts-tools/trunk/gendocs.php 2006-07-21 22:50:09 UTC (rev 648)
@@ -6,12 +6,20 @@
require_once("System.php");
require_once("Barrel.php");
-function genModuleDoc(&$script,$pod,$docdir)
+/** Import a single Perl POD file.
+ *
+ * @param $caller
+ * @param $pod
+ * @param $docdir
+ * @param $docbase
+ * @param $template
+ */
+function importPod(&$caller, $pod, $docdir, $docbase, $template = '')
{
global $globals;
- $barrel =& $script->barrel;
+ $barrel =& $caller->barrel;
- $pid = $barrel->makePath($docdir, $script);
+ $pid = $barrel->makePath($docdir, $caller);
$page = Diogenes_Barrel_Page::fromDb($barrel, $pid);
if (!$page->props['PID']) {
echo "failed to get Page $pid\n";
@@ -23,27 +31,46 @@
if (($tmpdir = System::mktemp('-d')) == false) {
$this->kill("Error : could not create temporary directory!");
}
- $content = shell_exec('cd '.$tmpdir.' && pod2html --htmlroot=FOODOCBASE --infile='.escapeshellarg($pod).' | sed -e "s/FOODOCBASE\(.*\)\.html/\/docs\1\//g" | sed -e "s/<hr \/>//g"');
+ $content = shell_exec("cd $tmpdir && pod2html --htmlroot=FOODOCBASE --infile=".escapeshellarg($pod));
+ $content = str_replace('<hr />', '', $content);
+ $content = preg_replace('/FOODOCBASE(.*).html/', "/$docbase$1/", $content);
# extract title
if (preg_match("/<title>(.*)<\/title>/si", $content, $matches))
{
$page->props['title'] = addslashes($matches[1]);
- $page->props['template'] = "barrel:pod.tpl";
- $page->toDb(0, $script);
+ if ($template)
+ $page->props['template'] = $template;
+ $page->toDb(0, $caller);
}
# strip un-needed info
- $rcs = $script->getRcs();
+ $rcs = $caller->getRcs();
$content = $rcs->importHtmlString($content);
if (preg_match("/<h1><a name=\"synopsis\">.*/si", $content, $matches))
$content = $matches[0];
- $content = shell_exec("echo ".escapeshellarg($content).' | sed -e "s/h1>/h2>/"');
+ $content = str_replace("h1>", "h2>", $content);
$rcs->commit($pid,$globals->htmlfile,$content,"automatic import");
}
+/** Import a set of Perl POD files.
+ *
+ * @param $caller
+ * @param $docarray
+ * @param $docbase
+ * @param $template
+ */
+function importPods(&$caller, $docarray, $docbase, $template = '')
+{
+ foreach ($docarray as $pod => $docdir)
+ {
+ importPod($caller, $pod, $docdir, $docbase, $template);
+ }
+}
+
+
function main()
{
$alias = "umts_tools";
@@ -78,10 +105,7 @@
'src/SMS/PDU/UserData.pm' => 'docs/SMS/PDU/UserData',
'src/UMTS/Terminal.pm' => 'docs/UMTS/Terminal',
);
- foreach ($docs as $pod => $docdir)
- {
- genModuleDoc($script,$pod,$docdir);
- }
+ importPods($script, $docs, "docs", "barrel:pod.tpl");
}
main();
More information about the umts-tools-commits
mailing list