Fix documentation

This commit is contained in:
Andrea Cavalli 2021-12-30 02:04:04 +01:00
parent 71b72b8450
commit db84af1db5
4 changed files with 10 additions and 8 deletions

View File

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

View File

@ -389,7 +389,7 @@ EOT
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* Returns $return_type.";
}
protected function addClassDocumentation($class_name, $base_class_name, $description)
protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description)
{
$this->addDocumentation("class $class_name final : public $base_class_name {", <<<EOT
/**

View File

@ -104,7 +104,7 @@ class JavadocTlDocumentationGenerator extends TlDocumentationGenerator
protected function extractClassName($line)
{
if (strpos($line, 'public static class ') > 0) {
return explode(' ', trim($line))[3];
return preg_split('/( |<|>)/', trim($line))[3];
}
return '';
}
@ -196,9 +196,9 @@ EOT
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* <p> Returns {@link $return_type $return_type} </p>";
}
protected function addClassDocumentation($class_name, $base_class_name, $description)
protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description)
{
$this->addDocumentation(" public static class $class_name extends $base_class_name {", <<<EOT
$this->addDocumentation(" public static class $class_name extends ".($base_class_name == "Function" ? "Function<R extends Object>" : $base_class_name).(empty($return_type) ? "" : "<".$return_type.">")." {", <<<EOT
/**
* $description
*/

View File

@ -89,7 +89,7 @@ abstract class TlDocumentationGenerator
abstract protected function getFunctionReturnTypeDescription($return_type, $for_constructor);
abstract protected function addClassDocumentation($class_name, $base_class_name, $description);
abstract protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description);
abstract protected function addFieldDocumentation($class_name, $field_name, $type_name, $field_info, $may_be_null);
@ -244,10 +244,12 @@ abstract class TlDocumentationGenerator
$base_class_name = $current_class ?: $this->getBaseClassName($is_function);
$class_description = $description;
$return_type = "";
if ($is_function) {
$class_description .= $this->getFunctionReturnTypeDescription($this->getTypeName($type), false);
$return_type = $this->getTypeName($type);
$class_description .= $this->getFunctionReturnTypeDescription($return_type, false);
}
$this->addClassDocumentation($class_name, $base_class_name, $class_description);
$this->addClassDocumentation($class_name, $base_class_name, $return_type, $class_description);
foreach ($known_fields as $name => $field_type) {
$may_be_null = stripos($info[$name], 'may be null') !== false;