### Install ExDoc as an Escript (CLI) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This command installs ExDoc as an executable script (escript) using Mix. This allows ExDoc to be run directly from the command line without needing to be part of a Mix project's dependencies. ```bash $ mix escript.install hex ex_doc ``` -------------------------------- ### Generate Documentation via Command Line (CLI) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This command-line invocation uses the installed ExDoc escript to generate documentation. It requires the project name, version, the path to the compiled code (ebin directories), the main module, the source code URL, and an optional logo path. It supports multiple ebin directories for umbrella projects. ```bash $ ex_doc "PROJECT_NAME" "PROJECT_VERSION" _build/dev/lib/project/ebin -m "PROJECT_MODULE" -u "https://github.com/GITHUB_USER/GITHUB_REPO" -l path/to/logo.png ``` ```bash $ ex_doc "PROJECT_NAME" "PROJECT_VERSION" _build/dev/lib/app1/ebin _build/dev/lib/app2/ebin -m "PROJECT_MODULE" -u "https://github.com/GITHUB_USER/GITHUB_REPO" -l path/to/logo.png ``` -------------------------------- ### Create Admonition Block (Neutral Example) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This syntax showcases the creation of a neutral admonition block. By changing the CSS class to `{: .neutral}`, the block receives a neutral visual style, suitable for general informational callouts. ```markdown > #### Neutral {: .neutral} > > This syntax will render a neutral block ``` -------------------------------- ### Create Tabbed Content with Elixir and Erlang Code Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This example illustrates how to create tabbed content for different programming languages, specifically Elixir and Erlang. It uses HTML comments `` and `` to delimit the tabbed section, with `h3` headings defining each tab. ```html ### Elixir ```elixir IO.puts "Hello, world!" ``` ### Erlang ```erlang io:fwrite("Hello, world!\n"). ``` ``` -------------------------------- ### Create Admonition Block (Error Example) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This syntax demonstrates how to create an admonition block for an 'error' type using an `h4` heading followed by a CSS class selector `{: .error}`. This visually distinguishes error messages within the documentation. ```markdown > #### Error {: .error} > > This syntax will render an error block ``` -------------------------------- ### Configure Project for ExDoc Output (Elixir/Mix) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This configuration is for Elixir projects using Mix. It defines application details like name, version, and dependencies. The `docs` function specifically sets the main documentation page, a logo path, and includes extra files like README.md for the documentation. ```elixir def project do [ app: :my_app, version: "0.1.0-dev", deps: deps(), # Docs name: "MyApp", source_url: "https://github.com/USER/PROJECT", homepage_url: "http://YOUR_PROJECT_HOMEPAGE", docs: &docs/0 ] end defp docs do [ main: "MyApp", # The main page in the docs logo: "path/to/logo.png", extras: ["README.md"] ] end ``` -------------------------------- ### Configure Dependency Docs Link in Mix (Elixir) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This configuration in `mix.exs` allows ExDoc to correctly link to the documentation of a specific dependency (e.g., `my_dep`) hosted at a provided URL on hexdocs.pm. It's crucial for cross-project linking. ```elixir docs: [ deps: [ my_dep: "https://path/to/docs/" ] ] ``` -------------------------------- ### Configure Dependency Docs Link in Rebar3 (Erlang) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This configuration within `rebar3.config` enables ExDoc to link to the documentation of a specified dependency (e.g., `my_dep`) hosted at a given URL. This is essential for maintaining consistent cross-application documentation. ```erlang {docs, [ {deps, [ {my_dep, "https://path/to/docs/"} ]} ]} ``` -------------------------------- ### Add Makeup HTML Syntax Highlighter (Elixir/Mix) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This snippet shows how to add the `makeup_html` package as a development dependency in an Elixir project using Mix. This enables ExDoc to provide syntax highlighting for HTML code within the generated documentation. ```elixir {:makeup_html, ">= 0.0.0", only: :dev, runtime: false} ``` -------------------------------- ### Add Makeup HTML Syntax Highlighter (Erlang/Rebar3) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This snippet shows how to add the `makeup_html` dependency in an Erlang project using Rebar3. This enables ExDoc to provide syntax highlighting for HTML code within the generated documentation. ```erlang {makeup_html, "0.1.1"} ``` -------------------------------- ### Configure Additional Pages with :extras Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This snippet demonstrates how to configure additional pages for your project documentation using the :extras option. Supported formats include Markdown (.md), Cheatsheets (.cheatmd), and Livebooks (.livemd). ```elixir extras: ["README.md", "LICENSE", "tutorial.livemd", "cheatsheet.cheatmd"] ``` ```erlang {extras, [<<"README.md">>, <<"cheatsheet.cheatmd">>]}. ``` -------------------------------- ### Render Math Expressions with KaTeX (JavaScript) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc JavaScript code to enable rendering of TeX-style mathematical expressions using the KaTeX library. It includes loading KaTeX and its auto-render extension, and attaching an event listener for 'exdoc:loaded' to process math delimiters in the document body. ```html ``` -------------------------------- ### Render Vega-Lite Plots (JavaScript) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc JavaScript code for rendering Vega-Lite specifications embedded in Markdown 'vega-lite' code snippets. It loads necessary Vega, Vega-Lite, and Vega-Embed libraries, and uses an 'exdoc:loaded' event listener to parse JSON specs and embed plots. ```html ``` -------------------------------- ### Add ExDoc as a Dev Dependency (Elixir/Mix) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This snippet shows how to add ExDoc as a development dependency in an Elixir project using Mix. It specifies the version and ensures ExDoc is only used during development and not at runtime, with a warning if the version is outdated. ```elixir def deps do [ {:ex_doc, ">= 0.34", only: :dev, runtime: false, warn_if_outdated: true} ] end ``` -------------------------------- ### Render Mermaid Graphs in ExDoc (JavaScript) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This snippet demonstrates how to render Mermaid graphs within ExDoc. It includes the necessary script tag for the Mermaid CDN and JavaScript code to initialize Mermaid and render graph definitions from 'pre code.mermaid' elements. The script listens for the 'exdoc:loaded' event to ensure the DOM is ready before attempting to render. ```html ``` -------------------------------- ### Configure ExDoc Custom Script Injection (Elixir) Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc Elixir code snippets demonstrating how to configure ExDoc to inject custom HTML content into the head or body of generated documentation pages. This can be done using anonymous functions, module-function tuples, or maps for different output formats like HTML and EPUB. ```elixir docs: [ # ... before_closing_head_tag: &before_closing_head_tag/1, before_closing_body_tag: &before_closing_body_tag/1 ] # ... defp before_closing_head_tag(:html) do """ """ end defp before_closing_head_tag(:epub), do: "" defp before_closing_body_tag(:html) do """ """ end defp before_closing_body_tag(:epub), do: "" ``` ```elixir docs: [ # ... before_closing_head_tag: {MyModule, :before_closing_head_tag, []}, before_closing_body_tag: {MyModule, :before_closing_body_tag, []} ] ``` ```elixir docs: [ # ... before_closing_head_tag: %{html: "...", epub: "..."}, before_closing_body_tag: %{html: "...", epub: "..."} ] ``` -------------------------------- ### Add Module Documentation Metadata in Elixir Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This Elixir code snippet shows how to add metadata, specifically the 'since' version, to a module using the @moduledoc annotation. This metadata is applied to all elements within the module. ```elixir @moduledoc since: "1.10.0" ``` -------------------------------- ### Add Module/Function Metadata in Erlang EDoc Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This Erlang EDoc snippet demonstrates how to add metadata, like the 'since' version, to modules or functions. ```erlang %% @since 0.1.0 ``` -------------------------------- ### Add Function Documentation Metadata in Elixir Source: https://hexdocs.pm/ex_doc/v0.38.4/ex_doc This Elixir code snippet illustrates how to add metadata, such as the 'since' version, to a specific function using the @doc annotation. ```elixir @doc since: "1.13.1" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.