Skip to content

Commit c56c695

Browse files
committed
updating the plugin system docs
1 parent 1228422 commit c56c695

File tree

2 files changed

+50
-41
lines changed

2 files changed

+50
-41
lines changed

docs/plugin_system.rst

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,14 @@ JSON
3434
Developing a Plugin
3535
-------------------
3636

37-
.. module:: tmuxp
38-
39-
Plugin API
40-
^^^^^^^^^^
41-
42-
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.before_workspace_builder
43-
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.on_window_create
44-
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.after_window_finished
45-
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.before_script
46-
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.reattach
47-
48-
49-
Example Plugin
50-
--------------
51-
52-
Tmuxp expects all plugins to be class within a python submodule named
37+
tmuxp expects all plugins to be class within a python submodule named
5338
``plugin`` that is within a python module that is installed in the local
5439
python environment. A plugin interface is provided by tmuxp to inherit.
5540

5641
`poetry`_ is the chosen python package manager for tmuxp. It is highly
5742
suggested to use it when developing tmuxp plugins; however, ``pip`` will work
58-
just as well.
43+
just as well. Only one of the configuration files is needed for the packaging tool that the
44+
package developer desides to use.
5945

6046
.. code-block:: bash
6147
@@ -66,6 +52,7 @@ just as well.
6652
├── pyproject.toml # Poetry's module configuration file
6753
└── setup.py # pip's module configuration file
6854
55+
6956
The `plugin.py` file could contain something like the following:
7057

7158
.. code-block:: python
@@ -75,6 +62,13 @@ The `plugin.py` file could contain something like the following:
7562
7663
class MyTmuxpPlugin(TmuxpPluginInterface):
7764
def __init__(self):
65+
"""
66+
Currently optional.
67+
68+
In the current version of the plugin interface, the __init__
69+
isn't being utilized. However, it does provide a space for
70+
later additions to the interface.
71+
"""
7872
super.__init__(self)
7973
8074
def before_workspace_builder(self, session):
@@ -87,9 +81,19 @@ The `plugin.py` file could contain something like the following:
8781
Once this plugin is installed in the local python environment, it can be used
8882
in a configuration file like the following:
8983

90-
.. code-block: yaml
84+
.. code-block:: yaml
9185
9286
session_name: plugin example
9387
plugins:
9488
- my_plugin_module.plugin.MyTmuxpPlugin
9589
# ... the rest of your config
90+
91+
92+
Plugin API
93+
----------
94+
95+
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.before_workspace_builder
96+
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.on_window_create
97+
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.after_window_finished
98+
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.before_script
99+
.. automethod:: tmuxp.plugin.TmuxpPluginInterface.reattach

tmuxp/plugin.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,70 @@ def before_workspace_builder(self, session):
99
"""
1010
Provide a session hook previous to creating the workspace.
1111
12+
This runs after the session has been created but before any of
13+
the windows/panes/commands are entered.
14+
1215
Parameters
1316
----------
1417
session : :class:`libtmux.Session`
1518
session to hook into
16-
17-
Notes
18-
-----
19-
This runs after the session has been created but before any of
20-
the windows/panes/commands are entered.
2119
"""
2220
pass
2321

2422
def on_window_create(self, window):
2523
"""
26-
Provide a window hook previous to creating the window.
24+
Provide a window hook previous to doing anything with a window.
25+
26+
This runs runs before anything is created in the windows, like panes.
2727
2828
Parameters
2929
----------
3030
window: :class:`libtmux.Window`
3131
window to hook into
32-
33-
Notes
34-
-----
35-
This runs runs before anything is created in the windows, like panes.
3632
"""
3733
pass
3834

3935
def after_window_finished(self, window):
4036
"""
4137
Provide a window hook after creating the window.
4238
39+
This runs after everything has been created in the window, including
40+
the panes and all of the commands for the panes. It also runs after the
41+
``options_after`` has been applied to the window.
42+
4343
Parameters
4444
----------
4545
window: :class:`libtmux.Window`
4646
window to hook into
47-
48-
Notes
49-
-----
50-
This runs after everything has been created in the window, including
51-
the paes and all of the commands for the panes. It also runs after the
52-
``options_after`` have been applied to the window.
5347
"""
5448
pass
5549

5650
def before_script(self, session):
5751
"""
5852
Provide a session hook after the workspace has been built.
5953
54+
This runs after the workspace has been loaded with ``tmuxp load``. It
55+
augments instead of replaces the ``before_script`` section of the
56+
configuration.
57+
58+
This hook provides access to the LibTmux.session object for any
59+
behavior that would be used in the ``before_script`` section of the
60+
configuration file that needs access directly to the session object.
61+
This runs after the workspace has been loaded with ``tmuxp load``.
62+
63+
The hook augments, rather than replaces, the ``before_script`` section
64+
of the configuration. While it is possible to do all of the
65+
``before_script`` configuration in this function, if a shell script
66+
is currently being used for the configuration, it would be cleaner to
67+
continue using the script in the ``before_section``.
68+
69+
If changes to the session need to be made prior to
70+
anything being built, please use ``before_workspace_builder`` instead.
71+
6072
Parameters
6173
----------
6274
session : :class:`libtmux.Session`
6375
session to hook into
64-
65-
Notes
66-
-----
67-
This runs after the workspace has been loaded with ``tmuxp load``. It
68-
augments instead of replaces the ``before_script`` section of the
69-
configuration. If changes to the session need to be made prior to
70-
anything being built, please use ``before_workspace_builder`` instead.
7176
"""
7277
pass
7378

0 commit comments

Comments
 (0)