Ignore tags files (from exuberant ctags)
[htmlpurifier.git] / configdoc / generate.php
bloba8f50c5ee3c802f8f1064a9a02133ebf912ef4e5
1 <?php
3 /**
4 * Generates XML and HTML documents describing configuration.
5 * @note PHP 5.2+ only!
6 */
8 /*
9 TODO:
10 - make XML format richer
11 - extend XSLT transformation (see the corresponding XSLT file)
12 - allow generation of packaged docs that can be easily moved
13 - multipage documentation
14 - determine how to multilingualize
15 - add blurbs to ToC
18 if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
19 error_reporting(E_ALL | E_STRICT);
21 chdir(dirname(__FILE__));
23 // load dual-libraries
24 require_once '../extras/HTMLPurifierExtras.auto.php';
25 require_once '../library/HTMLPurifier.auto.php';
27 // setup HTML Purifier singleton
28 HTMLPurifier::getInstance(array(
29 'AutoFormat.PurifierLinkify' => true
30 ));
32 $interchange = HTMLPurifier_ConfigSchema_InterchangeBuilder::buildFromDirectory();
33 $interchange->validate();
35 $style = 'plain'; // use $_GET in the future, careful to validate!
36 $configdoc_xml = 'configdoc.xml';
38 $xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
39 $xml_builder->openURI($configdoc_xml);
40 $xml_builder->build($interchange);
41 unset($xml_builder); // free handle
43 $xslt = new ConfigDoc_HTMLXSLTProcessor();
44 $xslt->importStylesheet(dirname(__FILE__) . "/styles/$style.xsl");
45 $output = $xslt->transformToHTML($configdoc_xml);
47 if (!$output) {
48 echo "Error in generating files\n";
49 exit(1);
52 // write out
53 file_put_contents("$style.html", $output);
55 if (php_sapi_name() != 'cli') {
56 // output (instant feedback if it's a browser)
57 echo $output;
58 } else {
59 echo 'Files generated successfully.';
62 // vim: et sw=4 sts=4