From 8a04c809f8f670167d4aac14f755ba7384317696 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 19 Apr 2018 17:56:52 +0000 Subject: [PATCH] Bugfixes to documentation builders --- build_docs.php | 6 ++++-- docs | 2 +- src/danog/MadelineProto/AnnotationsBuilder.php | 3 ++- src/danog/MadelineProto/DocsBuilder.php | 13 +++++++++++-- .../MadelineProto/DocsBuilder/Constructors.php | 3 ++- src/danog/MadelineProto/DocsBuilder/Methods.php | 4 +++- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/build_docs.php b/build_docs.php index 1fd109c03..71e6c2319 100755 --- a/build_docs.php +++ b/build_docs.php @@ -13,6 +13,8 @@ If not, see . 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(); } diff --git a/docs b/docs index 3a5b18f74..06370b827 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 3a5b18f742fa7f2898562aa3e9d7d20a2634bf69 +Subproject commit 06370b82769bf4182fe5919e2f3f5f37efc8b5a0 diff --git a/src/danog/MadelineProto/AnnotationsBuilder.php b/src/danog/MadelineProto/AnnotationsBuilder.php index 77d0f0479..3534c9098 100644 --- a/src/danog/MadelineProto/AnnotationsBuilder.php +++ b/src/danog/MadelineProto/AnnotationsBuilder.php @@ -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; } diff --git a/src/danog/MadelineProto/DocsBuilder.php b/src/danog/MadelineProto/DocsBuilder.php index 39cd29845..0845d73f6 100644 --- a/src/danog/MadelineProto/DocsBuilder.php +++ b/src/danog/MadelineProto/DocsBuilder.php @@ -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 diff --git a/src/danog/MadelineProto/DocsBuilder/Constructors.php b/src/danog/MadelineProto/DocsBuilder/Constructors.php index b27d758b1..c1ba943da 100644 --- a/src/danog/MadelineProto/DocsBuilder/Constructors.php +++ b/src/danog/MadelineProto/DocsBuilder/Constructors.php @@ -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'].'='; diff --git a/src/danog/MadelineProto/DocsBuilder/Methods.php b/src/danog/MadelineProto/DocsBuilder/Methods.php index 2bc2c9eb5..026f508b4 100644 --- a/src/danog/MadelineProto/DocsBuilder/Methods.php +++ b/src/danog/MadelineProto/DocsBuilder/Methods.php @@ -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).', ';