2016-12-19 16:56:52 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2019-10-28 22:39:23 +01:00
|
|
|
/**
|
|
|
|
* Copyright 2016-2019 Daniil Gentili
|
|
|
|
* (https://daniil.it)
|
|
|
|
* This file is part of MadelineProto.
|
|
|
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU Affero General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-12-14 16:47:04 +01:00
|
|
|
use danog\MadelineProto\API;
|
|
|
|
use danog\MadelineProto\APIFactory;
|
|
|
|
use danog\MadelineProto\MTProto;
|
|
|
|
use danog\MadelineProto\TON\ADNL;
|
|
|
|
use danog\MadelineProto\TON\API as TONAPI;
|
|
|
|
use danog\MadelineProto\TON\APIFactory as TONAPIFactory;
|
|
|
|
|
2019-10-29 22:00:21 +01:00
|
|
|
\chdir($d=__DIR__.'/..');
|
|
|
|
|
2017-01-02 19:50:37 +01:00
|
|
|
require 'vendor/autoload.php';
|
2019-10-28 22:39:23 +01:00
|
|
|
|
2017-01-02 19:50:37 +01:00
|
|
|
$param = 1;
|
2019-10-29 22:00:21 +01:00
|
|
|
\danog\MadelineProto\Magic::classExists();
|
2017-01-02 19:50:37 +01:00
|
|
|
\danog\MadelineProto\Logger::constructor($param);
|
2018-04-19 19:56:52 +02:00
|
|
|
$logger = \danog\MadelineProto\Logger::$default;
|
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
|
2016-12-19 16:56:52 +01:00
|
|
|
|
2018-03-02 01:38:10 +01:00
|
|
|
\danog\MadelineProto\Logger::log('Copying readme...', \danog\MadelineProto\Logger::NOTICE);
|
2016-12-19 16:56:52 +01:00
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\file_put_contents('docs/docs/index.md', '---
|
2016-12-20 13:15:22 +01:00
|
|
|
title: MadelineProto documentation
|
2018-04-04 19:52:41 +02:00
|
|
|
description: PHP client/server for the telegram MTProto protocol (a better tg-cli)
|
|
|
|
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
|
2016-12-20 13:15:22 +01:00
|
|
|
---
|
2019-10-28 19:48:59 +01:00
|
|
|
'.\str_replace('<img', '<amp-img', \file_get_contents('README.md')));
|
2016-12-19 16:56:52 +01:00
|
|
|
|
2017-01-02 19:50:37 +01:00
|
|
|
$docs = [
|
2019-06-04 23:55:02 +02:00
|
|
|
/* [
|
2019-10-29 22:00:21 +01:00
|
|
|
'tl_schema' => ['td' => "$d/src/danog/MadelineProto/TL_td.tl"],
|
2017-03-11 19:54:51 +01:00
|
|
|
'title' => 'MadelineProto API documentation (td-lib)',
|
|
|
|
'description' => 'MadelineProto API documentation (td-lib)',
|
2019-10-29 22:00:21 +01:00
|
|
|
'output_dir' => "$d/docs/docs/TD_docs",
|
2017-03-11 19:54:51 +01:00
|
|
|
'readme' => false,
|
2017-08-25 14:43:50 +02:00
|
|
|
'td' => true,
|
2019-06-04 23:55:02 +02:00
|
|
|
],*/
|
2017-01-02 19:50:37 +01:00
|
|
|
[
|
2019-10-29 22:00:21 +01:00
|
|
|
'tl_schema' => ['mtproto' => "$d/src/danog/MadelineProto/TL_mtproto_v1.json"],
|
2017-01-02 19:52:29 +01:00
|
|
|
'title' => 'MadelineProto API documentation (mtproto)',
|
2017-01-02 19:50:37 +01:00
|
|
|
'description' => 'MadelineProto API documentation (mtproto)',
|
2019-10-29 22:00:21 +01:00
|
|
|
'output_dir' => "$d/docs/docs/MTProto_docs",
|
2017-01-07 12:40:51 +01:00
|
|
|
'readme' => false,
|
2017-01-02 19:50:37 +01:00
|
|
|
],
|
|
|
|
[
|
2019-10-29 22:00:21 +01:00
|
|
|
'tl_schema' => ['telegram' => "$d/src/danog/MadelineProto/TL_telegram_v105.tl", 'calls' => "$d/src/danog/MadelineProto/TL_calls.tl", 'secret' => "$d/src/danog/MadelineProto/TL_secret.tl", 'td' => "$d/src/danog/MadelineProto/TL_td.tl"],
|
2019-09-12 19:08:48 +02:00
|
|
|
'title' => 'MadelineProto API documentation (layer 105)',
|
|
|
|
'description' => 'MadelineProto API documentation (layer 105)',
|
2019-10-29 22:00:21 +01:00
|
|
|
'output_dir' => "$d/docs/docs/API_docs",
|
2017-01-07 12:40:51 +01:00
|
|
|
'readme' => false,
|
2017-01-02 19:50:37 +01:00
|
|
|
],
|
|
|
|
];
|
2017-01-03 00:28:51 +01:00
|
|
|
|
Added docs for layer 18, 23, 25, 27, 33, 38, 40, 41, 42, 44, 45, 46, 51, 53, 55
2017-01-02 21:04:36 +01:00
|
|
|
$layer_list = '';
|
2019-10-29 22:00:21 +01:00
|
|
|
foreach (\array_slice(\glob("$d/src/danog/MadelineProto/TL_telegram_*"), 0, -1) as $file) {
|
2019-10-28 19:48:59 +01:00
|
|
|
$layer = \preg_replace(['/.*telegram_/', '/\..+/'], '', $file);
|
2017-01-02 21:19:06 +01:00
|
|
|
$docs[] = [
|
Added docs for layer 18, 23, 25, 27, 33, 38, 40, 41, 42, 44, 45, 46, 51, 53, 55
2017-01-02 21:04:36 +01:00
|
|
|
'tl_schema' => ['telegram' => $file],
|
|
|
|
'title' => 'MadelineProto API documentation (layer '.$layer.')',
|
|
|
|
'description' => 'MadelineProto API documentation (layer '.$layer.')',
|
2019-10-29 22:00:21 +01:00
|
|
|
'output_dir' => "$d/docs/old_docs/API_docs_".$layer,
|
2017-01-07 12:40:51 +01:00
|
|
|
'readme' => true,
|
Added docs for layer 18, 23, 25, 27, 33, 38, 40, 41, 42, 44, 45, 46, 51, 53, 55
2017-01-02 21:04:36 +01:00
|
|
|
];
|
|
|
|
$layer_list = '[Layer '.$layer.'](API_docs_'.$layer.'/)
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\file_put_contents('docs/old_docs/README.md', '---
|
Added docs for layer 18, 23, 25, 27, 33, 38, 40, 41, 42, 44, 45, 46, 51, 53, 55
2017-01-02 21:04:36 +01:00
|
|
|
title: Documentations of old mtproto layers
|
|
|
|
description: Documentation of old mtproto layers
|
|
|
|
---
|
|
|
|
# Documentation of old mtproto layers
|
2017-01-02 19:50:37 +01:00
|
|
|
|
Added docs for layer 18, 23, 25, 27, 33, 38, 40, 41, 42, 44, 45, 46, 51, 53, 55
2017-01-02 21:04:36 +01:00
|
|
|
'.$layer_list);
|
2017-01-03 00:28:51 +01:00
|
|
|
|
2019-12-14 16:47:04 +01:00
|
|
|
$doc = new \danog\MadelineProto\AnnotationsBuilder(
|
|
|
|
$logger,
|
|
|
|
$docs[1],
|
|
|
|
\dirname(__FILE__).'/../src/danog/MadelineProto/InternalDoc.php',
|
|
|
|
[
|
|
|
|
'API' => API::class,
|
|
|
|
'APIFactory' => APIFactory::class,
|
|
|
|
'MTProto' => MTProto::class
|
|
|
|
],
|
|
|
|
'danog\\MadelineProto'
|
|
|
|
);
|
2019-10-29 22:00:21 +01:00
|
|
|
$doc->mkAnnotations();
|
2017-01-22 17:40:56 +01:00
|
|
|
|
2019-12-14 16:47:04 +01:00
|
|
|
$ton = [
|
|
|
|
'tl_schema' => [
|
|
|
|
'lite_api' => "$d/src/danog/MadelineProto/TON/lite_api.tl",
|
|
|
|
'ton_api' => "$d/src/danog/MadelineProto/TON/ton_api.tl",
|
|
|
|
//'tonlib_api' => "$d/src/danog/MadelineProto/TON/tonlib_api.tl",
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
$doc = new \danog\MadelineProto\AnnotationsBuilder(
|
|
|
|
$logger,
|
|
|
|
$ton,
|
|
|
|
\dirname(__FILE__).'/../src/danog/MadelineProto/TON/InternalDoc.php',
|
|
|
|
[
|
|
|
|
'API' => TONAPI::class,
|
|
|
|
'APIFactory' => TONAPIFactory::class,
|
|
|
|
'MTProto' => ADNL::class
|
|
|
|
],
|
|
|
|
'danog\\MadelineProto\\TON'
|
|
|
|
);
|
|
|
|
$doc->mkAnnotations();
|
2017-01-02 19:50:37 +01:00
|
|
|
foreach ($docs as $settings) {
|
2018-04-19 19:56:52 +02:00
|
|
|
$doc = new \danog\MadelineProto\DocsBuilder($logger, $settings);
|
2019-10-29 22:00:21 +01:00
|
|
|
$doc->mkDocs();
|
2016-12-19 16:56:52 +01:00
|
|
|
}
|
2019-03-08 15:16:58 +01:00
|
|
|
|
2019-10-29 22:00:21 +01:00
|
|
|
\chdir(__DIR__.'/..');
|
2019-03-08 15:16:58 +01:00
|
|
|
|
|
|
|
$orderedfiles = [];
|
|
|
|
$order = [
|
2019-05-03 21:10:56 +02:00
|
|
|
'ASYNC',
|
2019-03-08 15:16:58 +01:00
|
|
|
'CREATING_A_CLIENT',
|
|
|
|
'LOGIN',
|
|
|
|
'FEATURES',
|
|
|
|
'REQUIREMENTS',
|
|
|
|
'INSTALLATION',
|
|
|
|
'UPDATES',
|
|
|
|
'SETTINGS',
|
|
|
|
'SELF',
|
|
|
|
'EXCEPTIONS',
|
|
|
|
'FLOOD_WAIT',
|
|
|
|
'LOGGING',
|
|
|
|
'CALLS',
|
|
|
|
'FILES',
|
|
|
|
'CHAT_INFO',
|
|
|
|
'DIALOGS',
|
|
|
|
'INLINE_BUTTONS',
|
|
|
|
'SECRET_CHATS',
|
|
|
|
'LUA',
|
|
|
|
'PROXY',
|
|
|
|
'USING_METHODS',
|
|
|
|
'CONTRIB',
|
2019-06-04 14:55:58 +02:00
|
|
|
'TEMPLATES',
|
2019-03-08 15:16:58 +01:00
|
|
|
];
|
|
|
|
$index = '';
|
2019-10-28 19:48:59 +01:00
|
|
|
$files = \glob('docs/docs/docs/*md');
|
2019-03-08 15:16:58 +01:00
|
|
|
foreach ($files as $file) {
|
2019-10-28 19:48:59 +01:00
|
|
|
$base = \basename($file, '.md');
|
|
|
|
if ($base === 'UPDATES_INTERNAL') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$key = \array_search($base, $order);
|
2019-03-08 15:16:58 +01:00
|
|
|
if ($key !== false) {
|
|
|
|
$orderedfiles[$key] = $file;
|
|
|
|
}
|
|
|
|
}
|
2019-10-28 19:48:59 +01:00
|
|
|
\ksort($orderedfiles);
|
2019-03-08 15:16:58 +01:00
|
|
|
foreach ($orderedfiles as $key => $filename) {
|
2019-10-28 19:48:59 +01:00
|
|
|
$lines = \explode("\n", \file_get_contents($filename));
|
|
|
|
while (\end($lines) === '' || \strpos(\end($lines), 'Next')) {
|
|
|
|
unset($lines[\count($lines) - 1]);
|
2019-03-08 15:16:58 +01:00
|
|
|
}
|
|
|
|
if ($lines[0] === '---') {
|
2019-10-28 19:48:59 +01:00
|
|
|
\array_shift($lines);
|
2019-03-08 15:16:58 +01:00
|
|
|
while ($lines[0] !== '---') {
|
2019-10-28 19:48:59 +01:00
|
|
|
\array_shift($lines);
|
2019-03-08 15:16:58 +01:00
|
|
|
}
|
2019-10-28 19:48:59 +01:00
|
|
|
\array_shift($lines);
|
2019-03-08 15:16:58 +01:00
|
|
|
}
|
2019-10-28 19:48:59 +01:00
|
|
|
\preg_match('|^# (.*)|', $lines[0], $matches);
|
2019-03-08 15:16:58 +01:00
|
|
|
$title = $matches[1];
|
|
|
|
$description = $lines[2];
|
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\array_unshift($lines, '---', 'title: '.$title, 'description: '.$description, 'image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png', '---');
|
2019-03-08 15:16:58 +01:00
|
|
|
|
|
|
|
if (isset($orderedfiles[$key + 1])) {
|
2019-10-28 19:48:59 +01:00
|
|
|
$nextfile = 'https://docs.madelineproto.xyz/docs/'.\basename($orderedfiles[$key + 1], '.md').'.html';
|
|
|
|
$prevfile = $key === 0 ? 'https://docs.madelineproto.xyz' : 'https://docs.madelineproto.xyz/docs/'.\basename($orderedfiles[$key - 1], '.md').'.html';
|
|
|
|
$lines[\count($lines)] = "\n<a href=\"$nextfile\">Next section</a>";
|
2019-03-08 15:16:58 +01:00
|
|
|
} else {
|
2019-10-28 19:48:59 +01:00
|
|
|
$lines[\count($lines)] = "\n<a href=\"https://docs.madelineproto.xyz/#very-complex-and-complete-examples\">Next section</a>";
|
2019-03-08 15:16:58 +01:00
|
|
|
}
|
2019-10-28 19:48:59 +01:00
|
|
|
\file_put_contents($filename, \implode("\n", $lines));
|
2019-03-08 15:16:58 +01:00
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
$file = \file_get_contents($filename);
|
2019-03-08 15:16:58 +01:00
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\preg_match_all('|( *)\* \[(.*)\]\((.*)\)|', $file, $matches);
|
|
|
|
$file = 'https://docs.madelineproto.xyz/docs/'.\basename($filename, '.md').'.html';
|
2019-03-08 15:16:58 +01:00
|
|
|
$index .= "* [$title]($file)\n";
|
2019-10-28 19:48:59 +01:00
|
|
|
if (\basename($filename) !== 'FEATURES.md') {
|
2019-03-08 15:16:58 +01:00
|
|
|
foreach ($matches[1] as $key => $match) {
|
|
|
|
$spaces = " $match";
|
|
|
|
$name = $matches[2][$key];
|
|
|
|
$url = $matches[3][$key][0] === '#' ? $file.$matches[3][$key] : $matches[3][$key];
|
|
|
|
$index .= "$spaces* [$name]($url)\n";
|
|
|
|
if ($name === 'FULL API Documentation with descriptions') {
|
2019-06-04 14:55:58 +02:00
|
|
|
$spaces .= ' ';
|
2019-10-28 19:48:59 +01:00
|
|
|
\preg_match_all('|\* (.*)|', \file_get_contents('docs/docs/API_docs/methods/index.md'), $smatches);
|
2019-03-08 15:16:58 +01:00
|
|
|
foreach ($smatches[1] as $key => $match) {
|
2019-10-28 19:48:59 +01:00
|
|
|
$match = \str_replace('href="', 'href="https://docs.madelineproto.xyz/API_docs/methods/', $match);
|
2019-03-08 15:16:58 +01:00
|
|
|
$index .= "$spaces* ".$match."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
$readme = \explode('## ', \file_get_contents('README.md'));
|
2019-03-08 15:16:58 +01:00
|
|
|
foreach ($readme as &$section) {
|
2019-10-28 19:48:59 +01:00
|
|
|
if (\explode("\n", $section)[0] === 'Documentation') {
|
2019-03-08 15:16:58 +01:00
|
|
|
$section = "Documentation\n\n".$index."\n";
|
|
|
|
}
|
|
|
|
}
|
2019-10-28 19:48:59 +01:00
|
|
|
$readme = \implode('## ', $readme);
|
2019-03-08 15:16:58 +01:00
|
|
|
|
2019-10-28 19:48:59 +01:00
|
|
|
\file_put_contents('README.md', $readme);
|
|
|
|
\file_put_contents('docs/docs/index.md', '---
|
2019-03-08 15:16:58 +01:00
|
|
|
title: MadelineProto documentation
|
|
|
|
description: PHP client/server for the telegram MTProto protocol (a better tg-cli)
|
|
|
|
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
|
|
|
|
---
|
|
|
|
'.$readme);
|