<commit_before><?php

/**
 * Generates XML and HTML documents describing configuration.
 * @note PHP 5 only!
 */

/*
TODO:
- make XML format richer (see XMLSerializer_ConfigSchema)
- extend XSLT transformation (see the corresponding XSLT file)
- allow generation of packaged docs that can be easily moved
- multipage documentation
- determine how to multilingualize
*/

// there are several hacks for the configForm.php smoketest
// - load copies (override default schema)
// - file/line server information hack
// - post-processing, base-name change hack

// ---------------------------------------------------------------------------
// Check and configure environment

if (version_compare('5', PHP_VERSION, '>')) exit('Requires PHP 5 or higher.');
error_reporting(E_ALL); // probably not possible to use E_STRICT


// ---------------------------------------------------------------------------
// Include HTML Purifier library

require_once '../library/HTMLPurifier.auto.php';
require_once 'library/ConfigDoc.auto.php';


// ---------------------------------------------------------------------------
// Load copies of HTMLPurifier_ConfigDef and HTMLPurifier

$schema = HTMLPurifier_ConfigSchema::instance();

// ---------------------------------------------------------------------------
// Generate final output using XSLT

// determine stylesheet name
$xsl_stylesheet_name = 'plain'; // use $_GET in the future
$configdoc = new ConfigDoc();
$html_output = $configdoc->generate($schema, $xsl_stylesheet_name);

file_put_contents("$xsl_stylesheet_name.html", $html_output);

// ---------------------------------------------------------------------------
// Output for instant feedback

if (php_sapi_name() != 'cli') {
    echo $html_output;
} else {
    echo 'Files generated successfully.';
}

?><commit_msg>Simplify generate.php variable naming and comments.<commit_after><?php

/**
 * Generates XML and HTML documents describing configuration.
 * @note PHP 5 only!
 */

/*
TODO:
- make XML format richer (see XMLSerializer_ConfigSchema)
- extend XSLT transformation (see the corresponding XSLT file)
- allow generation of packaged docs that can be easily moved
- multipage documentation
- determine how to multilingualize
*/

if (version_compare('5', PHP_VERSION, '>')) exit('Requires PHP 5 or higher.');
error_reporting(E_ALL); // probably not possible to use E_STRICT

// load dual-libraries
require_once '../library/HTMLPurifier.auto.php';
require_once 'library/ConfigDoc.auto.php';

$schema = HTMLPurifier_ConfigSchema::instance();
$style = 'plain'; // use $_GET in the future
$configdoc = new ConfigDoc();
$output = $configdoc->generate($schema, $style);

// write out
file_put_contents("$style.html", $output);

if (php_sapi_name() != 'cli') {
    // output = instant feedback
    echo $output;
} else {
    echo 'Files generated successfully.';
}

?>
{'fraction_non_alphanumeric': 0.2363826815642458, 'fraction_numerical': 0.002094972067039106, 'mean_word_length': 2.4229390681003586, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7183209', 'n_tokens_mistral': 752, 'n_tokens_neox': 726, 'n_words': 237}