Skip to content

Commit e87829a

Browse files
committed
Enhance documentation with Windows line endings guidance and add references to DocTest validation plugin examples across multiple files
1 parent e027b7d commit e87829a

10 files changed

Lines changed: 114 additions & 3 deletions

File tree

docs/advanced/debugging-techniques.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,33 @@ bash -n /path/to/script.sh
173173

174174
## Common Issues
175175

176+
### Windows Line Endings (CRLF vs LF)
177+
178+
{: .warning }
179+
> Scripts developed on Windows will have CRLF line endings (`\r\n`) which cause "bad interpreter" errors on Unraid's Linux system.
180+
181+
**Symptom:**
182+
```
183+
bash: /usr/local/emhttp/plugins/myplugin/event/started: /bin/bash^M: bad interpreter: No such file or directory
184+
```
185+
186+
**Fix during build:**
187+
```bash
188+
# Convert all scripts to Unix line endings
189+
find build/ -type f \( -name "*.sh" -o -name "*.page" \) -exec sed -i 's/\r$//' {} \;
190+
find build/usr/local/emhttp/plugins/myplugin/event -type f -exec sed -i 's/\r$//' {} \;
191+
```
192+
193+
**Fix on server:**
194+
```bash
195+
cd /usr/local/emhttp/plugins/myplugin/event
196+
sed -i 's/\r$//' *
197+
chmod 755 *
198+
```
199+
200+
{: .note }
201+
> See the [validation plugin build script](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/build.sh) for a working example that handles line ending conversion automatically.
202+
176203
### Permission Problems
177204

