Use more docstrings as descriptions

This commit is contained in:
Joel Collins 2019-11-20 12:08:25 +00:00
parent d3f2807bb9
commit 9b387985e3
12 changed files with 88 additions and 59 deletions

View file

@ -1,12 +1,16 @@
"""
Top-level representation of enabled actions
"""
from flask import Blueprint, url_for, jsonify
from sys import platform
from openflexure_microscope.utilities import get_docstring
from openflexure_microscope.api.utilities import blueprint_for_module
from openflexure_microscope.utilities import get_docstring, description_from_view
from openflexure_microscope.api.views import MicroscopeView
from . import camera, stage, system
# TODO: Could allowed methods be calculated automatically by looking at what methods exist?
_actions = {
"capture": {
"rule": "/camera/capture/",
@ -53,11 +57,12 @@ def actions_representation():
for name, action in enabled_actions().items():
d = {
"links": {"self": url_for(f".{name}")},
"description": get_docstring(action["view_class"]),
"rule": action["rule"],
"view_class": str(action["view_class"]),
}
d.update(description_from_view(action["view_class"]))
actions[name] = d
return actions
@ -69,7 +74,7 @@ class ActionsAPI(MicroscopeView):
def construct_blueprint(microscope_obj):
global _actions
blueprint = Blueprint("v2_actions_blueprint", __name__)
blueprint = blueprint_for_module(__name__)
# For each enabled action route defined in our dictionary above
for name, action in enabled_actions().items():

View file

@ -9,9 +9,6 @@ from flask import jsonify, request, abort, url_for, redirect, send_file
class CaptureAPI(MicroscopeView):
"""
Create a new image capture.
Allowed methods:
POST
"""
def post(self):
"""
@ -109,9 +106,6 @@ class CaptureAPI(MicroscopeView):
class GPUPreviewStartAPI(MicroscopeView):
"""
Start the onboard GPU preview.
Allowed methods:
POST
"""
def post(self, operation):
"""
@ -157,9 +151,6 @@ class GPUPreviewStartAPI(MicroscopeView):
class GPUPreviewStopAPI(MicroscopeView):
"""
Stop the onboard GPU preview.
Allowed methods:
POST
"""
def post(self, operation):
"""

View file

@ -10,9 +10,6 @@ import logging
class MoveStageAPI(MicroscopeView):
"""
Handle stage movements.
Allowed methods:
POST
"""
def post(self):
"""

View file

@ -6,9 +6,6 @@ import subprocess
class ShutdownAPI(MicroscopeView):
"""
Attempt to shutdown the device
Allowed methods:
POST
"""
def post(self):
"""
@ -25,9 +22,6 @@ class ShutdownAPI(MicroscopeView):
class RebootAPI(MicroscopeView):
"""
Attempt to reboot the device
Allowed methods:
POST
"""
def post(self):
"""