Use more docstrings as descriptions
This commit is contained in:
parent
d3f2807bb9
commit
9b387985e3
12 changed files with 88 additions and 59 deletions
|
|
@ -1,6 +1,11 @@
|
|||
"""
|
||||
Top-level representation of attached and enabled plugins
|
||||
"""
|
||||
|
||||
from openflexure_microscope.plugins import PluginLoader, MicroscopePlugin
|
||||
from openflexure_microscope.api.views import MicroscopeViewPlugin
|
||||
from openflexure_microscope.utilities import get_docstring
|
||||
from openflexure_microscope.utilities import get_docstring, description_from_view
|
||||
from openflexure_microscope.api.utilities import blueprint_for_module
|
||||
|
||||
from flask import Blueprint, jsonify, url_for
|
||||
from openflexure_microscope.api.views import MicroscopeView
|
||||
|
|
@ -9,7 +14,6 @@ import copy
|
|||
import logging
|
||||
import warnings
|
||||
|
||||
|
||||
def plugins_representation(plugin_loader_object: PluginLoader):
|
||||
"""
|
||||
Generate a dictionary representation of all plugins, including Flask route URLs
|
||||
|
|
@ -28,7 +32,7 @@ def plugins_representation(plugin_loader_object: PluginLoader):
|
|||
"python_name": plugin._name_python_safe,
|
||||
"plugin": str(plugin),
|
||||
"views": {},
|
||||
"form": plugin.form,
|
||||
"gui": plugin.gui,
|
||||
"description": get_docstring(plugin)
|
||||
}
|
||||
|
||||
|
|
@ -37,10 +41,11 @@ def plugins_representation(plugin_loader_object: PluginLoader):
|
|||
uri = url_for(f"v2_plugins_blueprint.{view_id}")
|
||||
# Make links dictionary if it doesn't yet exist
|
||||
view_d = {
|
||||
"description": get_docstring(view_data["view"]),
|
||||
"links": {"self": uri}
|
||||
}
|
||||
|
||||
view_d.update(description_from_view(view_data["view"]))
|
||||
|
||||
d["views"][view_id] = view_d
|
||||
|
||||
plugins[plugin._name] = d
|
||||
|
|
@ -67,15 +72,13 @@ class PluginFormAPI(MicroscopeView):
|
|||
|
||||
def construct_blueprint(microscope_obj):
|
||||
|
||||
blueprint = Blueprint("v2_plugins_blueprint", __name__)
|
||||
blueprint = blueprint_for_module(__name__)
|
||||
|
||||
# Create a base route to return plugin API forms, if any exist
|
||||
blueprint.add_url_rule(
|
||||
"/", view_func=PluginFormAPI.as_view("plugins", microscope=microscope_obj)
|
||||
)
|
||||
|
||||
all_routes = []
|
||||
|
||||
# For each plugin attached to the microscope object
|
||||
for plugin in microscope_obj.plugins.active:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue