From 355501394b679dde92d5d32016a133f6885a6b0c Mon Sep 17 00:00:00 2001 From: Thomas Druez Date: Tue, 29 Dec 2020 22:09:08 +0400 Subject: [PATCH] Add all the Pipeline steps (graph) as documentation in modals #24 Signed-off-by: Thomas Druez --- scanpipe/pipelines/__init__.py | 13 +++ scanpipe/templates/scanpipe/project_form.html | 93 ++++++++++++++++++- scanpipe/views.py | 5 +- 3 files changed, 104 insertions(+), 7 deletions(-) diff --git a/scanpipe/pipelines/__init__.py b/scanpipe/pipelines/__init__.py index f26031f66..c32e4f78f 100644 --- a/scanpipe/pipelines/__init__.py +++ b/scanpipe/pipelines/__init__.py @@ -139,3 +139,16 @@ def get_pipeline_description(pipeline_location): cmd = f"{sys.executable} {pipeline_location} show" description = subprocess.getoutput(cmd) return description + + +def get_pipeline_steps(pipeline_location): + """ + TODO: Return the provided `pipeline_location` documentation from the docstrings. + TODO: Test from scanpipe.pipelines import *; get_pipeline_steps("scanpipe/pipelines/docker.py") + """ + pipeline_class = get_pipeline_class(pipeline_location) + pipeline_graph = PipelineGraph(pipeline_class) + nodes = [ + {"name": node.name, "doc": node.doc} for node in pipeline_graph.nodes.values() + ] + return nodes diff --git a/scanpipe/templates/scanpipe/project_form.html b/scanpipe/templates/scanpipe/project_form.html index a5ff7925d..765cc35cd 100644 --- a/scanpipe/templates/scanpipe/project_form.html +++ b/scanpipe/templates/scanpipe/project_form.html @@ -9,6 +9,7 @@ @@ -74,8 +75,13 @@

-
- +
+
+ Cancel +
+
+ +
@@ -83,14 +89,91 @@

Pipelines:

{% for pipeline in pipelines %} -

- {{ pipeline.name }}
+

+
+ + {{ pipeline.name }} + + +
{{ pipeline.description }} -

+
{% endfor %}
+ + \ No newline at end of file diff --git a/scanpipe/views.py b/scanpipe/views.py index f621eec94..0210cf1eb 100644 --- a/scanpipe/views.py +++ b/scanpipe/views.py @@ -27,10 +27,10 @@ from django.views.generic import DetailView from django.views.generic import ListView +from scanpipe import pipelines from scanpipe.api.serializers import scanpipe_app_config from scanpipe.forms import ProjectForm from scanpipe.models import Project -from scanpipe.pipelines import get_pipeline_doc from scanpipe.pipes import codebase from scanpipe.pipes import outputs @@ -53,7 +53,8 @@ def get_context_data(self, **kwargs): { "location": location, "name": name, - "description": get_pipeline_doc(location), + "description": pipelines.get_pipeline_doc(location), + "steps": pipelines.get_pipeline_steps(location), } for location, name in scanpipe_app_config.pipelines ]