From 0af1fb2793dee50ef935fc96578266caa96cc881 Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Sat, 19 Aug 2017 22:57:26 +0700 Subject: [PATCH] Reference docs generator --- tools/gendocs.php | 145 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tools/gendocs.php diff --git a/tools/gendocs.php b/tools/gendocs.php new file mode 100644 index 0000000..c293ed0 --- /dev/null +++ b/tools/gendocs.php @@ -0,0 +1,145 @@ + ['constants' => true], + \GraphQL\Executor\Executor::class, + \GraphQL\Executor\ExecutionResult::class, + \GraphQL\Executor\Promise\PromiseAdapter::class, + \GraphQL\Type\Definition\ResolveInfo::class, + \GraphQL\Validator\DocumentValidator::class, + \GraphQL\Error\Error::class => ['constants' => true, 'methods' => true, 'props' => true], + \GraphQL\Error\Warning::class => ['constants' => true, 'methods' => true], + \GraphQL\Error\ClientAware::class, + \GraphQL\Error\Debug::class => ['constants' => true], + \GraphQL\Error\FormattedError::class, + \GraphQL\Server\StandardServer::class, + \GraphQL\Server\ServerConfig::class, + \GraphQL\Server\Helper::class, + \GraphQL\Server\OperationParams::class +]; + +function renderClassMethod(ReflectionMethod $method) { + $args = Utils::map($method->getParameters(), function(ReflectionParameter $p) { + $type = ltrim($p->getType() . " "); + $def = $type . '$' . $p->getName(); + + if ($p->isDefaultValueAvailable()) { + $val = $p->isDefaultValueConstant() ? $p->getDefaultValueConstantName() : $p->getDefaultValue(); + $def .= " = " . (is_array($val) ? '[]' : Utils::printSafe($val)); + } + + return $def; + }); + $argsStr = implode(", ", $args); + if (strlen($argsStr) >= 80) { + $argsStr = "\n " . implode(",\n ", $args) . "\n"; + } + $def = "function {$method->getName()}($argsStr)"; + $def = $method->isStatic() ? "static $def" : $def; + $docBlock = unpadDocblock($method->getDocComment()); + + return <<