Documentation: add getFunctionReturnTypeDescription virtual method.

GitOrigin-RevId: 1e17abb58e340ef03528eb17643f9d09bb388747
This commit is contained in:
levlam 2019-03-25 01:18:25 +03:00
parent 0db8f14014
commit bdfabde80a
4 changed files with 26 additions and 11 deletions

View File

@ -158,13 +158,16 @@ EOT
); );
} }
protected function addClassDocumentation($class_name, $base_class_name, $description, $return_type) protected function getFunctionReturnTypeDescription($return_type)
{ {
$return_type_description = $return_type ? "\r\n/// <para>Returns <see cref=\"".substr($return_type, 0, -1).'"/>.</para>' : ''; return "\r\n/// <para>Returns <see cref=\"".substr($return_type, 0, -1).'"/>.</para>';
}
protected function addClassDocumentation($class_name, $base_class_name, $description)
{
$this->addDocumentation("public ref class $class_name sealed : $base_class_name {", <<<EOT $this->addDocumentation("public ref class $class_name sealed : $base_class_name {", <<<EOT
/// <summary> /// <summary>
/// $description$return_type_description /// $description
/// </summary> /// </summary>
EOT EOT
); );

View File

@ -321,13 +321,16 @@ EOT
); );
} }
protected function addClassDocumentation($class_name, $base_class_name, $description, $return_type) protected function getFunctionReturnTypeDescription($return_type)
{ {
$return_type_description = $return_type ? PHP_EOL.' *'.PHP_EOL." * Returns $return_type." : ''; return PHP_EOL.' *'.PHP_EOL." * Returns $return_type.";
}
protected function addClassDocumentation($class_name, $base_class_name, $description)
{
$this->addDocumentation("class $class_name final : public $base_class_name {", <<<EOT $this->addDocumentation("class $class_name final : public $base_class_name {", <<<EOT
/** /**
* $description$return_type_description * $description
*/ */
EOT EOT
); );

View File

@ -190,13 +190,16 @@ EOT
); );
} }
protected function addClassDocumentation($class_name, $base_class_name, $description, $return_type) protected function getFunctionReturnTypeDescription($return_type)
{ {
$return_type_description = $return_type ? PHP_EOL.' *'.PHP_EOL." * <p> Returns {@link $return_type $return_type} </p>" : ''; return PHP_EOL.' *'.PHP_EOL." * <p> Returns {@link $return_type $return_type} </p>";
}
protected function addClassDocumentation($class_name, $base_class_name, $description)
{
$this->addDocumentation(" public static class $class_name extends $base_class_name {", <<<EOT $this->addDocumentation(" public static class $class_name extends $base_class_name {", <<<EOT
/** /**
* $description$return_type_description * $description
*/ */
EOT EOT
); );

View File

@ -87,7 +87,9 @@ abstract class TlDocumentationGenerator
abstract protected function addAbstractClassDocumentation($class_name, $value); abstract protected function addAbstractClassDocumentation($class_name, $value);
abstract protected function addClassDocumentation($class_name, $base_class_name, $description, $return_type); abstract protected function getFunctionReturnTypeDescription($return_type);
abstract protected function addClassDocumentation($class_name, $base_class_name, $description);
abstract protected function addFieldDocumentation($class_name, $field_name, $type_name, $field_info, $may_be_null); abstract protected function addFieldDocumentation($class_name, $field_name, $type_name, $field_info, $may_be_null);
@ -233,7 +235,11 @@ abstract class TlDocumentationGenerator
} }
$base_class_name = $current_class ?: $this->getBaseClassName($is_function); $base_class_name = $current_class ?: $this->getBaseClassName($is_function);
$this->addClassDocumentation($class_name, $base_class_name, $info['description'], $is_function ? $this->getTypeName($type) : ''); $class_description = $info['description'];
if ($is_function) {
$class_description .= $this->getFunctionReturnTypeDescription($this->getTypeName($type));
}
$this->addClassDocumentation($class_name, $base_class_name, $class_description);
foreach ($known_fields as $name => $type) { foreach ($known_fields as $name => $type) {
$may_be_null = stripos($info[$name], 'may be null') !== false; $may_be_null = stripos($info[$name], 'may be null') !== false;