-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakeDocs.php
More file actions
55 lines (42 loc) · 1.53 KB
/
makeDocs.php
File metadata and controls
55 lines (42 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
const PHPDOC_PHAR_URL = "https://phpdoc.org/phpDocumentor.phar";
const PHPDOC_PHAR_FILENAME = "phpdoc.phar";
if (!file_exists(PHPDOC_PHAR_FILENAME) || (time() - filemtime(PHPDOC_PHAR_FILENAME) > 86400)) {
echo "Downloading updated PHPDoc PHAR...";
file_put_contents(PHPDOC_PHAR_FILENAME, fopen(PHPDOC_PHAR_URL, 'r'));
echo " Complete.\n";
}
echo "Running PHPDoc Analysis...";
exec("php " . PHPDOC_PHAR_FILENAME . " run -d src -t docs/ --template=\"xml\"");
echo " Complete\n";
echo "Removing previous documentation files...";
array_map('unlink', glob('docs/*.md'));
echo " Complete.\n";
echo "Creating Markdown files...\n";
$argv[1] = "docs/structure.xml";
$argv[2] = "docs";
$argv[3] = "--lt";
$argv[4] = "%c";
$argv[5] = "--index";
$argv[6] = "_Sidebar.md";
include "vendor/skayo/phpdoc-md/bin/phpdocmd";
echo " Complete.\n";
// if git diff has no results, exit.
$diff = trim(exec("cd " . __DIR__ . "/docs && git diff --stat"));
if ($diff === "") {
echo "No changes detected in documentation. Exiting.\n";
exit(0);
} else {
echo "Changes detected in documentation. Will commit and push if --push is set.\n";
}
// if --push is set, push the changes.
if (in_array("--push", $argv)) {
echo "Committing and pushing to Repository...";
echo exec("cd " . __DIR__ . "/docs && git add *.md && git commit -m \"Auto-Updated Documentation\"");
echo " Complete.\n";
echo "Pushing to remote repository...";
echo exec("git push");
echo " Complete.\n";
}
// delete the xml file.
unlink("docs/structure.xml");