MadelineProto/build_docs_index.php
Daniil Gentili 7a0153a139
Documentation rework (#349)
* Documentation rework

* Apply fixes from StyleCI

* Documentation fixes

* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite

* Apply fixes from StyleCI

* Logging fixes

* Build docs

* Add methods to modify start template, bugfix to logging and keyboard conversion

* Add TL documentator

* Document MTProto methods

* Documenting methods...

* 7% documented

* Bugfixes

* Update docs

* Update docs

* Simplify file management

* Implement automatic object conversion for media, and more awesome stuff

* Implement automatic object conversion for media, and more awesome stuff

* Implement event update handler and file upload/download callback

* Auto-detect mime type, duration, width and height of media

* Update docs

* Document new file functions

* Fix links

* Fix links

* Update bot.php to use event loop

* Implement webhook update handler and forking in main loop

* Build docs

* Better docs

* Fixes to secret chats

* Almost finished updating docs

* Bugfixes, implemented infinite loop for loop() method, almost finished docs

* Finish writing docs

* Add automatic documentation builder script

* Finished writing docs
2018-03-20 12:48:05 +01:00

65 lines
2.2 KiB
PHP

<?php
$index = '';
$files = glob('docs/docs/*md');
foreach ($files as $file) {
$base = basename($file, '.md');
if ($base === 'CREATING_A_CLIENT') {
$orderedfiles[0] = $file;
} else if ($base === 'LOGIN') {
$orderedfiles[1] = $file;
} else if ($base === 'FEATURES') {
$orderedfiles[2] = $file;
} else if ($base === 'REQUIREMENTS') {
$orderedfiles[3] = $file;
} else if ($base === 'INSTALLATION') {
$orderedfiles[4] = $file;
} else if ($base === 'UPDATES') {
$orderedfiles[5] = $file;
} else if ($base === 'SETTINGS') {
$orderedfiles[6] = $file;
} else if ($base === 'SELF') {
$orderedfiles[7] = $file;
} else if ($base === 'EXCEPTIONS') {
$orderedfiles[8] = $file;
} else if ($base === 'LOGGING') {
$orderedfiles[9] = $file;
} else if ($base === 'USING_METHODS') {
$orderedfiles[10] = $file;
} else if ($base === 'FILES') {
$orderedfiles[11] = $file;
} else if ($base === 'CHAT_INFO') {
$orderedfiles[12] = $file;
} else if ($base === 'DIALOGS') {
$orderedfiles[13] = $file;
} else if ($base === 'INLINE_BUTTONS') {
$orderedfiles[14] = $file;
} else if ($base === 'CALLS') {
$orderedfiles[15] = $file;
} else if ($base === 'SECRET_CHATS') {
$orderedfiles[16] = $file;
} else if ($base === 'LUA') {
$orderedfiles[17] = $file;
} else if ($base === 'PROXY') {
$orderedfiles[18] = $file;
} else {
$orderedfiles[] = $file;
}
}
ksort($orderedfiles);
foreach ($orderedfiles as $filename) {
preg_match('|^# (.*)|', $file = file_get_contents($filename), $matches);
$title = $matches[1];
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];
$index .= "$spaces* [$name]($url)\n";
}
}
}
echo $index;