TGO's generator
TGO has all methods and types as they are described in Telegram Bot API, all
these are generated from docs themselves. All content of the doc's page is parsed using regular expressions, divided
into methods and types, and used for generation.
Also, With...
methods are generated from types and most of the tests are generated too. These tests meant to be
regenerated only after previous tests pass in the new version of the library have been generated.
The process of generation is pretty simple:
- Get raw HTML of docs
- Parse blocks of HTML with tables, where types and methods defined
- Parse resulted blocks into separate types/methods with individual parameters/fields
- Generate Go code from parsed data
- Write it into files and run
go fmt
on them
Disclaimer
This code (code of generator itself) isn't meant to be reused by anyone (at least directly) and has quite high
complexity so there are no tests or linters for it, and it is located inside the internal
folder, so be very
thoughtful if you want to use it.