-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify hex docs.open to fetch docs if not present locally #293
Conversation
3d1852a
to
ae13752
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you investigate why the tests fail?
end | ||
unless File.exists?(doc_path) do | ||
fetch_docs([name, latest_version], opts) | ||
end | ||
open_docs([name, latest_version], opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be open_file
like below? It looks like this would loop infinitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should be open_docs_offline([name, latest_version], opts)
so we can drop the unless File.exists?
from here as well.
ae13752
to
22887d9
Compare
@@ -123,6 +126,14 @@ defmodule Mix.Tasks.Hex.Docs do | |||
open_file(index_path) | |||
end | |||
|
|||
defp find_package_version(name, opts) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I am not very happy with this function, but we somehow need check the latest version based on cache or remote version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good imo.
@@ -113,7 +113,10 @@ defmodule Mix.Tasks.Hex.Docs do | |||
end | |||
|
|||
defp open_docs_offline([name], opts) do | |||
latest_version = find_latest_version("#{opts[:home]}/#{name}") | |||
{ is_missing, latest_version } = find_package_version(name, opts) | |||
if is_missing && Mix.shell.yes?("Documentation file not found, would you like to download it?") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done automatically, we should not prompt the user. If the user says no, it would just crash anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -113,7 +113,10 @@ defmodule Mix.Tasks.Hex.Docs do | |||
end | |||
|
|||
defp open_docs_offline([name], opts) do | |||
latest_version = find_latest_version("#{opts[:home]}/#{name}") | |||
{ is_missing, latest_version } = find_package_version(name, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the spaces inside {}
.
Sorry for the back and forth but we should not prompt the user in this On Sat, Sep 24, 2016 at 8:15 PM, Ilija Eftimov [email protected]
Eric Meadows-Jönsson |
22887d9
to
ed8f83b
Compare
No probs. PR updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Took a stab at #290
With this implementation, the task checks if the documentation for the package is locally present. Otherwise, it will fetch the latest version and open it in the browser.