Bugfixes to documentation builders

This commit is contained in:
Daniil Gentili 2018-04-19 17:56:52 +00:00
parent 8aae939d7d
commit 8a04c809f8
6 changed files with 23 additions and 8 deletions

View File

@ -13,6 +13,8 @@ If not, see <http://www.gnu.org/licenses/>.
require 'vendor/autoload.php';
$param = 1;
\danog\MadelineProto\Logger::constructor($param);
$logger = \danog\MadelineProto\Logger::$default;
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
\danog\MadelineProto\Logger::log('Copying readme...', \danog\MadelineProto\Logger::NOTICE);
@ -71,10 +73,10 @@ description: Documentation of old mtproto layers
'.$layer_list);
$doc = new \danog\MadelineProto\AnnotationsBuilder($docs[2]);
$doc = new \danog\MadelineProto\AnnotationsBuilder($logger, $docs[2]);
$doc->mk_annotations();
foreach ($docs as $settings) {
$doc = new \danog\MadelineProto\DocsBuilder($settings);
$doc = new \danog\MadelineProto\DocsBuilder($logger, $settings);
$doc->mk_docs();
}

2
docs

@ -1 +1 @@
Subproject commit 3a5b18f742fa7f2898562aa3e9d7d20a2634bf69
Subproject commit 06370b82769bf4182fe5919e2f3f5f37efc8b5a0

View File

@ -20,8 +20,9 @@ class AnnotationsBuilder
use \danog\MadelineProto\TL\TL;
use Tools;
public function __construct($settings)
public function __construct($logger, $settings)
{
$this->logger = $logger;
$this->construct_TL($settings['tl_schema']);
$this->settings = $settings;
}

View File

@ -21,8 +21,9 @@ class DocsBuilder
use Tools;
public $td = false;
public function __construct($settings)
public function __construct($logger, $settings)
{
$this->logger = $logger;
set_error_handler(['\\danog\\MadelineProto\\Exception', 'ExceptionErrorHandler']);
$this->construct_TL($settings['tl_schema']);
if (isset($settings['tl_schema']['td']) && !isset($settings['tl_schema']['telegram'])) {
@ -446,7 +447,15 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
## Type: bytes
[Back to constructor index](index.md)
A string of bytes of variable length, with length smaller than or equal to 16777215.
An object of type `\danog\MadelineProto\TL\Types\Bytes`.
When casted to string, turns into a string of bytes of variable length, with length smaller than or equal to 16777215.
When JSON-serialized, turns into an array of the following format:
```
[
\'_\' => \'bytes\',
\'bytes\' => base64_encode($contents)
];
```
');
file_put_contents('types/int.md', '---
title: integer

View File

@ -161,7 +161,8 @@ trait Constructors
}
$table .= PHP_EOL;
$pptype = in_array($ptype, ['string', 'bytes']) ? "'".$ptype."'" : $ptype;
$ppptype = in_array($ptype, ['string', 'bytes']) ? '"'.$ptype.'"' : $ptype;
$ppptype = in_array($ptype, ['string']) ? '"'.$ptype.'"' : $ptype;
$ppptype = in_array($ptype, ['bytes']) ? '{"_": "bytes", "bytes":"base64 encoded '.$ptype.'"}' : $ppptype;
$params .= ", '".$param['name']."' => ";
$params .= isset($param['subtype']) ? '['.$pptype.', '.$pptype.']' : $pptype;
$lua_params .= ', '.$param['name'].'=';

View File

@ -144,7 +144,9 @@ trait Methods
}
$table .= PHP_EOL;
$pptype = in_array($ptype, ['string', 'bytes']) ? "'".$ptype."'" : $ptype;
$ppptype = in_array($ptype, ['string', 'bytes']) ? '"'.$ptype.'"' : $ptype;
$ppptype = in_array($ptype, ['string']) ? '"'.$ptype.'"' : $ptype;
$ppptype = in_array($ptype, ['bytes']) ? '{"_": "bytes", "bytes":"base64 encoded '.$ptype.'"}' : $ppptype;
$params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '['.$pptype.', '.$pptype.']' : $pptype).', ';
$json_params .= '"'.$param['name'].'": '.(isset($param['subtype']) ? '['.$ppptype.']' : $ppptype).', ';