Started re-writing plugin documentation
This commit is contained in:
parent
367c68ad6f
commit
d681a2069d
7 changed files with 54 additions and 28 deletions
|
|
@ -3,7 +3,6 @@ Camera Functionality
|
|||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
picamera.rst
|
||||
basecamera.rst
|
||||
|
|
|
|||
17
docs/source/pluginmounts.rst
Normal file
17
docs/source/pluginmounts.rst
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Plugin mounts
|
||||
===============
|
||||
.. automodule:: openflexure_microscope.plugins
|
||||
:members:
|
||||
|
||||
Default plugins
|
||||
===============
|
||||
|
||||
Microscope plugin
|
||||
+++++++++++++++++
|
||||
.. automodule:: openflexure_microscope.plugins.default.plugin
|
||||
:members:
|
||||
|
||||
Web API plugin
|
||||
++++++++++++++
|
||||
.. automodule:: openflexure_microscope.plugins.default.api
|
||||
:members:
|
||||
|
|
@ -1,11 +1,27 @@
|
|||
Plugin System
|
||||
=============
|
||||
Plugins
|
||||
=======================================================
|
||||
|
||||
.. automodule:: openflexure_microscope.plugins
|
||||
:members:
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Example Plugin
|
||||
--------------
|
||||
Single-file plugins
|
||||
+++++++++++++++++++
|
||||
|
||||
.. automodule:: openflexure_microscope.plugins.default.test_plugin
|
||||
:members:
|
||||
Package plugins
|
||||
+++++++++++++++
|
||||
|
||||
Loading plugins with microscoperc.yaml
|
||||
++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Microscope plugin structure
|
||||
---------------------------
|
||||
|
||||
Adding web API routes
|
||||
---------------------
|
||||
|
||||
Mounting and built-ins
|
||||
----------------------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
pluginmounts.rst
|
||||
|
|
@ -22,5 +22,4 @@ picamera_params:
|
|||
|
||||
# Default plugins
|
||||
plugins:
|
||||
- openflexure_microscope.plugins.default:Plugin
|
||||
- openflexure_microscope.plugins.test_plugin:FirstPlugin
|
||||
- openflexure_microscope.plugins.default:Plugin
|
||||
|
|
@ -7,14 +7,24 @@ import logging
|
|||
|
||||
|
||||
class IdentifyAPI(MicroscopeViewPlugin):
|
||||
|
||||
"""
|
||||
A simple example API plugin, attached through the main microscope plugin.
|
||||
"""
|
||||
def get(self):
|
||||
"""
|
||||
Method to call when an HTTP GET request is made.
|
||||
"""
|
||||
data = self.microscope.plugin.default.identify() # Call a method from our plugin, using the full route
|
||||
return Response(escape(data))
|
||||
|
||||
|
||||
class HelloWorldAPI(MicroscopeViewPlugin):
|
||||
|
||||
"""
|
||||
An even simpler example API plugin, which just returns static data without using the microscope.
|
||||
"""
|
||||
def get(self):
|
||||
"""
|
||||
Method to call when an HTTP GET request is made.
|
||||
"""
|
||||
data = self.plugin.hello_world() # Call a method from our plugin, using the MicroscopeViewPlugin.plugin shortcut
|
||||
return Response(data)
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
from .plugin import FirstPlugin
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
from openflexure_microscope.plugins import MicroscopePlugin
|
||||
|
||||
|
||||
class FirstPlugin(MicroscopePlugin):
|
||||
"""
|
||||
An example Microscope plugin.
|
||||
"""
|
||||
def run(self):
|
||||
"""
|
||||
Demonstrate access to Microscope.camera, and Microscope.stage
|
||||
"""
|
||||
|
||||
response = "My parent camera is {}, and my parent stage is {}.".format(self.microscope.camera, self.microscope.stage)
|
||||
return response
|
||||
Loading…
Add table
Add a link
Reference in a new issue