Compare commits

...

3 commits

Author SHA1 Message Date
9e489bb5cf
Propagate the default/required properties of a parameter upon merge.
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-30 14:57:11 +02:00
1732bfa82c
Fixed _default_docstring regex. 2023-09-30 14:36:08 +02:00
532f5479b3
Added full YAML example for chat.irc configuration. 2023-09-30 14:34:54 +02:00
4 changed files with 34 additions and 4 deletions

View file

@ -49,7 +49,7 @@ steps:
commands: commands:
- echo "Installing required build dependencies" - echo "Installing required build dependencies"
- apk add --update --no-cache make py3-sphinx py3-pip $(cat platypush/install/requirements/alpine.txt) - apk add --update --no-cache make py3-sphinx py3-pip py3-paho-mqtt $(cat platypush/install/requirements/alpine.txt)
- pip install -U hid sphinx-rtd-theme sphinx-book-theme - pip install -U hid sphinx-rtd-theme sphinx-book-theme
- pip install . - pip install .
- mkdir -p /docs/current - mkdir -p /docs/current

View file

@ -22,7 +22,27 @@ class ChatIrcPlugin(RunnablePlugin, ChatPlugin):
def __init__(self, servers: Sequence[dict], **kwargs): def __init__(self, servers: Sequence[dict], **kwargs):
""" """
:param servers: List of servers/channels that the bot will automatically connect/join. :param servers: List of servers/channels that the bot will
automatically connect/join. Format:
.. code-block:: yaml
servers:
- server: irc.example.org
port: 6697
ssl: true
ipv6: false
username: foo
password: bar
nickname: testbot
realname: Test Bot
# List of channels that the bot will automatically join
channels:
- #channel1
- #channel2
- #channel3
""" """
super().__init__(**kwargs) super().__init__(**kwargs)
try: try:

View file

@ -79,6 +79,16 @@ class IntegrationMetadata:
if param.doc and not params[param_name].doc: if param.doc and not params[param_name].doc:
params[param_name].doc = param.doc params[param_name].doc = param.doc
# If the new parameter has required=False,
# then that should also be the value for the current ones
if param.required is False:
params[param_name].required = False
# If the new parameter has a default value, and the current
# one doesn't, then the default value should be set as the new one.
if param.default is not None and params[param_name].default is None:
params[param_name].default = param.default
@classmethod @classmethod
def _merge_actions(cls, actions: Dict[str, Action], new_actions: Dict[str, Action]): def _merge_actions(cls, actions: Dict[str, Action], new_actions: Dict[str, Action]):
""" """

View file

@ -99,7 +99,7 @@ class DocstringParser:
_param_doc_re = re.compile(r"^:param\s+(?P<name>[\w_]+):\s+(?P<doc>.*)$") _param_doc_re = re.compile(r"^:param\s+(?P<name>[\w_]+):\s+(?P<doc>.*)$")
_type_doc_re = re.compile(r"^:type\s+[\w_]+:.*$") _type_doc_re = re.compile(r"^:type\s+[\w_]+:.*$")
_return_doc_re = re.compile(r"^:return:\s+(?P<doc>.*)$") _return_doc_re = re.compile(r"^:return:\s+(?P<doc>.*)$")
_default_docstring = re.compile(r"^Initialize self. See help") _default_docstring = re.compile(r"^\s*Initialize self\. See help.*$")
def __init__( def __init__(
self, self,
@ -186,7 +186,7 @@ class DocstringParser:
ctx.cur_param = m.group("name") ctx.cur_param = m.group("name")
# Skip vararg/var keyword parameters # Skip vararg/var keyword parameters
if ctx.cur_param == ctx.spec.varkw or ctx.spec.varargs: if ctx.cur_param in {ctx.spec.varkw, ctx.spec.varargs}:
return return
ctx.parsed_params[ctx.cur_param] = Parameter( ctx.parsed_params[ctx.cur_param] = Parameter(