fchabouis
How to get function definition file and line?
I would like to know if there is a way, in a mix project, to get information about where a function is defined?
I would like, given a module name and function name, to know that this function is defined line 8 of foo.ex file. I guess it is possible to find information like this, as we get lines number when running tests or for compiler warnings.
Thanks!
Marked As Solved
fchabouis
Thanks, I have all the information I need ![]()
Phoenix.Router.route_info to know which module + function is called
module.module_info() for the source file path
Code.fetch_docs/1 for the line number
Also Liked
hauleth
It is in the metadata of module itself. Just check out module.module_info().
fchabouis
@ambareesha7 No blog post, but I made a PR on Phoenix that just got merged!
https://github.com/phoenixframework/phoenix/pull/4748
hauleth
You can try to extract that information from the Code.fetch_docs/1. It will not always be 100% precise (as if there is documentation, then it will point to the line for documentation), but works well enough, especially in presence of multiple heads.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









