elixir - 找不到任务 "docs"。您的意思是 "do"吗?

标签 elixir documentation elixir-mix

如何为 mix 项目生成文档?它是如何做到的?

使用 Elixir 混合项目的过程:

  • 我通过 mix newgreeter 命令生成一个项目。
  • 我在 greeter.ex 文件中添加了一段注释。
  • 我将依赖项添加到 mix.exs 文件中。
  • 我尝试通过 mix docs 生成文档 命令。

混合帮助 无法在可能选项列表中提供docs任务:

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

当我运行 mix docs 命令时,我收到一条混合消息:

**(Mix) 找不到任务“docs”。您指的是“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

我的错误是什么?

最佳答案

mix docs 任务可通过ExDoc 获得。 。确保您已安装依赖项。请务必查看文档并正确安装。然后您就可以使用 mix docs 命令。

安装方法如下:

  • 将其添加到 mix.exs 中的依赖项:

对于 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
  • 运行混合文档

您可以在混合文件的项目功能中配置一些内容。例如 namesource_urlhomepage_url。请务必查看 ExDoc 的文档以获取更多详细信息。

关于“找不到任务”错误,mix help 列出了当前环境的任务。默认的混合环境是:dev,上面的ex_doc被添加到了:dev环境中。然而,some projects使用 :docs 环境,而不是 :dev

此外,混合任务可以通过编译提供,因此您可能需要先编译(也尊重环境,如上所述)。

因此,如果 mix docs 任务未在 mix help 中列出或“无法找到”,请务必运行 mixcompile > 和 mix helpex_doc 依赖项的环境中。例如,运行 MIX_ENV=docs mix compile,然后运行 ​​MIX_ENV=docs mix helpMIX_ENV=docs mix docs

关于elixir - 找不到任务 "docs"。您的意思是 "do"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56270361/

相关文章:

NetBeans |如何在 JavaDoc 窗口中更改字体大小?

erlang-otp - 在线用户存储 Elixir

elixir - 如何从 Mix 任务返回特定的退出代码?

macros - Elixir 报价 vs 逃脱

random - 创建具有随机和唯一数字的列表

elixir - 如何在 Elixir 中使用 `select`?

elixir - 运行混合测试时如何避免 ExUnit.start() 错误

unit-testing - ExUnit - 运行存储在自定义目录中的所有测试(不是测试/)

python - 在 python 模块文档字符串中放入什么?

ruby - 在院子里用@param 标签警告