178205
```bash

docs/build-and-packaging.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ myplugin-1.0.0.txz
5959

6060
### Creating the TXZ Package
6161

62+
{: .note }
63+
> See the [DocTest validation plugin build script](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/build.sh) for a complete working example.
64+
6265
```bash
6366
#!/bin/bash
6467
# pkg_build.sh - Build a Slackware package
@@ -75,17 +78,26 @@ mkdir -p "$BUILD_DIR"
7578
# Copy source files preserving structure
7679
cp -R "$SOURCE_DIR"/* "$BUILD_DIR/"
7780

81+
# CRITICAL: Convert Windows line endings to Unix (CRLF → LF)
82+
# Without this, scripts will fail with "bad interpreter" errors
83+
find "$BUILD_DIR" -type f \( -name "*.sh" -o -name "*.page" -o -name "*.cfg" \) -exec sed -i 's/\r$//' {} \;
84+
find "$BUILD_DIR" -path "*/event/*" -type f -exec sed -i 's/\r$//' {} \;
85+
7886
# Set correct permissions
7987
find "$BUILD_DIR" -type d -exec chmod 755 {} \;
8088
find "$BUILD_DIR" -type f -exec chmod 644 {} \;
8189
find "$BUILD_DIR" -name "*.sh" -exec chmod 755 {} \;
90+
find "$BUILD_DIR" -path "*/event/*" -type f -exec chmod 755 {} \;
8291
find "$BUILD_DIR/etc/rc.d" -type f -exec chmod 755 {} \;
8392

8493
# Create the package
8594
cd "$BUILD_DIR"
8695
makepkg -l y -c n "../${PLUGIN_NAME}-${VERSION}.txz"
8796
```
8897

98+
{: .warning }
99+
> **Windows developers**: Always convert line endings before packaging! Scripts with CRLF line endings will fail with `/bin/bash^M: bad interpreter`. See [Debugging Techniques](advanced/debugging-techniques.md#windows-line-endings-crlf-vs-lf) for more details.
100+
89101
> **Note**: If `makepkg` isn't available (you're building on a non-Slackware system), you can use tar directly:
90102
> ```bash
91103
> tar -cJf "../${PLUGIN_NAME}-${VERSION}.txz" .

docs/events.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ flowchart LR
9696

9797
## Creating Event Handlers
9898

99+
{: .note }
100+
> See the [DocTest validation plugin event handlers](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/source/emhttp/event/) for working examples of all 16 documented events.
101+
99102
### Directory Structure
100103

101104
```

docs/getting-started.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,29 @@ Refresh the browser to see changes. Remember to copy changes back to your source
292292
- Check package URL is accessible
293293
- Look at install output for errors
294294

295+
### "Bad Interpreter" Error
296+
297+
If you see errors like `/bin/bash^M: bad interpreter`, your files have Windows line endings (CRLF). Fix with:
298+
299+
```bash
300+
# Convert all scripts to Unix line endings
301+
find . -type f \( -name "*.sh" -o -name "*.page" \) -exec sed -i 's/\r$//' {} \;
302+
```
303+
304+
{: .warning }
305+
> **Windows developers**: Always convert line endings before packaging! Add line ending conversion to your build script. See [Debugging Techniques](advanced/debugging-techniques.md#windows-line-endings-crlf-vs-lf) for details.
306+
307+
### Form Layout Issues
308+
309+
If form fields are misaligned, check that you're using the Dynamix markdown syntax with `: ` (colon-space at line start):
310+
311+
```markdown
312+
_(Label)_:
313+
: <input type="text" name="field">
314+
```
315+
316+
**Not** raw `<dl><dt><dd>` HTML inside `markdown="1"` forms. See [Page Files Troubleshooting](page-files.md#content-shifted-or-layout-issues) for details.
317+
295318
## Next Steps
296319

297320
Now that you have a working plugin:

docs/introduction.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ This documentation will guide you through:
154154
4. **[Packaging](packaging.md)** - Building distribution packages
155155
5. **[Best Practices](best-practices.md)** - Tips from experienced developers
156156

157+
## Working Example: DocTest Validation Plugin
158+
159+
This repository includes a complete, working validation plugin that demonstrates all documented features. You can:
160+
161+
- **[View the source code](https://github.com/mstrhakr/unraid-plugin-docs/tree/main/validation/plugin)** - See how a real plugin is structured
162+
- **[Install it on your server](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/README.md)** - Test documented features live
163+
- **[Check validation results](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/results/)** - See what we've verified against Unraid
164+
165+
The DocTest plugin validates:
166+
- All 16 documented event handlers
167+
- `parse_plugin_cfg()` and `mk_option()` functions
168+
- `$var` array properties
169+
- Page file rendering and form handling
170+
- Notification system integration
171+
157172
## Next Steps
158173

159174
Ready to build your first plugin? Continue to [Your First Plugin](getting-started.md) for a hands-on tutorial.

docs/page-files.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ $containers = $DockerClient->getDockerContainers();
511511
1. Check Menu attribute matches a valid section
512512
2. Verify Cond evaluation returns true
513513
3. Check for PHP syntax errors: `php -l yourfile.page`
514+
4. Check for Windows line endings (CRLF) - see [Debugging Techniques](advanced/debugging-techniques.md#windows-line-endings-crlf-vs-lf)
514515

515516
### Form Not Saving
516517

@@ -524,6 +525,30 @@ $containers = $DockerClient->getDockerContainers();
524525
2. Check file paths are correct
525526
3. Verify files exist in the package
526527

528+
### Content Shifted or Layout Issues
529+
530+
{: .warning }
531+
> Do not use raw `<dl><dt><dd>` HTML inside `markdown="1"` forms. The Dynamix markdown processor expects the colon syntax.
532+
533+
**Wrong (causes layout shift):**
534+
```html
535+
<dl>
536+
<dt>My Label:</dt>
537+
<dd><input type="text" name="field"></dd>
538+
</dl>
539+
```
540+
541+
**Correct:**
542+
```markdown
543+
_(My Label)_:
544+
: <input type="text" name="field">
545+
```
546+
547+
The `: ` (colon-space at start of line) creates proper Dynamix field alignment. For read-only display sections outside forms, use standard HTML tables or `<pre>` blocks.
548+
549+
{: .note }
550+
> See the [DocTest validation plugin](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/source/emhttp/DocTest.page) for a working example of proper form structure.
551+
527552
## Next Steps
528553

529554
- Learn about [Page Headers](page-headers.md) for advanced menu options

docs/plg-file.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ nav_order: 3
88

99
{: .note }
1010
> **Validated against Unraid 7.2.3** - PLG structure and attributes verified against installed plugins.
11+
>
12+
> See the [DocTest validation plugin PLG](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/doctest.plg) for a complete working example.
1113
1214
The `.plg` file is the heart of every Unraid plugin. It's an XML document that tells the plugin system how to install, update, and remove your plugin.
1315

docs/reference/php-functions-reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ nav_order: 1
99

1010
{: .note }
1111
> **Validated against Unraid 7.2.3** - Function locations and implementations verified.
12+
>
13+
> See the [DocTest validation plugin](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/source/emhttp/DocTest.page) for a working example that demonstrates `parse_plugin_cfg()`, `mk_option()`, `$var` array access, and more.
1214
1315
{: .warning }
1416
> This page is a stub. [Help us expand it!](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/CONTRIBUTING.md)

docs/reference/var-array-reference.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ nav_order: 4
99

1010
{: .note }
1111
> **Validated against Unraid 7.2.3** - All properties verified against `/var/local/emhttp/var.ini` on live systems.
12+
>
13+
> See the [DocTest validation plugin](https://github.com/mstrhakr/unraid-plugin-docs/blob/main/validation/plugin/source/emhttp/DocTest.page) for a working example that displays `$var` array values.
1214
1315
## Overview
1416

@@ -73,7 +75,7 @@ This file is continuously updated by the Unraid system to reflect current state.
7375
| `mdResync` | string | Resync position (if active) | Block number |
7476
| `mdResyncSize` | string | Total resync size | Block count |
7577
| `mdResyncAction` | string | Resync action type | `"check"`, `"rebuild"`, `"sync"` |
76-
| `mdNumStripes` | string | Number of stripes | `"1280"` |
78+
| `md_num_stripes` | string | Number of stripes | `"1280"` |
7779
| `mdNumDisks` | string | Number of array disks | `"4"` |
7880
| `mdNumDisabled` | string | Number of disabled disks | `"0"` |
7981
| `mdNumMissing` | string | Number of missing disks | `"0"` |

validation/results/unraid-7.2.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
|----------|--------|--------|-------|
1212
| Event System | 16 | 0 | All 16 documented events validated |
1313
| File Paths | 19 | 1 | Docker socket may not exist if Docker disabled |
14-
| $var Array | 31 | 1 | `mdNumStripes` uses different key name |
14+
| $var Array | 32 | 0 | All properties validated (mdNumStripes → md_num_stripes fixed) |
1515
| PHP Functions | 7 | 0 | All functions found |
16-
| **Total** | **73** | **2** | 97.3% pass rate |
16+
| **Total** | **74** | **1** | 98.7% pass rate |
1717

1818
## Event System Validation
1919

0 commit comments

Comments
 (0)