Skip to content

Commit 3caa57d

Browse files
author
Peter Baumert
committed
docs: set up MkDocs Material site with port status SVG example
- Add mkdocs.yml with Material theme, dark/light toggle, navigation tabs, and GitHub Pages site_url - Reorganise docs/ into 9 focused pages: index, installation, configuration, how-it-works, layout-yaml, layout-css, svg-renderer, virtual-chassis, troubleshooting - Move content from the 226-line README into dedicated pages; README is now a short install guide with a link to the full docs site - Add docs/assets/port-status-example.svg — annotated SVG illustrating all four port status states (full, partial, unconnected, disabled) including the new partial-connection dot overlay from feature/partial-connection-indicator - Replace docs/yaml-layout-schema.md with a redirect stub (content moved to layout-yaml.md) - Add .github/workflows/docs.yml — deploys to GitHub Pages on push to main - Add docs optional-dependency group and Documentation URL to pyproject.toml
1 parent 19f0308 commit 3caa57d

16 files changed

Lines changed: 997 additions & 513 deletions

.github/workflows/docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "docs/**"
9+
- "mkdocs.yml"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
25+
- name: Install MkDocs Material
26+
run: pip install "mkdocs-material>=9.5"
27+
28+
- name: Deploy to GitHub Pages
29+
run: mkdocs gh-deploy --force

README.md

