Where does Routes.static_path() fn come from?

I can see that it’s a callback from Phoenix.Endpoint, but I’ve gotten a bit lost in macro expansion.

A view will alias Routes to .Router.Helpers, which AFAIK is generated on the fly by macro expansion in Phoenix.Router, and it looks like it involves Phoenix.Router.Helpers.

I really like to know how all the dots are connected, and this one is escaping me.

I’m sure someone who actually knows something will illuminate, but in the meantime if you want to dig further yourself here are some notes I jotted down (before persuading myself that I really must gen up on elixir macros before going backwards through the framework even more …)

The meat seems to be in Phoenix.Router.Helpers define phoenix/helpers.ex at v1.5.11 · phoenixframework/phoenix · GitHub

This gets to the project via the __before_compile__ macro in Phoenix.Router which is used in the main web module.

It’s a bit circuitous & at my level of elixir knowledge I find it kind of hard to trace (or at least to grok what I find)

@crispinb is right. Just to add to the answer, here’s the relationship among the modules:

In case you’re not familiar with @before_compile, you can check out the official documentation: