Clean up plugins documentation

This commit is contained in:
jeremystretch 2022-11-15 16:55:18 -05:00
parent 23077821f6
commit 0c0c848597
5 changed files with 20 additions and 15 deletions

View File

@ -16,7 +16,7 @@ menu = PluginMenu(
('Foo', (item1, item2, item3)), ('Foo', (item1, item2, item3)),
('Bar', (item4, item5)), ('Bar', (item4, item5)),
), ),
icon='mdi mdi-router' icon_class='mdi mdi-router'
) )
``` ```

View File

@ -1,5 +1,8 @@
# Search # Search
!!! note
This feature was introduced in NetBox v3.4.
Plugins can define and register their own models to extend NetBox's core search functionality. Typically, a plugin will include a file named `search.py`, which holds all search indexes for its models (see the example below). Plugins can define and register their own models to extend NetBox's core search functionality. Typically, a plugin will include a file named `search.py`, which holds all search indexes for its models (see the example below).
```python ```python

View File

@ -156,6 +156,9 @@ These views are provided to enable or enhance certain NetBox model features, suc
### Additional Tabs ### Additional Tabs
!!! note
This feature was introduced in NetBox v3.4.
Plugins can "attach" a custom view to a core NetBox model by registering it with `register_model_view()`. To include a tab for this view within the NetBox UI, declare a TabView instance named `tab`: Plugins can "attach" a custom view to a core NetBox model by registering it with `register_model_view()`. To include a tab for this view within the NetBox UI, declare a TabView instance named `tab`:
```python ```python
@ -164,7 +167,7 @@ from myplugin.models import Stuff
from netbox.views import generic from netbox.views import generic
from utilities.views import ViewTab, register_model_view from utilities.views import ViewTab, register_model_view
@register_model_view(Site, 'mview', path='some-other-stuff') @register_model_view(Site, name='myview', path='some-other-stuff')
class MyView(generic.ObjectView): class MyView(generic.ObjectView):
... ...
tab = ViewTab( tab = ViewTab(
@ -180,23 +183,22 @@ class MyView(generic.ObjectView):
### Extra Template Content ### Extra Template Content
Plugins can inject custom content into certain areas of the detail views of applicable models. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired methods to render custom content. Four methods are available: Plugins can inject custom content into certain areas of core NetBox views. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired method(s) to render custom content. Five methods are available:
* `left_page()` - Inject content on the left side of the page | Method | View | Description |
* `right_page()` - Inject content on the right side of the page |---------------------|-------------|-----------------------------------------------------|
* `full_width_page()` - Inject content across the entire bottom of the page | `left_page()` | Object view | Inject content on the left side of the page |
* `buttons()` - Add buttons to the top of the page | `right_page()` | Object view | Inject content on the right side of the page |
| `full_width_page()` | Object view | Inject content across the entire bottom of the page |
Plugins can also inject custom content into certain areas of the list views of applicable models using the same subclass of `PluginTemplateExtension`. One method is available: | `buttons()` | Object view | Add buttons to the top of the page |
| `list_buttons()` | List view | Add buttons to the top of the page |
* `list_buttons()` - Add buttons to the top of the list view page
Additionally, a `render()` method is available for convenience. This method accepts the name of a template to render, and any additional context data you want to pass. Its use is optional, however. Additionally, a `render()` method is available for convenience. This method accepts the name of a template to render, and any additional context data you want to pass. Its use is optional, however.
When a PluginTemplateExtension is instantiated, context data is assigned to `self.context`. Available data include: When a PluginTemplateExtension is instantiated, context data is assigned to `self.context`. Available data include:
* `object` - The object being viewed (for detail views only) * `object` - The object being viewed (object views only)
* `model` - The model of the list view (for list views only) * `model` - The model of the list view (list views only)
* `request` - The current request * `request` - The current request
* `settings` - Global NetBox settings * `settings` - Global NetBox settings
* `config` - Plugin-specific configuration parameters * `config` - Plugin-specific configuration parameters

View File

@ -128,12 +128,12 @@ nav:
- Tables: 'plugins/development/tables.md' - Tables: 'plugins/development/tables.md'
- Forms: 'plugins/development/forms.md' - Forms: 'plugins/development/forms.md'
- Filters & Filter Sets: 'plugins/development/filtersets.md' - Filters & Filter Sets: 'plugins/development/filtersets.md'
- Search: 'plugins/development/search.md'
- REST API: 'plugins/development/rest-api.md' - REST API: 'plugins/development/rest-api.md'
- GraphQL API: 'plugins/development/graphql-api.md' - GraphQL API: 'plugins/development/graphql-api.md'
- Background Tasks: 'plugins/development/background-tasks.md' - Background Tasks: 'plugins/development/background-tasks.md'
- Staged Changes: 'plugins/development/staged-changes.md' - Staged Changes: 'plugins/development/staged-changes.md'
- Exceptions: 'plugins/development/exceptions.md' - Exceptions: 'plugins/development/exceptions.md'
- Search: 'plugins/development/search.md'
- Administration: - Administration:
- Authentication: - Authentication:
- Overview: 'administration/authentication/overview.md' - Overview: 'administration/authentication/overview.md'

View File

@ -24,7 +24,7 @@ class SearchIndex:
""" """
Base class for building search indexes. Base class for building search indexes.
Attrs: Attributes:
model: The model class for which this index is used. model: The model class for which this index is used.
category: The label of the group under which this indexer is categorized (for form field display). If none, category: The label of the group under which this indexer is categorized (for form field display). If none,
the name of the model's app will be used. the name of the model's app will be used.