Gleanex.Generator.Processor (Gleanex v0.1.0)

Copy Markdown View Source

Code generation plugin that fixes up operation function names.

This module is only compiled in the :dev environment and is not shipped in the package. It exists because Glean's four descriptions each name operations a different way, and the generator's defaults carry that inconsistency straight into the public API.

Two rules, both purely mechanical:

Drop prefixes the module already says

Platform operation IDs repeat the API and the tag: platform-agents-get-schemas under tag Agents would become a function named platform_agents_get_schemas on Gleanex.Platform.Agents. Leading tokens matching the profile name or a tag are dropped, giving get_schemas instead.

Only whole tokens are matched, and stripping never empties the name, so platform-agents-search keeps its last word as search/2 and createAgent under tag Agents stays create_agent/2 because agent is not agents.

Name Indexing operations after their path

The Indexing description has no operation IDs at all, so the default falls back to path plus method: indexdocument_post. The method suffix is dropped for POST only, which is the verb Indexing uses for every write. Paths that carry more than one method use GET, PUT and DELETE, so those keep their suffix and no two operations in a module can collide.

Glean's own run-together words (indexdocument, createannouncement) are left alone. Splitting them would need a hand-maintained vocabulary, and an unrecognised new word would silently rename a public function.