-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocgen.php
61 lines (45 loc) · 2 KB
/
docgen.php
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
56
57
58
59
60
61
<?php
#-------------------------------------------------------
# Copyright (C) 2019 The Trustees of Indiana University
# SPDX-License-Identifier: BSD-3-Clause
#-------------------------------------------------------
#----------------------------------------------------------------------
# Script for generating documentation page for transformation rules
# from the REDCap-ETL markdown documentation
#----------------------------------------------------------------------
if (PHP_SAPI !== 'cli') {
die('Not allowed.');
}
require_once 'dev/autoload.php';
$trFile = __DIR__ . '/vendor/iu-redcap/redcap-etl/docs/TransformationRulesGuide.md';
$fileContents = file_get_contents($trFile);
$parsedown = new Parsedown();
$content = $parsedown->text($fileContents);
$content = str_replace('<table>', '<table class="dataTable">', $content);
$content = str_replace('<h1>Transformation Rules</h1>', '<h1>REDCap-ETL Transformation Rules</h1>', $content);
$html = "<?php\n"
. "#-------------------------------------------------------\n"
. "# Copyright (C) 2019 The Trustees of Indiana University\n"
. "# SPDX-License-Identifier: BSD-3-Clause\n"
. "#-------------------------------------------------------\n"
. "\n"
. "require_once APP_PATH_DOCROOT . 'Config/init_global.php';\n"
. "\n"
. "# THIS PAGE WAS AUTO-GENERATED\n"
. "\n"
. '$htmlPage = new HtmlPage();' . "\n"
. '$htmlPage->PrintHeaderExt();' . "\n"
. "?>\n"
. '<div style="text-align:right;float:right;">' . "\n"
. ' <img src="<?php echo APP_PATH_IMAGES . "redcap-logo.png"; ?>" alt="REDCap"/>' . "\n"
. '</div>' . "\n"
. "<?php // phpcs:disable ?>\n"
. $content
. "<?php // phpcs:enable ?>\n"
. "\n"
. '<style type="text/css">#footer { display: block; }</style>' . "\n"
. '<?php' . "\n" . '$htmlPage->PrintFooterExt();' . "\n";
#print "{$contents}\n";
$outputFile = __DIR__ . '/web/transformation_rules.php';
file_put_contents($outputFile, $html);
print "\nOutput stored in {$outputFile}.\n\n";