|
| 1 | +# artisan-docs |
| 2 | + |
| 3 | +[](https://github.com/codeinstinctai/artisan-docs/actions) |
| 4 | +[](https://packagist.org/packages/code-instinct/artisan-docs) |
| 5 | +[](LICENSE) |
| 6 | + |
| 7 | +Automatically generate structured reference documentation for **every Artisan command** registered in your Laravel application — including custom commands, third-party packages, and Laravel's own built-in commands. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +```bash |
| 14 | +composer require code-instinct/artisan-docs |
| 15 | +``` |
| 16 | + |
| 17 | +Laravel's auto-discovery will register the service provider automatically. |
| 18 | + |
| 19 | +Optionally publish the config and/or the HTML template: |
| 20 | + |
| 21 | +```bash |
| 22 | +# Publish configuration |
| 23 | +php artisan vendor:publish --tag=artisan-docs-config |
| 24 | + |
| 25 | +# Publish HTML Blade template (for customisation) |
| 26 | +php artisan vendor:publish --tag=artisan-docs-views |
| 27 | +``` |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +### Zero-config (Markdown, outputs to `docs/commands.md`) |
| 34 | +```bash |
| 35 | +php artisan docs:commands |
| 36 | +``` |
| 37 | + |
| 38 | +### Choose output format |
| 39 | +```bash |
| 40 | +php artisan docs:commands --format=html --output=docs/commands.html |
| 41 | +php artisan docs:commands --format=json --output=docs/commands.json |
| 42 | +php artisan docs:commands --format=markdown --output=README-commands.md |
| 43 | +``` |
| 44 | + |
| 45 | +### Filtering |
| 46 | +```bash |
| 47 | +# Only application-defined commands (in App\Console\Commands) |
| 48 | +php artisan docs:commands --only-custom |
| 49 | + |
| 50 | +# Exclude anything that lives in vendor/ |
| 51 | +php artisan docs:commands --exclude-vendor |
| 52 | + |
| 53 | +# Scope to a single namespace |
| 54 | +php artisan docs:commands --namespace=make |
| 55 | + |
| 56 | +# Also surface hidden commands |
| 57 | +php artisan docs:commands --include-hidden |
| 58 | +``` |
| 59 | + |
| 60 | +### CI check — fail if docs are out of sync |
| 61 | +```bash |
| 62 | +php artisan docs:commands --check |
| 63 | +``` |
| 64 | +Exits with code `1` when the committed documentation file does not match the current command structure. Ideal for a CI gate. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Configuration |
| 69 | + |
| 70 | +After publishing, edit `config/artisan-docs.php`: |
| 71 | + |
| 72 | +| Key | Default | Description | |
| 73 | +|-----|---------|-------------| |
| 74 | +| `default_format` | `markdown` | `markdown`, `html`, or `json` | |
| 75 | +| `default_output` | `docs/commands.md` | Output file path (relative to base path) | |
| 76 | +| `include_hidden` | `false` | Include hidden commands | |
| 77 | +| `include_vendor` | `true` | Include vendor package commands | |
| 78 | +| `excluded_namespaces` | `['_', 'completion']` | Namespaces to always skip | |
| 79 | +| `excluded_commands` | `[]` | Specific command names to skip | |
| 80 | +| `groups` | *(see config)* | Map namespace → group display name | |
| 81 | +| `app_command_paths` | `['App\\Console\\Commands\\']` | Paths used to detect custom commands | |
| 82 | +| `html_template` | `artisan-docs::commands` | Blade view for HTML output | |
| 83 | +| `title` | `Artisan Command Reference` | Document title | |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Output Formats |
| 88 | + |
| 89 | +### Markdown |
| 90 | +GitHub-friendly tables for arguments and options, TOC with anchor links, group sections. |
| 91 | + |
| 92 | +### HTML |
| 93 | +Self-contained, dark-themed single-page reference with a sticky sidebar navigation. Zero external dependencies — ship it to GitHub Pages, an S3 bucket, or your internal wiki. |
| 94 | + |
| 95 | +### JSON |
| 96 | +Machine-readable structure for integration with Confluence, Notion, or custom tooling. |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Customising the HTML Template |
| 101 | + |
| 102 | +```bash |
| 103 | +php artisan vendor:publish --tag=artisan-docs-views |
| 104 | +``` |
| 105 | + |
| 106 | +Edit `resources/views/vendor/artisan-docs/commands.blade.php`. |
| 107 | +Update `html_template` in your config to `artisan-docs::commands` (default already points to it after publishing). |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## Testing |
| 112 | + |
| 113 | +```bash |
| 114 | +composer test |
| 115 | +``` |
| 116 | + |
| 117 | +## Linting |
| 118 | + |
| 119 | +```bash |
| 120 | +composer lint |
| 121 | +``` |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Contributing |
| 126 | + |
| 127 | +Contributions are welcome! If you've found a bug, have a feature request, or want to submit a pull request, please read the [Contributing Guidelines](CONTRIBUTING.md) to get started. |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## License |
| 132 | + |
| 133 | +Open-sourced software licensed under the [MIT LICENSE](LICENSE). |
0 commit comments