|
1 |
| -# EmmyLua Doc Cli |
| 1 | +<div align="center"> |
2 | 2 |
|
3 |
| -This is a command line tool for generating EmmyLua doc from Lua source code. |
| 3 | +# 📚 EmmyLua Doc CLI |
4 | 4 |
|
5 |
| -## Installation |
| 5 | +[](https://crates.io/crates/emmylua_doc_cli) |
| 6 | +[](../../LICENSE) |
6 | 7 |
|
| 8 | +</div> |
| 9 | + |
| 10 | +`emmylua_doc_cli` is a powerful command-line tool for generating documentation directly from your Lua source code and EmmyLua annotations. Built with Rust, it offers exceptional performance and is a core component of the `emmylua-analyzer-rust` ecosystem. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## ✨ Features |
| 15 | + |
| 16 | +- **🚀 Blazing Fast**: Leverages Rust's performance to parse and generate documentation for large codebases in seconds. |
| 17 | +- **✍️ Rich Annotation Support**: Intelligently interprets EmmyLua annotations (`---@class`, `---@field`, `---@param`, etc.) to generate detailed and accurate documentation. |
| 18 | +- **🔧 Highly Customizable**: |
| 19 | + - Override the default templates with `--override-template` to match your project's branding. |
| 20 | + - Inject custom content into the main page using the `--mixin` option to add guides, tutorials, or other static pages. |
| 21 | +- **📦 Multiple Output Formats**: Generate documentation in **Markdown** or **JSON** for maximum flexibility. |
| 22 | +- **🤝 CI/CD Ready**: Automate your documentation publishing workflow with seamless integration into services like GitHub Actions. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## 📦 Installation |
| 27 | + |
| 28 | +Install `emmylua_doc_cli` via cargo: |
7 | 29 | ```shell
|
8 | 30 | cargo install emmylua_doc_cli
|
9 | 31 | ```
|
| 32 | +Alternatively, you can grab pre-built binaries from the [**GitHub Releases**](https://github.com/EmmyLua/emmylua-analyzer-rust/releases) page. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## 🚀 Usage |
| 37 | + |
| 38 | +### Basic Usage |
| 39 | + |
| 40 | +Generate documentation for all Lua files in the `src` directory and output to the default `./docs` folder: |
| 41 | +```shell |
| 42 | +emmylua_doc_cli ./src -o ./docs |
| 43 | +``` |
| 44 | + |
| 45 | +### Advanced Usage |
| 46 | + |
| 47 | +#### Generate JSON Output |
| 48 | + |
| 49 | +Output the documentation structure as a JSON file for custom processing: |
| 50 | +```shell |
| 51 | +emmylua_doc_cli . -f json -o ./api.json |
| 52 | +``` |
10 | 53 |
|
11 |
| -## Usage |
| 54 | +#### Customize Site Name |
12 | 55 |
|
| 56 | +Set a custom name for the generated documentation site: |
13 | 57 | ```shell
|
14 |
| -emmylua_doc_cli ./tests/lua --output ./tests/doc |
| 58 | +emmylua_doc_cli . -o ./docs --site-name "My Awesome Project" |
| 59 | +``` |
| 60 | + |
| 61 | +#### Ignore Files |
| 62 | + |
| 63 | +Exclude certain directories or files from the documentation: |
| 64 | +```shell |
| 65 | +emmylua_doc_cli . -o ./docs --ignore "third_party/**,test/**" |
| 66 | +``` |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 🛠️ CI/CD Integration |
| 71 | + |
| 72 | +Automate the process of building and deploying your documentation to GitHub Pages using GitHub Actions. |
| 73 | + |
| 74 | +**Example `.github/workflows/docs.yml`:** |
| 75 | +```yaml |
| 76 | +name: Generate and Deploy Docs |
| 77 | + |
| 78 | +on: |
| 79 | + push: |
| 80 | + branches: |
| 81 | + - main |
| 82 | + |
| 83 | +jobs: |
| 84 | + build: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Checkout |
| 88 | + uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - name: Install Rust toolchain |
| 91 | + uses: dtolnay/rust-toolchain@stable |
| 92 | + |
| 93 | + - name: Install emmylua_doc_cli |
| 94 | + run: cargo install emmylua_doc_cli |
| 95 | + |
| 96 | + - name: Generate Docs |
| 97 | + run: emmylua_doc_cli ./src -o ./docs --site-name "My Project" |
| 98 | +``` |
| 99 | +
|
| 100 | +--- |
| 101 | +
|
| 102 | +## Command Line Options |
| 103 | +
|
| 104 | +``` |
| 105 | +Usage: emmylua_doc_cli [OPTIONS] [WORKSPACE]... |
| 106 | + |
| 107 | +Arguments: |
| 108 | + [WORKSPACE]... Path to the workspace directory |
| 109 | + |
| 110 | +Options: |
| 111 | + -c, --config <CONFIG> Configuration file paths. If not provided, both ".emmyrc.json" and ".luarc.json" will be searched in the workspace directory |
| 112 | + --ignore <IGNORE> Comma separated list of ignore patterns. Patterns must follow glob syntax |
| 113 | + -f, --output-format <OUTPUT_FORMAT> Specify output format [default: markdown] [possible values: json, markdown] |
| 114 | + -o, --output <OUTPUT> Specify output destination (can be stdout when output_format is json) [default: ./output] |
| 115 | + --override-template <OVERRIDE_TEMPLATE> The path of the override template |
| 116 | + --site-name <SITE_NAME> [default: Docs] |
| 117 | + --mixin <MIXIN> The path of the mixin md file |
| 118 | + --verbose Verbose output |
| 119 | + -h, --help Print help |
| 120 | + -V, --version Print version |
15 | 121 | ```
|
0 commit comments