Skip to content

Conversation

alco
Copy link
Member

@alco alco commented May 16, 2013

No description provided.

@alco
Copy link
Member Author

alco commented May 16, 2013

This PR will allow us to tweak Makefile for Elixir and close #32.

@alco
Copy link
Member Author

alco commented May 16, 2013

Now I'm in doubt if master is a good default. It is probably more reasonable to use current rev. If the user wants master, they case set :source_ref to "master" which is easier to do than to set it to current rev.

@alco
Copy link
Member Author

alco commented May 16, 2013

Another issue that users might have to deal with is when they need to generate documentation for a new version of their project and they want to use the most recent tag for source links, they'll need to modify the :source_ref option.

To solve this, in general case, project config should probably look like this:

def project do
  [ source_ref: get_ref ]
end

defp get_ref do
  # calculate the desired ref
end

We could make this easier on the user by providing helpers like ExDoc.source_ref(:most_recent_tag), ExDoc.source_ref(:HEAD), etc.

josevalim pushed a commit that referenced this pull request May 16, 2013
Add an option to specify a particular commit/branch/tag for source links
@josevalim josevalim merged commit aa78134 into elixir-lang:master May 16, 2013
@josevalim
Copy link
Member

The problem with ExDoc.source_ref(:HEAD) is that it would be executed for every mix command, effectively slowing things down. :) Maybe we should just allow setting it to an atom and, if that is the case, we expand the atom (like :HEAD would have special semantics).

@josevalim
Copy link
Member

Can we add a small test?

@josevalim
Copy link
Member

Thanks a lot! ❤️

@alco
Copy link
Member Author

alco commented May 16, 2013

The problem with ExDoc.source_ref(:HEAD) is that it would be executed for every mix command, effectively slowing things down.

It's true. But if we don't provide those helpers, users will write their own function for retrieving a suitable ref and it'll run for every mix command. I think we need to come up with a way to be able to specify such a function but make it run only once.

@alco alco deleted the flexible-urls branch May 16, 2013 12:26
@alco alco restored the flexible-urls branch May 16, 2013 12:26
@alco
Copy link
Member Author

alco commented May 16, 2013

Even though mix.exs is compiled in-memory, can we reference it during the doc generation process? I'm think of this

def project do
  [ source_ref: {__MODULE__, :get_ref } ]
  # or even
  [ source_ref: function(__MODULE__.get_ref/0) ]
end

def get_ref do
  # calculate the desired ref
end

@josevalim
Copy link
Member

A function would work perfectly too.

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