Skip to content

Commit

Permalink
docs: document methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricziel committed Jul 29, 2024
1 parent 2d02f0f commit 99a936b
Show file tree
Hide file tree
Showing 2 changed files with 3,012 additions and 316 deletions.
32 changes: 29 additions & 3 deletions .regen-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,40 @@

require_once __DIR__.'/vendor/autoload.php';

function underscoreToCamelCase($string, $capitalizeFirstCharacter = false)
{

$str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));

if (!$capitalizeFirstCharacter) {
$str[0] = strtolower($str[0]);
}

return $str;
}

$methods = get_class_methods(Client::class);
$readme = file_get_contents('./.github/README.md');

$json = json_decode(file_get_contents('openapi.json'), true);

$doc = '';

foreach ($methods as $method) {
echo "$method\n";
$doc .= "$method\n";
foreach ($json['paths'] as $pathName => $path) {
foreach ($path as $httpMethod => $method) {
$methodName = underscoreToCamelCase($method['operationId']);

$doc .= '### ' . $method['operationId'] . ' - ' . "$httpMethod $pathName\n";
$doc .= "\n";
$doc .= $method['description'] ?? '';
$doc .= "\n\n";
$doc .= '```php' . "\n";
$doc .= '$client = \\CedricZiel\\Baserow\\Client::create();' . "\n";
$doc .= '$client->' . "{$methodName}();\n";
$doc .= '```' . "\n";
$doc .= "\n";
echo $method['operationId'] . "\n";
}
}

file_put_contents('README.md', str_replace('### docs ###', $doc, $readme));
Loading

0 comments on commit 99a936b

Please sign in to comment.