Skip to content

Conversation

@ftes
Copy link
Contributor

@ftes ftes commented Nov 21, 2025

https://hexdocs.pm/ex_doc/Mix.Tasks.Docs.html#module-using-source_url-and-source_ref-together

shows this example

@version "0.30.10"
def project do
  [
    ...
    version: @version,
    docs: docs(),
    ...
  ]
end

def docs do
  ...
  source_ref: "v#{@version}",
  source_url: @source_url,
  ...
end

Which is incorrect afaict. source_url is not a docs option and should be moved to the project function.

@josevalim
Copy link
Member

I am looking at the source code and the ones in the top level are simply moved inside:


  defp normalize_source_url(options, config) do
    if source_url = config[:source_url] do
      Keyword.put(options, :source_url, source_url)
    else
      options
    end
  end

  defp normalize_homepage_url(options, config) do
    if homepage_url = config[:homepage_url] do
      Keyword.put(options, :homepage_url, homepage_url)
    else
      options
    end
  end

So I am thinking both are supported and the docs are correct. Thoughts?

@ftes
Copy link
Contributor Author

ftes commented Nov 22, 2025

I am looking at the source code and the ones in the top level are simply moved inside:

Ah, interesting. I see this behaviour for generating source links:
Top-level project.source_url takes precedence (example).
It overwrites docs.source_url if both are present.
Only if project.source_url is not present, then docs.source_url is used.

Since

  1. docs.source_url is not mentioned as a config option elsewhere
  2. project.source_url takes precedence

I think the example in question should be changed to use project.source_url.

Going further, maybe docs.source_url should even be deprecated?
I find it unnecessarily complex and thus potentially confusing without further explanation.
Unless there are valid use cases when you don't want project.source_url but do want docs.source_url.

@josevalim
Copy link
Member

I believe the original goal was to have source_url/homepage_url also be used by Hex to list in the packages page, but I think it was never implemented.

Added documentation for source_url and updated example.
@josevalim josevalim merged commit 6db9cab into elixir-lang:main Nov 22, 2025
@josevalim
Copy link
Member

All other examples used it at the root, so I merged it for consistency. I don't think it is worth deprecating though as to not push users through this hassle. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants