1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 00:14:38 +01:00

Improve documentation builder

This commit is contained in:
Daniil Gentili 2018-04-11 14:18:03 +02:00
parent d088f5e009
commit 6dd180542e
3 changed files with 36 additions and 8 deletions

View File

@ -60,7 +60,6 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro
* [Simple (manual)](https://docs.madelineproto.xyz/docs/INSTALLATION.html#simple-manual)
* [Composer from scratch](https://docs.madelineproto.xyz/docs/INSTALLATION.html#composer-from-scratch)
* [Composer from existing project](https://docs.madelineproto.xyz/docs/INSTALLATION.html#composer-from-existing-project)
* [Git](https://docs.madelineproto.xyz/docs/INSTALLATION.html#git)
* [Handling updates](https://docs.madelineproto.xyz/docs/UPDATES.html)
* [Event driven](https://docs.madelineproto.xyz/docs/UPDATES.html#event-driven)
* [Event driven multithreaded](https://docs.madelineproto.xyz/docs/UPDATES.html#event-driven-multithreaded)
@ -78,7 +77,9 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro
* [Avoiding FLOOD_WAITs](https://docs.madelineproto.xyz/docs/FLOOD_WAIT.html)
* [Logging](https://docs.madelineproto.xyz/docs/LOGGING.html)
* [Using methods](https://docs.madelineproto.xyz/docs/USING_METHODS.html)
* [FULL API Documentation with descriptions](https://docs.madelineproto.xyz/API_docs/methods)
* [Peers](https://docs.madelineproto.xyz/docs/USING_METHODS.html#peers)
* [Files](https://docs.madelineproto.xyz/docs/FILES.html)
* [Secret chats](https://docs.madelineproto.xyz/docs/USING_METHODS.html#secret-chats)
* [Entities (Markdown & HTML)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#entities)
* [reply_markup (keyboards & inline keyboards)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#reply_markup)
@ -132,7 +133,6 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro
* [Credits](https://docs.madelineproto.xyz/docs/CONTRIB.html#credits)
* [Web templates for `$MadelineProto->start()`](https://docs.madelineproto.xyz/docs/TEMPLATES.html)
## Very complex and complete examples
You can find examples for nearly every MadelineProto function in

View File

@ -57,6 +57,19 @@ foreach ($orderedfiles as $key => $filename) {
while (end($lines) === '' || strpos(end($lines), 'Next')) {
unset($lines[count($lines) - 1]);
}
if ($lines[0] === '---') {
array_shift($lines);
while ($lines[0] !== '---') {
array_shift($lines);
}
array_shift($lines);
}
preg_match('|^# (.*)|', $lines[0], $matches);
$title = $matches[1];
$description = $lines[2];
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';
$prevfile = $key === 0 ? 'https://docs.madelineproto.xyz' : 'https://docs.madelineproto.xyz/docs/'.basename($orderedfiles[$key - 1], '.md').'.html';
@ -66,18 +79,33 @@ foreach ($orderedfiles as $key => $filename) {
}
file_put_contents($filename, implode("\n", $lines));
preg_match('|^# (.*)|', $file = file_get_contents($filename), $matches);
$title = $matches[1];
preg_match_all('|( *)\* \[(.*)\]\(#(.*)\)|', $file, $matches);
$file = file_get_contents($filename);
preg_match_all('|( *)\* \[(.*)\]\((.*)\)|', $file, $matches);
$file = 'https://docs.madelineproto.xyz/docs/'.basename($filename, '.md').'.html';
$index .= "* [$title]($file)\n";
if (basename($filename) !== 'FEATURES.md') {
foreach ($matches[1] as $key => $match) {
$spaces = " $match";
$name = $matches[2][$key];
$url = $file.'#'.$matches[3][$key];
$url = $matches[3][$key][0] === '#' ? $file.$matches[3][$key] : $matches[3][$key];
$index .= "$spaces* [$name]($url)\n";
}
}
}
echo $index;
$readme = explode("## ", file_get_contents('README.md'));
foreach ($readme as &$section) {
if (explode("\n", $section)[0] === 'Documentation') {
$section = "Documentation\n\n".$index."\n";
}
}
$readme = implode("## ", $readme);
file_put_contents('README.md', $readme);
file_put_contents('docs/docs/index.md', "---
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);

2
docs

@ -1 +1 @@
Subproject commit d7fb09c3cae7e41d66d4ce86e0cfc48255b27122
Subproject commit b6152298e377fe696e67971d889833fa1f36da8e