Skip to content

Commit

Permalink
move MetadataUrl to pywps.app.Common to avoid dependencies on sphinx
Browse files Browse the repository at this point in the history
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 "<stdin>", line 1, in <module>
  File "/home/david/src/pywps/pywps/tests.py", line 15, in <module>
    from pywps.ext_autodoc import MetadataUrl
  File "/home/david/src/pywps/pywps/ext_autodoc.py", line 2, in <module>
    from sphinx.ext.autodoc import ClassDocumenter, bool_option
ModuleNotFoundError: No module named 'sphinx'
```
  • Loading branch information
tlvu committed Jan 22, 2021
1 parent effc9cd commit d389ee6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
18 changes: 18 additions & 0 deletions pywps/app/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
17 changes: 1 addition & 16 deletions pywps/ext_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions pywps/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d389ee6

Please sign in to comment.