Debian Codegraph @

docpages/makedocs.php

raw symbols SCIP
1 <?php
2
3 /* Sanity checks */
4 if (!file_exists(getenv("HOME") . "/dpp-web")) {
5 echo "\n*** YOU PROBABLY SHOULDN'T BE RUNNING THIS!!! ***\n\n";
6 echo "\nClone https://github.com/brainboxdotcc/dpp-web.git to " . getenv("HOME") . "/dpp-web before running this script.\n";
7 echo "\nIMPORTANT: This script is for documentation maintainers to auto update the website. You do NOT need to run this script\nto generate offline documentation. Instead, just run `doxygen` from the repository root.\n\n";
8 exit(0);
9 }
10
11 /* Make drop down list of versions from the tags */
12 echo "Make version drop down select\n";
13 system("git fetch -av --tags");
14 $tags = explode("\n", shell_exec("git tag"));
15 for ($n = 0; $n < count($tags); ++$n) {
16 $tags[$n] = preg_replace('/^v/', '', $tags[$n]);
17 }
18 natsort($tags);
19 $tags = array_reverse($tags);
20
21 $opts = "<option value='/'>master</option>";
22 foreach ($tags as $tag) {
23 if ($tag != '') {
24 $opts .= "<option value='/$tag/'>$tag</option>";
25 }
26 }
27
28 $taglist = '';
29 foreach ($tags as $tag) {
30 if ($tag != '') {
31 $tag2 = str_replace("v", "", $tag);
32 $taglist .= "<a href='/".$tag2."/'>D++ Library version $tag</a>";
33 }
34 }
35
36 $template = file_get_contents("header.template.html");
37 $header = str_replace("##VERSION_OPTIONS##", $opts, $template);
38
39 $footer = file_get_contents("footer.template.html");
40 $footer = str_replace("###PREV###", $taglist, $footer);
41
42 file_put_contents("header.html", $header);
43 file_put_contents("footer.html", $footer);
44
45 echo "Generate `master` docs\n";
46
47 chdir("..");
48 shell_exec("/usr/local/bin/doxygen");
49 system("cp -r docs/* " . getenv("HOME") . "/dpp-web/");
50
51 /* Create old version docs */
52 chdir(getenv("HOME") . "/D++");
53 system("rm -rf " . sys_get_temp_dir() . "/dpp-old");
54 mkdir(sys_get_temp_dir() . "/dpp-old");
55 chdir(sys_get_temp_dir() . "/dpp-old");
56 foreach ($tags as $tag) {
57 $orig_tag = $tag;
58 $tag = preg_replace("/^v/", "", $tag);
59 if (!empty($tag)) {
60 print "Generate $orig_tag docs (https://dpp.dev/$tag/)\n";
61 system("git clone --recursive https://github.com/brainboxdotcc/DPP.git");
62 chdir("DPP");
63 system("git checkout tags/$orig_tag");
64 /* Older versions of the docs before 9.0.7 don't have these. Force them into the tree so old versions get current styling */
65 system("cp -rv " . getenv("HOME") . "/D++/docpages/images docpages");
66 system("cp -rv " . getenv("HOME") . "/D++/docpages/style.css docpages/style.css");
67 system("cp -rv " . getenv("HOME") . "/D++/docpages/*.html docpages/");
68 system("cp -rv " . getenv("HOME") . "/D++/doxygen-awesome-css doxygen-awesome-css");
69 /* Always make sure that the version is using the latest doxygen,
70 * but rewrite version number (project number)
71 */
72 $doxy = file_get_contents(getenv("HOME") . "/D++/Doxyfile");
73 $doxy = str_replace("PROJECT_NUMBER =", "PROJECT_NUMBER = $tag", $doxy);
74 file_put_contents("Doxyfile", $doxy);
75 /* Rewrite selected version number so that each page has a new default selected in the drop down */
76 $hdr = file_get_contents(getenv("HOME") . "/D++/docpages/header.html");
77 $hdr = str_replace("option value='/$tag/'", "option selected value='/$tag/'", $hdr);
78 /* Rewrite version info in header */
79 file_put_contents("docpages/header.html", $hdr);
80 shell_exec("/usr/local/bin/doxygen");
81 mkdir(getenv("HOME") . "/dpp-web/$tag");
82 system("cp -r docs/* " . getenv("HOME") . "/dpp-web/$tag");
83 chdir("..");
84 system("rm -rf " . sys_get_temp_dir() . "/dpp-old/DPP");
85 }
86 }
87
88 /* Commit and push everything to the github pages repo */
89 echo "Commit and push\n";
90 chdir(getenv("HOME") . "/dpp-web");
91 system("git add -A");
92 system("git commit -a -m \"automatic commit\"");
93 system("git push");
94