mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Make doc/parse.php read the version from package.json. [ci skip]
This commit is contained in:
@@ -1,36 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// cleanup requested filepath
|
// cleanup requested file path
|
||||||
$file = isset($_GET['f']) ? $_GET['f'] : 'lodash';
|
$filePath = isset($_GET['f']) ? $_GET['f'] : 'lodash';
|
||||||
$file = preg_replace('#(\.*[\/])+#', '', $file);
|
$filePath = preg_replace('#(\.*[\/])+#', '', $filePath);
|
||||||
$file .= preg_match('/\.[a-z]+$/', $file) ? '' : '.js';
|
$filePath .= preg_match('/\.[a-z]+$/', $filePath) ? '' : '.js';
|
||||||
|
|
||||||
// output filename
|
// output filename
|
||||||
if (isset($_GET['o'])) {
|
if (isset($_GET['o'])) {
|
||||||
$output = $_GET['o'];
|
$outputName = $_GET['o'];
|
||||||
} else if (isset($_SERVER['argv'][1])) {
|
} else if (isset($_SERVER['argv'][1])) {
|
||||||
$output = $_SERVER['argv'][1];
|
$outputName = $_SERVER['argv'][1];
|
||||||
} else {
|
} else {
|
||||||
$output = basename($file);
|
$outputName = basename($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
require('../vendor/docdown/docdown.php');
|
require('../vendor/docdown/docdown.php');
|
||||||
|
|
||||||
|
// get package version
|
||||||
|
$version = json_decode(file_get_contents('../package.json'))->version;
|
||||||
|
|
||||||
// generate Markdown
|
// generate Markdown
|
||||||
$markdown = docdown(array(
|
$markdown = docdown(array(
|
||||||
'path' => '../' . $file,
|
'path' => '../' . $filePath,
|
||||||
'title' => 'Lo-Dash <span>v2.2.0</span>',
|
'title' => 'Lo-Dash <span>v' . $version . '</span>',
|
||||||
'toc' => 'categories',
|
'toc' => 'categories',
|
||||||
'url' => 'https://github.com/lodash/lodash/blob/master/lodash.js'
|
'url' => 'https://github.com/lodash/lodash/blob/master/lodash.js'
|
||||||
));
|
));
|
||||||
|
|
||||||
// save to a .md file
|
// save to a `.md` file
|
||||||
file_put_contents($output . '.md', $markdown);
|
file_put_contents($outputName . '.md', $markdown);
|
||||||
|
|
||||||
// print
|
// print
|
||||||
header('Content-Type: text/plain;charset=utf-8');
|
header('Content-Type: text/plain;charset=utf-8');
|
||||||
echo $markdown . PHP_EOL;
|
echo $markdown . PHP_EOL;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user