How to generate documentation for mix project? How it can do it?
The procedure for working with the Elixir mix-project:
mix new greeter
command. greeter.ex
file. mix.exs
file. mix docs
command.mix help
can not provide docs
task in a list of possible options:
mix # Runs the default task (current: "mix run")
mix app.start # Starts all registered apps
mix app.tree # Prints the application tree
mix archive # Lists installed archives
mix archive.build # Archives this project into a .ez file
mix archive.install # Installs an archive locally
mix archive.uninstall # Uninstalls archives
mix clean # Deletes generated application files
mix cmd # Executes the given command
mix compile # Compiles source files
mix deps # Lists dependencies and their status
mix deps.clean # Deletes the given dependencies' files
mix deps.compile # Compiles dependencies
mix deps.get # Gets all out of date dependencies
mix deps.tree # Prints the dependency tree
mix deps.unlock # Unlocks the given dependencies
mix deps.update # Updates the given dependencies
mix dialyzer # Runs dialyzer with default or project-defined flags.
mix dialyzer.build # Build the required plt(s) and exit.
mix dialyzer.clean # Delete plt(s) and exit.
mix dialyzer.explain # Display information about dialyzer warnings.
mix do # Executes the tasks separated by comma
mix escript # Lists installed escripts
When I run mix docs
command I get a mix-message:
**(Mix) The task "docs" could not be found. Did you mean "do"?
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
earmark 1.3.2
ex_doc 0.20.2
makeup 0.8.0
makeup_elixir 0.13.0
nimble_parsec 0.5.0
All dependencies are up to date
What is my mistake?
The mix docs
task is available with ExDoc. Make sure that you have the dependency installed. Make sure to check out the docs and install it properly. Then you'll be able to use the mix docs
command.
This is how to install it:
mix.exs
:for Elixir >= 1.7:
def deps do
[
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
]
end
Elixir < 1.7:
def deps do
[
{:ex_doc, "~> 0.18.0", only: :dev, runtime: false},
]
end
mix deps.get
mix docs
There are things you can configure in the project function of your mix file. Such as the name
, source_url
and homepage_url
. Make sure to check out ExDoc's documentation for more details.
Concerning the "task could not be found" error, mix help
lists tasks for the current environment. The default mix environment is :dev
, and above ex_doc
was added to the :dev
environment. However, some projects use a :docs
environment, instead of :dev
.
Also, mix tasks can be provided by compilation, so you may need compile first (also respecting the environment, as above).
So, if the mix docs
task is not listed by mix help
or "could not be found", be sure to run mix compile
and mix help
in the environment of the ex_doc
dependency. For example, run MIX_ENV=docs mix compile
, then MIX_ENV=docs mix help
or MIX_ENV=docs mix docs
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With