I'm boarding a plane in a few minutes, but I'd like to still have access to hex.docs.
How hard could it be to get docs running locally so I don't need a connection to use them?
It turns out to be very, very easy. The Elixir guys thought of everything!
# From any mix directory mix hex.docs fetch elixir mix hex.docs fetch kino mix hex.docs fetch nx mix hex.docs fetch scholar mix hex.docs fetch livebook ...
You may need to check the versions and fetch a specific one you're interested in...
mix hex.docs fetch nx 0.5.2
On a Mac, the default location for docs is:
I use Caddy so with that it's as easy to run a local instance as a single command from the directory:
cd /Users/<user>/.hex/docs/hexpm caddy file-server --browse --listen :5051
Go to http://localhost:5051 to test.
Let's go ahead and automate this. You could create an alias but I prefer to create small scripts that I keep on my PATH to run again whenever needed. In my case, I have a directory at ~/projects/utils
touch ~/projects/utils/local_docs.sh echo "cd /Users/$(whoami)/.hex/docs/hexpm" > ~/projects/utils/local_docs.sh echo "caddy file-server --browse --listen :5051" >> ~/projects/utils/local_docs.sh echo "cd -" >> ~/projects/utils/local_docs.sh chmod u+x ~/projects/utils/local_docs.sh
Now whenever I want to start my local docs I can just run: