Compare commits
2 commits
7eca1c27c9
...
a2f8e2f0d2
Author | SHA1 | Date | |
---|---|---|---|
a2f8e2f0d2 | |||
a7aabd7c52 |
23 changed files with 78 additions and 45 deletions
|
@ -1 +1 @@
|
||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/fonts/poppins.css"><title>platypush</title><script defer="defer" type="module" src="/static/js/chunk-vendors.0f6060b6.js"></script><script defer="defer" type="module" src="/static/js/app.55199c6f.js"></script><link href="/static/css/chunk-vendors.0fcd36f0.css" rel="stylesheet"><link href="/static/css/app.72325ef5.css" rel="stylesheet"><link rel="icon" type="image/svg+xml" href="/img/icons/favicon.svg"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#ffffff"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="Platypush"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#ffffff"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"><script defer="defer" src="/static/js/chunk-vendors-legacy.037e71b7.js" nomodule></script><script defer="defer" src="/static/js/app-legacy.08491679.js" nomodule></script></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/fonts/poppins.css"><title>platypush</title><script defer="defer" type="module" src="/static/js/chunk-vendors.0f6060b6.js"></script><script defer="defer" type="module" src="/static/js/app.8e3d4fb1.js"></script><link href="/static/css/chunk-vendors.0fcd36f0.css" rel="stylesheet"><link href="/static/css/app.0a781c41.css" rel="stylesheet"><link rel="icon" type="image/svg+xml" href="/img/icons/favicon.svg"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#ffffff"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="Platypush"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#ffffff"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"><script defer="defer" src="/static/js/chunk-vendors-legacy.037e71b7.js" nomodule></script><script defer="defer" src="/static/js/app-legacy.523328cf.js" nomodule></script></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -64,6 +64,7 @@ export default {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: right;
|
justify-content: right;
|
||||||
|
margin-bottom: 1em;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from typing import Callable, Optional, Type
|
from typing import Callable, List, Optional, Type
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
from platypush.message.event import Event
|
from platypush.message.event import Event
|
||||||
|
@ -13,6 +13,7 @@ from ._parsers import (
|
||||||
BackendParser,
|
BackendParser,
|
||||||
EventParser,
|
EventParser,
|
||||||
MethodParser,
|
MethodParser,
|
||||||
|
Parser,
|
||||||
PluginParser,
|
PluginParser,
|
||||||
ResponseParser,
|
ResponseParser,
|
||||||
SchemaParser,
|
SchemaParser,
|
||||||
|
@ -24,7 +25,7 @@ class Model:
|
||||||
Base class for component models.
|
Base class for component models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_parsers = [
|
_parsers: List[Type[Parser]] = [
|
||||||
BackendParser,
|
BackendParser,
|
||||||
EventParser,
|
EventParser,
|
||||||
MethodParser,
|
MethodParser,
|
||||||
|
@ -51,7 +52,9 @@ class Model:
|
||||||
self.package = obj_type.__module__[len(prefix) :]
|
self.package = obj_type.__module__[len(prefix) :]
|
||||||
self.name = name or self.package
|
self.name = name or self.package
|
||||||
self.last_modified = last_modified
|
self.last_modified = last_modified
|
||||||
self.doc, argsdoc = self._parse_docstring(doc or obj_type.__doc__ or '')
|
self.doc, argsdoc = self._parse_docstring(
|
||||||
|
doc or obj_type.__doc__ or '', obj_type=obj_type
|
||||||
|
)
|
||||||
self.args = {}
|
self.args = {}
|
||||||
self.has_kwargs = False
|
self.has_kwargs = False
|
||||||
|
|
||||||
|
@ -87,7 +90,7 @@ class Model:
|
||||||
yield attr, getattr(self, attr)
|
yield attr, getattr(self, attr)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _parse_docstring(cls, docstring: str):
|
def _parse_docstring(cls, docstring: str, obj_type: type):
|
||||||
new_docstring = ''
|
new_docstring = ''
|
||||||
params = {}
|
params = {}
|
||||||
cur_param = None
|
cur_param = None
|
||||||
|
@ -129,14 +132,14 @@ class Model:
|
||||||
params[cur_param] = cur_param_docstring
|
params[cur_param] = cur_param_docstring
|
||||||
|
|
||||||
for param, doc in params.items():
|
for param, doc in params.items():
|
||||||
params[param] = cls._post_process_docstring(doc)
|
params[param] = cls._post_process_docstring(doc, obj_type=obj_type)
|
||||||
|
|
||||||
return cls._post_process_docstring(new_docstring), params
|
return cls._post_process_docstring(new_docstring, obj_type=obj_type), params
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _post_process_docstring(cls, docstring: str) -> str:
|
def _post_process_docstring(cls, docstring: str, obj_type: type) -> str:
|
||||||
for parsers in cls._parsers:
|
for parsers in cls._parsers:
|
||||||
docstring = parsers.parse(docstring)
|
docstring = parsers.parse(docstring, obj_type=obj_type)
|
||||||
return docstring.strip()
|
return docstring.strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from ._backend import BackendParser
|
from ._backend import BackendParser
|
||||||
|
from ._base import Parser
|
||||||
from ._event import EventParser
|
from ._event import EventParser
|
||||||
from ._method import MethodParser
|
from ._method import MethodParser
|
||||||
from ._plugin import PluginParser
|
from ._plugin import PluginParser
|
||||||
|
@ -10,6 +11,7 @@ __all__ = [
|
||||||
'BackendParser',
|
'BackendParser',
|
||||||
'EventParser',
|
'EventParser',
|
||||||
'MethodParser',
|
'MethodParser',
|
||||||
|
'Parser',
|
||||||
'PluginParser',
|
'PluginParser',
|
||||||
'ResponseParser',
|
'ResponseParser',
|
||||||
'SchemaParser',
|
'SchemaParser',
|
||||||
|
|
|
@ -16,7 +16,7 @@ class BackendParser(Parser):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, *_, **__) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._backend_regex.search(docstring)
|
m = cls._backend_regex.search(docstring)
|
||||||
if not m:
|
if not m:
|
||||||
|
|
|
@ -8,5 +8,5 @@ class Parser(ABC):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, obj_type: type) -> str:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
@ -16,7 +16,7 @@ class EventParser(Parser):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, *_, **__) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._event_regex.search(docstring)
|
m = cls._event_regex.search(docstring)
|
||||||
if not m:
|
if not m:
|
||||||
|
|
|
@ -10,26 +10,53 @@ class MethodParser(Parser):
|
||||||
respective documentation.
|
respective documentation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_method_regex = re.compile(
|
_abs_method_regex = re.compile(
|
||||||
r'(\s*):meth:`(platypush\.plugins\.(.+?))`', re.MULTILINE
|
r'(\s*):meth:`(platypush\.plugins\.(.+?))`', re.MULTILINE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_rel_method_regex = re.compile(r'(\s*):meth:`\.(.+?)`', re.MULTILINE)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, obj_type: type) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._method_regex.search(docstring)
|
m = cls._rel_method_regex.search(docstring)
|
||||||
if not m:
|
if m:
|
||||||
break
|
tokens = m.group(2).split('.')
|
||||||
|
method = tokens[-1]
|
||||||
|
package = obj_type.__module__
|
||||||
|
rel_package = '.'.join(package.split('.')[2:])
|
||||||
|
full_name = '.'.join(
|
||||||
|
[
|
||||||
|
package,
|
||||||
|
'.'.join(obj_type.__qualname__.split('.')[:-1]),
|
||||||
|
method,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
docstring = cls._rel_method_regex.sub(
|
||||||
|
f'{m.group(1)}`{package}.{method} '
|
||||||
|
f'<https://docs.platypush.tech/platypush/plugins/{rel_package}.html#{full_name}>`_',
|
||||||
|
docstring,
|
||||||
|
count=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
m = cls._abs_method_regex.search(docstring)
|
||||||
|
if m:
|
||||||
tokens = m.group(3).split('.')
|
tokens = m.group(3).split('.')
|
||||||
method = tokens[-1]
|
method = tokens[-1]
|
||||||
package = '.'.join(tokens[:-2])
|
package = '.'.join(tokens[:-2])
|
||||||
docstring = cls._method_regex.sub(
|
docstring = cls._abs_method_regex.sub(
|
||||||
f'{m.group(1)}`{package}.{method} '
|
f'{m.group(1)}`{package}.{method} '
|
||||||
f'<https://docs.platypush.tech/platypush/plugins/{package}.html#{m.group(2)}>`_',
|
f'<https://docs.platypush.tech/platypush/plugins/{package}.html#{m.group(2)}>`_',
|
||||||
docstring,
|
docstring,
|
||||||
count=1,
|
count=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
return docstring
|
return docstring
|
||||||
|
|
|
@ -16,7 +16,7 @@ class PluginParser(Parser):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, *_, **__) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._plugin_regex.search(docstring)
|
m = cls._plugin_regex.search(docstring)
|
||||||
if not m:
|
if not m:
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ResponseParser(Parser):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, *_, **__) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._response_regex.search(docstring)
|
m = cls._response_regex.search(docstring)
|
||||||
if not m:
|
if not m:
|
||||||
|
|
|
@ -61,7 +61,7 @@ class SchemaParser(Parser):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, docstring: str) -> str:
|
def parse(cls, docstring: str, *_, **__) -> str:
|
||||||
while True:
|
while True:
|
||||||
m = cls._schema_regex.search(docstring)
|
m = cls._schema_regex.search(docstring)
|
||||||
if not m:
|
if not m:
|
||||||
|
|
|
@ -378,7 +378,7 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC):
|
||||||
@action
|
@action
|
||||||
def get_data(self, *args, **kwargs):
|
def get_data(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
(Deprecated) alias for :meth:`.get_measurement``
|
(Deprecated) alias for :meth:`.get_measurement`
|
||||||
"""
|
"""
|
||||||
return self.get_measurement(*args, **kwargs)
|
return self.get_measurement(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue