How to add auto-discoverable feature to a custom ESP8266 device with MQTT discovery?

I’m working on my own hardware device(with an ESP8266) and I want to integrate it with HA.
I want to make it discoverable using MQTT discovery service, but I miss something about the “init procedure” to register the device. The documentation is quite poor about it.
Could you please tell me a step-by-step procedure to achieve this? I’m using an MQTT library on ESP8266.

Did you read this?

Seems pretty comprehensive to me.

Thanks, I miss that doc, I’ll read it now.