Rename files & symbols

This commit is contained in:
Denis Arh
2019-04-29 18:51:18 +02:00
parent d5c5c9ffae
commit 010a1351ea
137 changed files with 231 additions and 896 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
$cleanUp = function($contents) {
$lines = array_map("rtrim", explode("\n", $contents));
$empty = true;
foreach ($lines as $k => $v) {
if ($v === "") {
if ($empty) {
unset($lines[$k]);
}
$empty = true;
continue;
}
$empty = false;
}
$contents = implode("\n", $lines);
$contents = str_replace("`\n|", "` |", $contents);
$contents = preg_replace("/^# /sm", "\n\n\n# ", $contents);
return trim($contents);
};
foreach ($apis as $k => $api) {
$entrypoint = $api['entrypoint'];
$filename_md = $api['dirname'] . $entrypoint . "/index.md";
if (file_exists($filename_md)) {
$api['description'] = file_get_contents($filename_md);
}
foreach ($api['apis'] as $key => $call) {
$name = $call['name'];
$filename_md = $api['dirname'] . $entrypoint . "/" . $name . ".md";
if (file_exists($filename_md)) {
$call['description'] = file_get_contents($filename_md);
}
$api['apis'][$key] = $call;
}
$apis[$k] = $api;
}
$tpl->load("README.tpl");
$tpl->assign("apis", $apis);
file_put_contents($dirname . "README.md", $cleanUp($tpl->get()));
echo $dirname . "README.md\n";
+29
View File
@@ -0,0 +1,29 @@
<?php
$templates = array(
"http_handlers_inline.tpl" => function($name, $api) {
return strtolower($name) . ".go";
},
);
foreach ($templates as $template => $fn)
foreach ($apis as $api) {
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . $fn($name, $api);
$tpl->load($template);
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("apis", $apis);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = imports($api);
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
file_put_contents($filename, $contents);
echo $filename . "\n";
}
+23
View File
@@ -0,0 +1,23 @@
<?php
foreach ($apis as $api) {
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . str_replace("..", ".", strtolower($name) . ".go");
$tpl->load("http_.tpl");
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = imports($api);
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
if (!file_exists($filename)) {
file_put_contents($filename, $contents);
echo $filename . "\n";
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
$templates = array(
"http_request_inline.tpl" => function($name, $api) {
return strtolower($name) . ".go";
},
);
foreach ($templates as $template => $fn)
foreach ($apis as $api) {
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . $fn($name, $api);
$tpl->load($template);
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("apis", $apis);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = imports($api);
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
file_put_contents($filename, $contents);
echo $filename . "\n";
}
+33
View File
@@ -0,0 +1,33 @@
<?php
$templates = array(
"http_structs.tpl" => function($name, $api) {
return strtolower($name) . ".go";
},
);
$templates = array();
foreach ($templates as $template => $fn)
foreach ($apis as $api) {
if (is_array($api['struct'])) {
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . $fn($name, $api);
$tpl->load($template);
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("apis", $apis);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = imports($api);
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
file_put_contents($filename, $contents);
echo $filename . "\n";
}
}