Lines changed: 14 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
![CI](https://github.com/peterbaumert/netbox-device-view/actions/workflows/test.yml/badge.svg)
66
![License](https://img.shields.io/github/license/peterbaumert/netbox-device-view)
77

8-
Renders a visual CSS grid representation of a device's physical ports and interfaces directly on the NetBox device detail page. An SVG renderer is also available for YAML-based layouts.
8+
Renders a visual front/rear panel of a device's physical ports and interfaces directly on the NetBox device detail page. Supports both a CSS Grid renderer and a scalable SVG renderer driven by a YAML layout.
99

10-
![example](https://github.com/peterbaumert/netbox-device-view/blob/main/docs/example_view.png?raw=true)
10+
![example](https://github.com/peterbaumert/netbox-device-view/blob/main/docs/assets/example_view.png?raw=true)
11+
12+
**Full documentation: [peterbaumert.github.io/netbox-device-view](https://peterbaumert.github.io/netbox-device-view/)**
13+
14+
---
1115

1216
## Requirements
1317

@@ -23,204 +27,24 @@ source /opt/netbox/venv/bin/activate
2327
pip install netbox-device-view
2428
```
2529

26-
To ensure the plugin is reinstalled on future NetBox upgrades, add it to `local_requirements.txt`:
30+
Add to `local_requirements.txt` to survive NetBox upgrades:
2731

2832
```bash
2933
echo netbox-device-view >> /opt/netbox/local_requirements.txt
3034
```
3135

32-
Run the migration and collect static files:
33-
34-
```bash
35-
cd /opt/netbox/netbox
36-
python manage.py migrate netbox_device_view
37-
python manage.py collectstatic --no-input
38-
```
39-
40-
## Configuration
41-
42-
Enable the plugin in your NetBox `configuration.py`:
36+
Enable in `configuration.py`:
4337

4438
```python
4539
PLUGINS = ["netbox_device_view"]
46-
47-
PLUGINS_CONFIG = {
48-
"netbox_device_view": {
49-
# Show the port grid inline on the main device tab (default: False)
50-
# When False, the grid is only shown on a dedicated "Device View" tab
51-
"show_on_device_tab": False,
52-
# Where to render the grid when show_on_device_tab is True (default: "bottom")
53-
# "bottom" — below main device content (full_width_page)
54-
# "top" — above main device content (alerts area)
55-
"device_tab_position": "bottom",
56-
},
57-
}
58-
```
59-
60-
## How It Works
61-
62-
For each **Device Type** you create a **DeviceView** object (at *Plugins → Device Views → Add*) with either a **YAML layout** or a raw **CSS layout**. When you visit a device of that type, the plugin renders every interface and port as a clickable cell in the grid.
63-
64-
### Port/Interface name → CSS grid-area name
65-
66-
The plugin derives a `stylename` for each interface and port:
67-
68-
| Interface name | Stylename |
69-
|----------------|-----------|
70-
| `GigabitEthernet0/0/1` | `gigabitethernet0-1` |
71-
| `TenGigabitEthernet1/1/4` | `tengigabitethernet1-4` |
72-
| `GigabitEthernet0/1` | `gigabitethernet-1` |
73-
| `Management0` | `management-0` |
74-
| `eth0` | `eth-0` |
75-
| `1` (numeric only) | `p1` |
76-
77-
**Rules:**
78-
- Names are lowercased
79-
- For the 3-part Cisco format `Type{dev}/{module}/{port}`, stylename is `type{module}-{port}`
80-
- For the 2-part format `Type{dev}/{port}`, stylename is `type-{port}`
81-
- All other names: non-alphanumeric/dot characters are replaced with `-`
82-
- Purely numeric stylenames are prefixed with `p`
83-
- Virtual and LAG interfaces are skipped
84-
85-
---
86-
87-
## Layout formats
88-
89-
A DeviceView supports two layout formats. **YAML is preferred** — it is easier to write, validate, and maintain. Legacy CSS is still fully supported for backward compatibility.
90-
91-
### Render modes
92-
93-
A DeviceView also has a **Render Mode** field:
94-
95-
| Mode | Description |
96-
|------|-------------|
97-
| `css` (default) | CSS Grid renderer — works with both YAML and legacy CSS layouts |
98-
| `svg` | SVG renderer — requires a YAML layout; produces a scalable `<svg>` element |
99-
100-
SVG mode produces the same port positions as CSS mode (using `canvas.cell_size` for coordinates) and supports front/rear faces, module variants, hover tooltips, and click targets. Virtual Chassis devices always fall back to CSS mode.
101-
102-
### YAML layout (recommended)
103-
104-
Fill the **YAML Layout** field with a YAML document describing the device layout. The plugin compiles it to CSS at render time.
105-
106-
Example for a Cisco C9300-24T with an optional 8x 10G expansion module:
107-
108-
```yaml
109-
version: 1
110-
111-
meta:
112-
description: "Cisco Catalyst 9300-24T"
113-
114-
canvas:
115-
columns: 32
116-
rows: 2
117-
118-
views:
119-
front:
120-
rows:
121-
- blank: 14
122-
- group:
123-
spacer: 1
124-
sections:
125-
- sequence:
126-
kind: interface
127-
prefix: "gigabitethernet1-"
128-
start: 1
129-
count: 12
130-
pattern: top-odd
131-
- sequence:
132-
kind: interface
133-
prefix: "gigabitethernet1-"
134-
start: 13
135-
count: 12
136-
pattern: top-odd
137-
- spacer: 4
138-
139-
variants:
140-
C9300-NM-8X:
141-
match: module
142-
rows:
143-
- blank: 14
144-
- group:
145-
spacer: 1
146-
sections:
147-
- sequence:
148-
kind: interface
149-
prefix: "gigabitethernet1-"
150-
start: 1
151-
count: 12
152-
pattern: top-odd
153-
- sequence:
154-
kind: interface
155-
prefix: "gigabitethernet1-"
156-
start: 13
157-
count: 12
158-
pattern: top-odd
159-
- sequence:
160-
kind: interface
161-
prefix: "tengigabitethernet1-"
162-
start: 1
163-
count: 8
164-
pattern: top-odd
16540
```
16641

167-
See [`docs/yaml-layout-schema.md`](docs/yaml-layout-schema.md)
42+
Run migrations and collect static files:
16843

169-
### CSS layout (legacy)
170-
171-
Fill the **Grid Template Area** field with raw CSS. The grid has **32 columns** and uses **20 px cells**.
172-
173-
Placeholder names: `x` — leading blank, `z` — trailing blank, `s0`–`s99` — interior spacers.
174-
175-
```css
176-
/* C9300-24T */
177-
.deviceview.area {
178-
grid-template-areas:
179-
"x x x x x x x x x x x x x x gigabitethernet0-1 gigabitethernet0-3 ... z z z z z"
180-
"x x x x x x x x x x x x x x gigabitethernet0-2 gigabitethernet0-4 ... z z z z z";
181-
}
44+
```bash
45+
cd /opt/netbox/netbox
46+
python manage.py migrate netbox_device_view
47+
python manage.py collectstatic --no-input
18248
```
18349

184-
See [`examples/`](examples/) for ready-made CSS files.
185-
186-
> **Precedence:** if a DeviceView has a YAML layout, it is used and the CSS field is ignored.
187-
188-
### Migrating from CSS to YAML
189-
190-
> [!IMPORTANT]
191-
> If you have existing DeviceViews with CSS `grid_template_area` layouts and want to switch to the SVG renderer, run the bundled management command to convert them automatically:
192-
>
193-
> ```bash
194-
> cd /opt/netbox/netbox
195-
> python manage.py css_to_yaml
196-
> ```
197-
>
198-
> This converts every DeviceView that has a CSS layout but no YAML layout, writes the result into the **YAML Layout** field, and leaves the original CSS untouched (so you can roll back by clearing the YAML field). After running it, set **Render Mode → SVG** on the DeviceViews you want to upgrade.
199-
200-
### Module variants
201-
202-
When a device has an installed module, an extra CSS class matching the module model is added to the device div. In YAML, declare a `variants:` block. In CSS, add a `.deviceview.module{ModelName}.area` rule.
203-
204-
### Virtual Chassis
205-
206-
For virtual chassis devices, each member's CSS areas are scoped with a `.d{vc_position}` suffix automatically. YAML-rendered CSS is scoped the same way.
207-
208-
## Troubleshooting
209-
210-
**Tab not showing / badge count is zero**
211-
No DeviceView exists for this device's type. Go to *Plugins → Device Views → Add* and create one.
212-
213-
**A port is not appearing in the grid**
214-
The port's stylename is not referenced in the CSS. Check what stylename the plugin derives: it follows the rules in the table above. Add a corresponding area name to your `grid-template-areas`.
215-
216-
**Layout looks wrong after adding a module**
217-
Add a `.deviceview.module{ModelName}.area` rule to your CSS that includes the new module ports.
218-
219-
**Virtual chassis ports missing**
220-
Ensure your CSS uses `.area.d{vc_position}` scoped selectors. Each VC member needs its own rule.
221-
222-
**SVG mode shows nothing / falls back to CSS**
223-
SVG mode requires a YAML layout. If the DeviceView has no YAML layout, or the device is part of a Virtual Chassis, it silently falls back to CSS rendering.
224-
225-
**Port status colours not showing in SVG mode**
226-
Status classes (`bg-success`, `bg-secondary`, `bg-danger`) are applied by JavaScript using the `data-stylename` attribute. Ensure the static file `netbox_device_view/css/device_view_svg.css` is collected (`python manage.py collectstatic`).
50+
For configuration options, layout formats, the SVG renderer, and troubleshooting see the **[full documentation](https://peterbaumert.github.io/netbox-device-view/)**.
Lines changed: 128 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)