dotenv_elixir icon indicating copy to clipboard operation
dotenv_elixir copied to clipboard

Add docs for hexdocs

Open fireproofsocks opened this issue 4 years ago • 3 comments

It would be useful to groom through the module and function docs so hexdocs can be as useful a reference (if not more) than the Github README.

fireproofsocks avatar Mar 31 '21 21:03 fireproofsocks

@fireproofsocks that would be great! Want to submit a PR?

iloveitaly avatar Mar 31 '21 22:03 iloveitaly

I started combing through things and adding ## Examples blocks -- see PR #40 (comments welcome).

However, I have a couple questions:

I'm confused by the Dotenv.load!/1 vs Dotenv.load/1 -- usually I would expect a function ending with ! to raise on error, and the other to wrap its result in a tuple, but both variants do not handle errors, e.g.

iex(5)> Dotenv.load("asdfas")
** (File.Error) could not read file "asdfas": no such file or directory
    (elixir 1.11.1) lib/file.ex:354: File.read!/1
    (dotenv 3.1.0) lib/dotenv.ex:241: Dotenv.read_env_file/1
    (dotenv 3.1.0) lib/dotenv.ex:158: Dotenv.load/1
iex(5)> Dotenv.load!("asdfas")
** (File.Error) could not read file "asdfas": no such file or directory
    (elixir 1.11.1) lib/file.ex:354: File.read!/1
    (dotenv 3.1.0) lib/dotenv.ex:241: Dotenv.read_env_file/1
    (dotenv 3.1.0) lib/dotenv.ex:158: Dotenv.load/1
    (dotenv 3.1.0) lib/dotenv.ex:135: Dotenv.load!/1

The Dotenv.Env.get/3 function seems to have arguments swapped from what I would expect from the likes of Map.get/3 -- I would expect the default (i.e. "fallback") value to be the 3rd argument, not the 2nd. This seems a mashing of Map.get/3 and Map.get_lazy/3, no?

Would you be open to discussing the organization and approach of this package? I think it could be adjusted to support releases and help simplify the Mix configs.

fireproofsocks avatar Apr 01 '21 02:04 fireproofsocks

Would you be open to discussing the organization and approach of this package? I think it could be adjusted to support releases and help simplify the Mix configs.

Yes, definitely! Submit a PR and I'll take a look. There are definitely lots of improvements to be made last time I took a look.

iloveitaly avatar Apr 01 '21 20:04 iloveitaly