Skip to content

Commit

Permalink
[docs] Show commands for popup layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
elParaguayo committed Aug 17, 2024
1 parent dcc8935 commit 1eef672
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/manual/ref/popup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ flexibility to users, there are a number of different layouts available in the t
:exclude-base:
:no-commands:
:show-config:
:methods: show,hide,unhide,kill,update_controls,bind_callbacks


.. _ref-popup-controls:
Expand Down
16 changes: 15 additions & 1 deletion docs/sphinx_qtile_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
{% if no_config %}:no-config:{% endif %}
{% if no_commands %}:no-commands:{% endif %}
{% if show_config %}:show-config:{% endif %}
{% if methods %}:methods: {{ methods }}{% endif %}
"""
)

Expand Down Expand Up @@ -177,6 +178,11 @@
.. automethod:: {{ module }}.{{ class_name }}.{{ cmd }}
{% endfor %}
{% endif %}
{% if has_methods %}
{% for method in methods %}
.. automethod:: {{ module }}.{{ class_name }}.{{ method }}
{% endfor %}
{% endif %}
{% endif %}
"""
)
Expand Down Expand Up @@ -219,6 +225,7 @@ class QtileClass(SimpleDirectiveMixin, Directive):
"show-config": directives.flag,
"no-commands": directives.flag,
"exclude-base": directives.flag,
"methods": directives.unchanged,
}

def make_rst(self):
Expand Down Expand Up @@ -265,6 +272,8 @@ def make_rst(self):
for k, v in widget_shots.items()
}

methods = [m for m in self.options.get("methods", "").split(",") if m]

context = {
"module": module,
"class_name": class_name,
Expand All @@ -281,7 +290,10 @@ def make_rst(self):
"compatibility": getattr(obj, "_qte_compatibility", False),
"widget_screenshots": widget_shots,
"is_widget": is_widget,
"methods": methods,
"has_methods": bool(methods),
}

if context["commandable"]:
context["commands"] = [
# Command methods have the "_cmd" attribute so we check for this
Expand All @@ -300,12 +312,13 @@ class QtileModule(SimpleDirectiveMixin, Directive):
# :baseclass: <base class path>
# :no-commands:
# :no-config:
optional_arguments = 4
optional_arguments = 5
option_spec = {
"baseclass": directives.unchanged,
"no-commands": directives.flag,
"exclude-base": directives.flag,
"show-config": directives.flag,
"methods": directives.unchanged,
}

def make_rst(self):
Expand All @@ -331,6 +344,7 @@ def make_rst(self):
"class_name": item,
"no_commands": "no-commands" in self.options,
"show_config": "show-config" in self.options,
"methods": self.options.get("methods", ""),
}

rst = qtile_module_template.render(**context)
Expand Down
11 changes: 8 additions & 3 deletions qtile_extras/popup/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def show(
`relative_to` parameter. The parameter is an integer from 1 to 9 representing the
screen broken into a 3x3 grid:
.. ::
.. code::
1 2 3
Expand All @@ -258,7 +258,7 @@ def show(
the bar or gap (including any margin) nearest the point on the above grid
i.e. if ``relative_to=1`` then the y coordinate would be adjusted for any bar on the
top of the screen and the x would be adjusted for any bar on the left. NB If you set
``relative_to-bar=True`` and you use a float value for x and/or y, the float value is
``relative_to_bar=True`` and you use a float value for x and/or y, the float value is
still calculated by reference to the whole screen's dimensions (i.e. including the space
occupied by the bar).
Expand Down Expand Up @@ -389,7 +389,12 @@ def hide(self):
"""Hide the popup."""
self.popup.hide()

def unhide(self):
"""Unhide the popup."""
self.popup.unhide()

def kill(self):
"""Kill the popup window."""
if self.keyboard_navigation:
self.unset_hooks()
self.popup.kill()
Expand Down Expand Up @@ -1553,7 +1558,7 @@ class PopupWidget(_PopupWidget):
Mouse clicks are passed on to the widgets.
Currently, widgets will be sized based on the dimensions of the control.
This will override any width/stretching settings in thw widget.
This will override any width/stretching settings in the widget.
"""

defaults = [
Expand Down

0 comments on commit 1eef672

Please sign in to comment.