From d389ee637044b09eb1c91f9a5d21dceebf71e520 Mon Sep 17 00:00:00 2001 From: Long Vu Date: Fri, 22 Jan 2021 14:45:41 -0500 Subject: [PATCH] move MetadataUrl to pywps.app.Common to avoid dependencies on sphinx Steps to Reproduce ```bash conda create -n pywps4.2.9 python=3.7 conda activate pywps4.2.9 python setup.py develop python ``` Then ```python from pywps import tests Python 3.7.9 | packaged by conda-forge | (default, Dec 9 2020, 21:08:20) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from pywps import tests Traceback (most recent call last): File "", line 1, in File "/home/david/src/pywps/pywps/tests.py", line 15, in from pywps.ext_autodoc import MetadataUrl File "/home/david/src/pywps/pywps/ext_autodoc.py", line 2, in from sphinx.ext.autodoc import ClassDocumenter, bool_option ModuleNotFoundError: No module named 'sphinx' ``` --- pywps/app/Common.py | 18 ++++++++++++++++++ pywps/ext_autodoc.py | 17 +---------------- pywps/tests.py | 3 +-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pywps/app/Common.py b/pywps/app/Common.py index bf8b77341..c2ba42c12 100644 --- a/pywps/app/Common.py +++ b/pywps/app/Common.py @@ -63,3 +63,21 @@ def __eq__(self, other): self.role == other.role, self.type == other.type, ]) + + +class MetadataUrl(Metadata): + """Metadata subclass to allow anonymous links generation in documentation. + + Useful to avoid Sphinx "Duplicate explicit target name" warning. + + See https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks. + + Meant to use in documentation only, not needed in the xml response, nor being serialized or + deserialized to/from json. So that's why it is not directly in the base class. + """ + + def __init__(self, title, href=None, role=None, type_='simple', + anonymous=False): + super().__init__(title, href=href, role=role, type_=type_) + self.anonymous = anonymous + "Whether to create anonymous link (boolean)." diff --git a/pywps/ext_autodoc.py b/pywps/ext_autodoc.py index 664847505..082b16e29 100644 --- a/pywps/ext_autodoc.py +++ b/pywps/ext_autodoc.py @@ -5,22 +5,7 @@ from sphinx.util import force_decode from docutils.parsers.rst import directives from pywps import Process -from pywps.app.Common import Metadata - - -class MetadataUrl(Metadata): - """Metadata subclass to allow anonymous links generation. - - Useful to avoid Sphinx "Duplicate explicit target name" warning. - - See https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks. - """ - - def __init__(self, title, href=None, role=None, type_='simple', - anonymous=False): - super().__init__(title, href=href, role=role, type_=type_) - self.anonymous = anonymous - "Whether to create anonymous link (boolean)." +from pywps.app.Common import Metadata, MetadataUrl class ProcessDocumenter(ClassDocumenter): diff --git a/pywps/tests.py b/pywps/tests.py index c8d3e84e3..36ad18b47 100644 --- a/pywps/tests.py +++ b/pywps/tests.py @@ -11,8 +11,7 @@ from pywps import Process from pywps.inout import LiteralInput, LiteralOutput, ComplexInput, ComplexOutput, BoundingBoxInput, BoundingBoxOutput from pywps.inout import Format -from pywps.app.Common import Metadata -from pywps.ext_autodoc import MetadataUrl +from pywps.app.Common import Metadata, MetadataUrl import re