aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/vendor/benchmark/doc/parse.php
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/vendor/benchmark/doc/parse.php')
-rw-r--r--web/src/vendor/benchmark/doc/parse.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/web/src/vendor/benchmark/doc/parse.php b/web/src/vendor/benchmark/doc/parse.php
new file mode 100644
index 00000000..565b78fb
--- /dev/null
+++ b/web/src/vendor/benchmark/doc/parse.php
@@ -0,0 +1,35 @@
+<?php
+
+ // cleanup requested filepath
+ $file = isset($_GET['f']) ? $_GET['f'] : 'benchmark';
+ $file = preg_replace('#(\.*[\/])+#', '', $file);
+ $file .= preg_match('/\.[a-z]+$/', $file) ? '' : '.js';
+
+ // output filename
+ if (isset($_GET['o'])) {
+ $output = $_GET['o'];
+ } else if (isset($_SERVER['argv'][1])) {
+ $output = $_SERVER['argv'][1];
+ } else {
+ $output = basename($file);
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ require('../vendor/docdown/docdown.php');
+
+ // generate Markdown
+ $markdown = docdown(array(
+ 'path' => '../' . $file,
+ 'title' => 'Benchmark.js <sup>v1.0.0</sup>',
+ 'url' => 'https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js'
+ ));
+
+ // save to a .md file
+ file_put_contents($output . '.md', $markdown);
+
+ // print
+ header('Content-Type: text/plain;charset=utf-8');
+ echo $markdown . PHP_EOL;
+
+?>