1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 08:39:00 +01:00
This commit is contained in:
Daniil Gentili 2021-12-21 14:44:39 +01:00
parent 24980d473a
commit c9791fd291
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
7 changed files with 34 additions and 38 deletions

View File

@ -65,7 +65,8 @@
"phpunit/phpunit": "^9",
"phabel/phabel": "^1",
"bamarni/composer-bin-plugin": "^1.4",
"roave/security-advisories": "dev-latest"
"roave/security-advisories": "dev-latest",
"symfony/yaml": "^6.0"
},
"suggest": {
"ext-libtgvoip": "Install the php-libtgvoip extension to make phone calls (https://github.com/danog/php-libtgvoip)",

2
docs

@ -1 +1 @@
Subproject commit b6e8bd2600e38afa4e6ad60b9bfdf9dea9dbd94c
Subproject commit 23e60b270e4f34d5a74bc9248e741d6badb998ac

View File

@ -177,10 +177,10 @@ trait Constructors
$description = isset($this->TL->getDescriptions()['constructors'][$constructor]) ? $this->TL->getDescriptions()['constructors'][$constructor]['description'] : $constructor.' attributes, type and example';
$symFile = \str_replace('.', '_', $constructor.$layer);
$redir = $symFile !== $constructor.$layer ? "\nredirect_from: /API_docs/constructors/{$symFile}.html" : '';
$description = \rtrim(\explode("\n", $description)[0], ':');
$description = \str_replace('"', "'", Tools::toString(\rtrim(\explode("\n", $description)[0], ':')));
$header = '---
title: '.$constructor.'
description: '.$description.'
title: "'.$constructor.'"
description: "'.$description.'"
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redir.'
---
# Constructor: '.StrTools::markdownEscape($constructor.$layer).'

View File

@ -25,6 +25,9 @@ use Amp\Loop;
use Amp\Promise;
use Amp\Success;
use Amp\TimeoutException;
use DOMDocument;
use Parsedown;
use function Amp\ByteStream\getOutputBufferStream;
use function Amp\ByteStream\getStdin;
use function Amp\ByteStream\getStdout;
@ -1017,4 +1020,25 @@ abstract class Tools extends StrTools
}
return [!!$matches[1], $matches[2]];
}
/**
* Strip markdown tags.
*
* @internal
*
* @param string $markdown
* @return string
*/
public static function toString(string $markdown): string
{
if ($markdown === '') {
return $markdown;
}
$html = (new Parsedown($markdown))->text($markdown);
$document = new DOMDocument('', 'utf-8');
@$document->loadHTML(\mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
if (!$document->getElementsByTagName('body')[0]) {
return '';
}
return $document->getElementsByTagName('body')[0]->childNodes[0]->textContent;
}
}

View File

@ -26,15 +26,6 @@ function __destructure($list, $value): array
return $res;
}
trait MyCallableMaker
{
use \Amp\CallableMaker {
callableFromInstanceMethod as public;
callableFromStaticMethod as public;
}
}
$ampFilePolyfill = 'namespace Amp\\File {';
foreach ([
'open' => 'openFile',

View File

@ -20,6 +20,7 @@ use danog\MadelineProto\Settings\Logger as SettingsLogger;
use danog\MadelineProto\TON\API as TONAPI;
use danog\MadelineProto\TON\APIFactory as TONAPIFactory;
use danog\MadelineProto\TON\Lite;
use danog\MadelineProto\Tools;
\chdir($d=__DIR__.'/..');
@ -159,9 +160,9 @@ foreach ($orderedfiles as $key => $filename) {
}
\preg_match('|^# (.*)|', $lines[0], $matches);
$title = $matches[1];
$description = $lines[2];
$description = \str_replace('"', "'", Tools::toString($lines[2]));
\array_unshift($lines, '---', 'title: '.$title, 'description: '.$description, 'image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png', '---');
\array_unshift($lines, '---', 'title: "'.$title.'"', 'description: "'.$description.'"', 'image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png', '---');
if (isset($orderedfiles[$key + 1])) {
$nextfile = 'https://docs.madelineproto.xyz/docs/'.\basename($orderedfiles[$key + 1], '.md').'.html';

View File

@ -38,26 +38,5 @@ function maxLayer(array $schemas): int
*/
function initDocs(array $layers): array
{
$docs = [];
$layer_list = '';
foreach (\array_slice($layers, 0, -1) as $layer => $file) {
$layer = "v$layer";
$docs[] = [
'tl_schema' => ['telegram' => $file, 'mtproto' => '', 'secret' => '', 'td' => ''],
'title' => 'MadelineProto API documentation (layer '.$layer.')',
'description' => 'MadelineProto API documentation (layer '.$layer.')',
'output_dir' => \getcwd()."/docs/old_docs/API_docs_".$layer,
'template' => \getcwd()."/docs/template",
'readme' => true,
];
$layer_list .= "[Layer $layer](API_docs_$layer/) \n";
}
\file_put_contents('docs/old_docs/README.md', '---
title: Documentation of old mtproto layers
description: Documentation of old mtproto layers
---
# Documentation of old mtproto layers
'.$layer_list);
return $docs;
return [];
}