|
15 | 15 | \danog\MadelineProto\Logger::constructor($param); |
16 | 16 | $logger = \danog\MadelineProto\Logger::$default; |
17 | 17 |
|
18 | | -set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']); |
| 18 | +\set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']); |
19 | 19 |
|
20 | 20 | \danog\MadelineProto\Logger::log('Copying readme...', \danog\MadelineProto\Logger::NOTICE); |
21 | 21 |
|
22 | | -file_put_contents('docs/docs/index.md', '--- |
| 22 | +\file_put_contents('docs/docs/index.md', '--- |
23 | 23 | title: MadelineProto documentation |
24 | 24 | description: PHP client/server for the telegram MTProto protocol (a better tg-cli) |
25 | 25 | image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png |
26 | 26 | --- |
27 | | -'.str_replace('<img', '<amp-img', file_get_contents('README.md'))); |
| 27 | +'.\str_replace('<img', '<amp-img', \file_get_contents('README.md'))); |
28 | 28 |
|
29 | 29 | $docs = [ |
30 | 30 | /* [ |
|
52 | 52 | ]; |
53 | 53 |
|
54 | 54 | $layer_list = ''; |
55 | | -foreach (array_slice(glob(__DIR__.'/src/danog/MadelineProto/TL_telegram_*'), 0, -1) as $file) { |
56 | | - $layer = preg_replace(['/.*telegram_/', '/\..+/'], '', $file); |
| 55 | +foreach (\array_slice(\glob(__DIR__.'/src/danog/MadelineProto/TL_telegram_*'), 0, -1) as $file) { |
| 56 | + $layer = \preg_replace(['/.*telegram_/', '/\..+/'], '', $file); |
57 | 57 | $docs[] = [ |
58 | 58 | 'tl_schema' => ['telegram' => $file], |
59 | 59 | 'title' => 'MadelineProto API documentation (layer '.$layer.')', |
|
65 | 65 | '; |
66 | 66 | } |
67 | 67 |
|
68 | | -file_put_contents('docs/old_docs/README.md', '--- |
| 68 | +\file_put_contents('docs/old_docs/README.md', '--- |
69 | 69 | title: Documentations of old mtproto layers |
70 | 70 | description: Documentation of old mtproto layers |
71 | 71 | --- |
|
81 | 81 | $doc->mk_docs(); |
82 | 82 | } |
83 | 83 |
|
84 | | -chdir(__DIR__); |
| 84 | +\chdir(__DIR__); |
85 | 85 |
|
86 | 86 | $orderedfiles = []; |
87 | 87 | $order = [ |
|
110 | 110 | 'TEMPLATES', |
111 | 111 | ]; |
112 | 112 | $index = ''; |
113 | | -$files = glob('docs/docs/docs/*md'); |
| 113 | +$files = \glob('docs/docs/docs/*md'); |
114 | 114 | foreach ($files as $file) { |
115 | | - $base = basename($file, '.md'); |
116 | | - if ($base === 'UPDATES_INTERNAL') continue; |
117 | | - $key = array_search($base, $order); |
| 115 | + $base = \basename($file, '.md'); |
| 116 | + if ($base === 'UPDATES_INTERNAL') { |
| 117 | + continue; |
| 118 | + } |
| 119 | + $key = \array_search($base, $order); |
118 | 120 | if ($key !== false) { |
119 | 121 | $orderedfiles[$key] = $file; |
120 | 122 | } |
121 | 123 | } |
122 | | -ksort($orderedfiles); |
| 124 | +\ksort($orderedfiles); |
123 | 125 | foreach ($orderedfiles as $key => $filename) { |
124 | | - $lines = explode("\n", file_get_contents($filename)); |
125 | | - while (end($lines) === '' || strpos(end($lines), 'Next')) { |
126 | | - unset($lines[count($lines) - 1]); |
| 126 | + $lines = \explode("\n", \file_get_contents($filename)); |
| 127 | + while (\end($lines) === '' || \strpos(\end($lines), 'Next')) { |
| 128 | + unset($lines[\count($lines) - 1]); |
127 | 129 | } |
128 | 130 | if ($lines[0] === '---') { |
129 | | - array_shift($lines); |
| 131 | + \array_shift($lines); |
130 | 132 | while ($lines[0] !== '---') { |
131 | | - array_shift($lines); |
| 133 | + \array_shift($lines); |
132 | 134 | } |
133 | | - array_shift($lines); |
| 135 | + \array_shift($lines); |
134 | 136 | } |
135 | | - preg_match('|^# (.*)|', $lines[0], $matches); |
| 137 | + \preg_match('|^# (.*)|', $lines[0], $matches); |
136 | 138 | $title = $matches[1]; |
137 | 139 | $description = $lines[2]; |
138 | 140 |
|
139 | | - array_unshift($lines, '---', 'title: '.$title, 'description: '.$description, 'image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png', '---'); |
| 141 | + \array_unshift($lines, '---', 'title: '.$title, 'description: '.$description, 'image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png', '---'); |
140 | 142 |
|
141 | 143 | if (isset($orderedfiles[$key + 1])) { |
142 | | - $nextfile = 'https://docs.madelineproto.xyz/docs/'.basename($orderedfiles[$key + 1], '.md').'.html'; |
143 | | - $prevfile = $key === 0 ? 'https://docs.madelineproto.xyz' : 'https://docs.madelineproto.xyz/docs/'.basename($orderedfiles[$key - 1], '.md').'.html'; |
144 | | - $lines[count($lines)] = "\n<a href=\"$nextfile\">Next section</a>"; |
| 144 | + $nextfile = 'https://docs.madelineproto.xyz/docs/'.\basename($orderedfiles[$key + 1], '.md').'.html'; |
| 145 | + $prevfile = $key === 0 ? 'https://docs.madelineproto.xyz' : 'https://docs.madelineproto.xyz/docs/'.\basename($orderedfiles[$key - 1], '.md').'.html'; |
| 146 | + $lines[\count($lines)] = "\n<a href=\"$nextfile\">Next section</a>"; |
145 | 147 | } else { |
146 | | - $lines[count($lines)] = "\n<a href=\"https://docs.madelineproto.xyz/#very-complex-and-complete-examples\">Next section</a>"; |
| 148 | + $lines[\count($lines)] = "\n<a href=\"https://docs.madelineproto.xyz/#very-complex-and-complete-examples\">Next section</a>"; |
147 | 149 | } |
148 | | - file_put_contents($filename, implode("\n", $lines)); |
| 150 | + \file_put_contents($filename, \implode("\n", $lines)); |
149 | 151 |
|
150 | | - $file = file_get_contents($filename); |
| 152 | + $file = \file_get_contents($filename); |
151 | 153 |
|
152 | | - preg_match_all('|( *)\* \[(.*)\]\((.*)\)|', $file, $matches); |
153 | | - $file = 'https://docs.madelineproto.xyz/docs/'.basename($filename, '.md').'.html'; |
| 154 | + \preg_match_all('|( *)\* \[(.*)\]\((.*)\)|', $file, $matches); |
| 155 | + $file = 'https://docs.madelineproto.xyz/docs/'.\basename($filename, '.md').'.html'; |
154 | 156 | $index .= "* [$title]($file)\n"; |
155 | | - if (basename($filename) !== 'FEATURES.md') { |
| 157 | + if (\basename($filename) !== 'FEATURES.md') { |
156 | 158 | foreach ($matches[1] as $key => $match) { |
157 | 159 | $spaces = " $match"; |
158 | 160 | $name = $matches[2][$key]; |
159 | 161 | $url = $matches[3][$key][0] === '#' ? $file.$matches[3][$key] : $matches[3][$key]; |
160 | 162 | $index .= "$spaces* [$name]($url)\n"; |
161 | 163 | if ($name === 'FULL API Documentation with descriptions') { |
162 | 164 | $spaces .= ' '; |
163 | | - preg_match_all('|\* (.*)|', file_get_contents('docs/docs/API_docs/methods/index.md'), $smatches); |
| 165 | + \preg_match_all('|\* (.*)|', \file_get_contents('docs/docs/API_docs/methods/index.md'), $smatches); |
164 | 166 | foreach ($smatches[1] as $key => $match) { |
165 | | - $match = str_replace('href="', 'href="https://docs.madelineproto.xyz/API_docs/methods/', $match); |
| 167 | + $match = \str_replace('href="', 'href="https://docs.madelineproto.xyz/API_docs/methods/', $match); |
166 | 168 | $index .= "$spaces* ".$match."\n"; |
167 | 169 | } |
168 | 170 | } |
169 | 171 | } |
170 | 172 | } |
171 | 173 | } |
172 | 174 |
|
173 | | -$readme = explode('## ', file_get_contents('README.md')); |
| 175 | +$readme = \explode('## ', \file_get_contents('README.md')); |
174 | 176 | foreach ($readme as &$section) { |
175 | | - if (explode("\n", $section)[0] === 'Documentation') { |
| 177 | + if (\explode("\n", $section)[0] === 'Documentation') { |
176 | 178 | $section = "Documentation\n\n".$index."\n"; |
177 | 179 | } |
178 | 180 | } |
179 | | -$readme = implode('## ', $readme); |
| 181 | +$readme = \implode('## ', $readme); |
180 | 182 |
|
181 | | -file_put_contents('README.md', $readme); |
182 | | -file_put_contents('docs/docs/index.md', '--- |
| 183 | +\file_put_contents('README.md', $readme); |
| 184 | +\file_put_contents('docs/docs/index.md', '--- |
183 | 185 | title: MadelineProto documentation |
184 | 186 | description: PHP client/server for the telegram MTProto protocol (a better tg-cli) |
185 | 187 | image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png |
|
0 commit comments