[pve-devel] r6485 - in pve2-api-doc/trunk: data debian

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Aug 17 12:15:52 CEST 2011


Author: dietmar
Date: 2011-08-17 12:15:52 +0200 (Wed, 17 Aug 2011)
New Revision: 6485

Added:
   pve2-api-doc/trunk/data/pve-man-include.php
Modified:
   pve2-api-doc/trunk/data/Makefile
   pve2-api-doc/trunk/debian/README
   pve2-api-doc/trunk/debian/changelog
Log:
  * added mediawiki plugin for proxmox man pages



Modified: pve2-api-doc/trunk/data/Makefile
===================================================================
--- pve2-api-doc/trunk/data/Makefile	2011-08-17 10:13:30 UTC (rev 6484)
+++ pve2-api-doc/trunk/data/Makefile	2011-08-17 10:15:52 UTC (rev 6485)
@@ -1,6 +1,8 @@
 PREFIX=/usr
 DOCDIR=${PREFIX}/share/pve2-api-doc/
-MANPAGES=pvecm.1.html qm.1.html
+MANPAGES=pvecm.1.html qm.1.html datacenter.cfg.5.html vm.conf.5.html
+PVECLUSTERPODDIR=/usr/share/doc/pve-cluster/pod
+QEMUSERVERPODDIR=/usr/share/doc/qemu-server/pod
 
 all: ${MANPAGES} apidoc.js
 
@@ -12,16 +14,25 @@
 apidoc.js: ${JSSRC}
 	cat ${JSSRC} >$@
 
-%.1.html:
-	$* printmanpod|pod2html --noindex>$@
+pvecm.1.html: ${PVECLUSTERPODDIR}/pvecm.1.pod
+	cat $<|pod2html --noindex > $@
 
+datacenter.cfg.5.html: ${PVECLUSTERPODDIR}/datacenter.cfg.5.pod
+	cat $<|pod2html --noindex > $@
 
+qm.1.html: ${QEMUSERVERPODDIR}/qm.1.pod
+	cat $<|pod2html --noindex > $@
+
+vm.conf.5.html: ${QEMUSERVERPODDIR}/vm.conf.5.pod
+	cat $<|pod2html --noindex > $@
+
 .PHONY: install
 install: apidoc.js apidoc.html apidata.js ${MANPAGES}
 	install -d -m 0755 ${DESTDIR}${DOCDIR}
 	install -D -m 0644 apidoc.html ${DESTDIR}${DOCDIR}/index.html;
 	install -D -m 0644 apidoc.js ${DESTDIR}${DOCDIR}/apidoc.js;
 	install -D -m 0644 apidata.js ${DESTDIR}${DOCDIR}/apidata.js;
+	install -D -m 0644 pve-man-include.php ${DESTDIR}/etc/mediawiki-extensions/extensions-available/pve-man-include.php;
 	install -d -m 0755 ${DESTDIR}${DOCDIR}/man
 	install -m 0644 ${MANPAGES} ${DESTDIR}${DOCDIR}/man
 

Added: pve2-api-doc/trunk/data/pve-man-include.php
===================================================================
--- pve2-api-doc/trunk/data/pve-man-include.php	                        (rev 0)
+++ pve2-api-doc/trunk/data/pve-man-include.php	2011-08-17 10:15:52 UTC (rev 6485)
@@ -0,0 +1,60 @@
+<?php
+
+# see http://www.mediawiki.org/wiki/Manual:Parser_functions
+
+$wgExtensionCredits['parserhook'][] = array(
+        'name' => "PVE Manual Pages",
+        'description' => "Display PVE manual pages", 
+        'author' => "Dietmar Maurer",
+);
+ 
+# Define a setup function
+$wgHooks['ParserFirstCallInit'][] = 'efPvemanParserFunction_Setup';
+# Add a hook to initialise the magic word
+$wgHooks['LanguageGetMagic'][]       = 'efPvemanParserFunction_Magic';
+ 
+function efPvemanParserFunction_Setup( &$parser ) {
+        # Set a function hook associating the "pveman" magic word with our function
+ $parser->setFunctionHook( 'pveman', 'efPvemanParserFunction_Render' );
+        return true;
+}
+ 
+function efPvemanParserFunction_Magic( &$magicWords, $langCode ) {
+        # Add the magic word
+        # The first array element is whether to be case sensitive, in this case (0) it is not case sensitive, 1 would be sensitive
+        # All remaining elements are synonyms for our parser function
+        $magicWords['pveman'] = array( 0, 'pveman' );
+        # unless we return true, other parser functions extensions won't get loaded.
+        return true;
+}
+ 
+function efPvemanParserFunction_Render( $parser, $param1 = '', $param2 = '' ) {
+        # The parser function itself
+        # The input parameters are wikitext with templates expanded
+        # The output should be wikitext too
+
+	$parser->disableCache();
+
+	$allowed = array(
+		'pvecm.1.html' => 1, 
+		'qm.1.html' => 1, 
+		'datacenter.cfg.5.html' => 1,
+		'vm.conf.5.html' => 1,
+		);
+
+	if (!$allowed[$param1]) {
+		die ("no such manual page");
+	}
+
+	$output = file_get_contents("/usr/share/pve2-api-doc/man/$param1");
+
+	$output = preg_replace('|^.*(<h1><a name="name">NAME</a></h1>)|s', '\1', $output);
+	$output = preg_replace('|</body>.*$|s', '', $output);
+	$output = preg_replace('|<p>\s*\n\s*</p>\n?|m', '', $output);
+	$output = preg_replace('|<hr\s*/>\n?|', '', $output);
+	$output = preg_replace('|^\n|m', '', $output);
+
+	return array( $output, 'noparse' => true, 'isHTML' => true );
+}
+
+?>

Modified: pve2-api-doc/trunk/debian/README
===================================================================
--- pve2-api-doc/trunk/debian/README	2011-08-17 10:13:30 UTC (rev 6484)
+++ pve2-api-doc/trunk/debian/README	2011-08-17 10:15:52 UTC (rev 6485)
@@ -3,13 +3,17 @@
 # a2ensite pve2-api-doc.conf
 # /etc/init.d/apache2 reload
 
+To enable mediawiki 'pveman' plugin
+# mwenext pve-man-include.php
+
 Now you should be able to access the documentation at:
 
-# API docu browser
+* API docu browser
 http://your-server/pve2-api-doc
 
-# Manual pages
+* Manual pages
 http://your-server/pve2-api-doc/man/
 
-
-
+* Mediawiki Plugin
+{{#pveman:qm.1.html}}
+[[Category:Manual Pages]]

Modified: pve2-api-doc/trunk/debian/changelog
===================================================================
--- pve2-api-doc/trunk/debian/changelog	2011-08-17 10:13:30 UTC (rev 6484)
+++ pve2-api-doc/trunk/debian/changelog	2011-08-17 10:15:52 UTC (rev 6485)
@@ -1,6 +1,8 @@
 pve2-api-doc (2.0-4) unstable; urgency=low
 
   * update to pve-manager 2.0-4
+  
+  * added mediawiki plugin for proxmox man pages
 
  -- Proxmox Support Team <support at proxmox.com>  Wed, 10 Aug 2011 11:27:43 +0200
 




More information about the pve-devel mailing list