### Install ExDoc as an escript
Source: https://ex-doc.hexdocs.pm/
Install the ExDoc executable globally via Mix.
```bash
$ mix escript.install hex ex_doc
```
--------------------------------
### ExDoc command-line argument examples
Source: https://ex-doc.hexdocs.pm/
Reference values for the ex_doc command-line arguments.
```text
PROJECT_NAME => Ecto
PROJECT_VERSION => 0.1.0
PROJECT_MODULE => Ecto (the main module provided by the library)
GITHUB_USER => elixir-ecto
GITHUB_REPO => ecto
```
--------------------------------
### Define a Greeter module in Elixir
Source: https://ex-doc.hexdocs.pm/cheatsheet.md
A basic module definition and function call example.
```elixir
# hello.exs
defmodule Greeter do
def greet(name) do
message = "Hello, " <> name <> "!"
IO.puts message
end
end
Greeter.greet("world")
```
--------------------------------
### Group extras by file path
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Organize extra guides into groups using Path.wildcard to match file patterns.
```elixir
groups_for_extras: [
"Introduction": Path.wildcard("guides/introduction/*.md"),
"Advanced": Path.wildcard("guides/advanced/*.md")
]
```
--------------------------------
### Group extras by regex
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Organize extra guides into groups using regular expressions to match file paths.
```elixir
groups_for_extras: [
"Introduction": ~r"/introduction/",
"Advanced": ~r"/advanced/"
]
```
--------------------------------
### Configure skip_code_autolink_to
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Examples for skipping specific terms during documentation autolinking.
```elixir
&String.match?(&1, ~r/PrivateModule/)
```
```elixir
["PrivateModule", "PrivateModule.func/1"]
```
--------------------------------
### Configure skip_undefined_reference_warnings_on
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Examples for suppressing undefined reference warnings using lists or functions.
```elixir
["Foo", "Bar.baz/0"]
```
```elixir
&String.match?(&1, ~r/Foo/)
```
```elixir
["pages/deprecations.md"]
```
--------------------------------
### Define and access user map
Source: https://ex-doc.hexdocs.pm/cheatsheet.md
Example of map creation and string concatenation in Elixir.
```elixir
user = %{
name: "John",
city: "Melbourne"
}
```
```elixir
IO.puts "Hello, " <> user.name
```
--------------------------------
### Define Markdown layout variants
Source: https://ex-doc.hexdocs.pm/cheatsheet.md
Example of using inline attribute notation to change presentation.
```markdown
## H2
{: .col-2}
### H3
{: .list-6}
* example 1
* example 2
```
--------------------------------
### ExDoc Development Commands
Source: https://ex-doc.hexdocs.pm/
Standard shell commands for setting up, building, and linting the ExDoc project locally.
```bash
1. Run `mix setup` to install all dependencies
2. Run `mix build` to generate the docs and open up the generated `doc/index.html`
3. (optional) Run `erl -S httpd serve doc/` to serve the docs locally
4. (optional) Run `npm run --prefix assets build:watch` if working on assets for automatic recompilation
5. Run `mix lint` to check linting and formatting (and `mix fix` to automatically fix it)
6. (important) Do not add the files in the `formatters/` directory to your commits, those will be handled by the maintainers
```
--------------------------------
### Generate project documentation with ExDoc
Source: https://ex-doc.hexdocs.pm/ExDoc.md
The generate function serves as the main entry point for creating documentation, requiring the project name, version, source directories, and configuration options.
```elixir
@spec generate(String.t(), String.t(), [Path.t()], Keyword.t()) :: [
%{entrypoint: String.t(), warned?: boolean(), formatter: module()}
]
```
--------------------------------
### Define run callback
Source: https://ex-doc.hexdocs.pm/ExDoc.Formatter.md
The primary entry point for formatters, receiving configuration and nodes to generate documentation output.
```elixir
@callback run(ExDoc.Formatter.Config.t(), [ExDoc.ModuleNode.t()], [
ExDoc.ExtraNode.t() | ExDoc.URLNode.t()
]) ::
%{entrypoint: String.t(), build: [String.t()]}
```
--------------------------------
### Invoke ExDoc for umbrella projects
Source: https://ex-doc.hexdocs.pm/
Specify multiple ebin directories when generating documentation for umbrella projects.
```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
```
--------------------------------
### Compile project for documentation
Source: https://ex-doc.hexdocs.pm/
Ensure the project is compiled before running the ExDoc executable.
```bash
$ cd PATH_TO_YOUR_PROJECT
$ mix compile
```
--------------------------------
### Configure Extra Documentation Pages
Source: https://ex-doc.hexdocs.pm/
Define additional documentation files in your project configuration using the :extras key.
```elixir
extras: ["README.md", "LICENSE", "tutorial.livemd", "cheatsheet.cheatmd"]
```
```erlang
{extras, [<<"README.md">>, <<"cheatsheet.cheatmd">>]}.
```
--------------------------------
### Configure Documentation Redirects
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Map old module or file paths to new locations to prevent broken links. Destinations can include anchors for specific sections.
```elixir
redirects: %{
"MyApp.MyModule" => "MyApp.My.Module",
"get-started" => "quickstart"
}
```
```elixir
redirects: %{
"old-page" => "new-page#relevant-section"
}
```
--------------------------------
### Render Math with KaTeX
Source: https://ex-doc.hexdocs.pm/
Load KaTeX libraries and trigger rendering on the 'exdoc:loaded' event to support TeX-style math expressions.
```html
```
--------------------------------
### ExDoc.generate/4
Source: https://ex-doc.hexdocs.pm/ExDoc.md
Generates documentation for a given project, version, source directories, and configuration options.
```APIDOC
## ExDoc.generate(project, vsn, source_beams, options)
### Description
Generates documentation for the given project, version, source beams directories, and options. By default, it generates HTML, Markdown, and EPUB documents.
### Signature
`generate(String.t(), String.t(), [Path.t()], Keyword.t()) :: [%{entrypoint: String.t(), warned?: boolean(), formatter: module()}]`
### Parameters
- **project** (String.t) - The name of the project.
- **vsn** (String.t) - The version of the project.
- **source_beams** ([Path.t()]) - A list of paths to the compiled BEAM files.
- **options** (Keyword.t) - Configuration options for the documentation generation.
### Options
- **:annotations_for_docs** (function) - Function to add metadata annotations.
- **:api_reference** (boolean) - Whether to generate api-reference.html; default: true.
- **:assets** (map) - Map of source to target directories for assets.
- **:authors** (list) - List of authors.
- **:before_closing_body_tag** (function) - Function to inject HTML before