Let's start with the fact that I'm still very skeptical of the idea in the title in the sense you understand it by default. That is, for me it's absolutely obvious that it's impossible (yet) to universally generate the code of a component or especially a screen drawn by designers. It's impossible because at the project level you most likely have guidelines and reusable blocks that complicate this task a thousand times. Generating a component is not such a big problem. The problem is to make it reuse what you already have.
But as for design system tokens - this is the base that seems to be quite simple to export. Tokens don't depend on anything. And I lived with this thought for the last few weeks.
To tell the truth, I was driven by laziness exactly at the moment when we received a pack of 500 new icons from designers in Figma. And each of these icons according to the usual workflow needed to be exported to SVG, made into an optimized Vector Drawable, meaningfully renamed as is customary in Android resources, put where needed, and write a Compose getter like Icons.Filled.ArrowLeft. And, God forbid, then they update something. It's noteworthy that out of the box in Android Studio there's not even batch conversion of SVG to Vector Drawable, you have to convert one by one.
Parts of this complex task are solved by various tools like Figma plugins or third-party exporters-converters. But I decided to write a bicycle so that all this could be done with one button and as is customary for us. At least there will be experience.
So, it turned out that the Figma API is really very simple, I don't even know why this isn't so widespread. We literally need two endpoints, the first one exports the tree of nodes by the root node, the second gives a link to its exported image by any node.
That is, the main complexity here is algorithmic. You need to traverse the tree looking for nodes that designers marked as exportable, simultaneously accumulating the names of all parents. The chain of parent names after simple transformations (brutal crutches) are assembled into the final icon name. As a result, an array of SVGs with "correct" names. Then each SVG is converted to Vector Drawable using the Svg2Vector class from Build Tools, which the studio itself uses. There are many tools for optimizing SVG or Vector Drawable, I took the first one that caught my eye - avocado. Well, generating code files from an array of Drawable resources using KotlinPoet or even your own templates is already a matter of technique.
And as a result, it's just a Gradle plugin in the design system module, everything is configured there and launched with one task. And the most crappy thing in this whole story is that essentially only the concept can be shared, because the tree parsing code is a direct consequence of the Figma structure from designers and the most vulnerable place for changes.
By the way, here is a good article on this topic. I honestly didn't peek, but almost all my buzzwords and approaches matched in the end.