diff --git a/CHANGES b/CHANGES index 662c71566..345ef36e2 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ Here you can find the recent changes to libtmux current ------- +- :issue:`303` Add ``common.get_libtmux_version`` which gives the tmux + version as a loose constraint. Fix linking to terms inside docs, and + duplicate description of module which sphinx warned about in api.rst. - *Insert changes/features/fixes for next release here* libtmux 0.8.4 (2020-10-25) diff --git a/docs/api.rst b/docs/api.rst index adcb55fc3..340a0e425 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -86,6 +86,8 @@ Internals .. automethod:: libtmux.common.handle_option_error +.. automethod:: libtmux.common.get_libtmux_version + Exceptions ---------- diff --git a/libtmux/__init__.py b/libtmux/__init__.py index 8b60a1b2c..409994293 100644 --- a/libtmux/__init__.py +++ b/libtmux/__init__.py @@ -1,15 +1,5 @@ # -*- coding: utf-8 -*- # flake8: NOQA -"""API for interfacing with tmux servers, sessions, windows and panes. - -libtmux -~~~~~~~ - -:copyright: Copyright 2016-2018 Tony Narlock. -:license: MIT, see LICENSE for details - -""" - from .__about__ import ( __author__, __copyright__, diff --git a/libtmux/common.py b/libtmux/common.py index dd7eafd64..4df50ec4d 100644 --- a/libtmux/common.py +++ b/libtmux/common.py @@ -668,3 +668,16 @@ def handle_option_error(error): raise exc.AmbiguousOption(error) else: raise exc.OptionError(error) # Raise generic option error + + +def get_libtmux_version(): + """Return libtmux version is a PEP386 compliant format. + + Returns + ------- + distutils.version.LooseVersion + libtmux version + """ + from libtmux.__about__ import __version__ + + return LooseVersion(__version__) diff --git a/libtmux/pane.py b/libtmux/pane.py index 0be1d8151..8c0ef4aae 100644 --- a/libtmux/pane.py +++ b/libtmux/pane.py @@ -18,7 +18,7 @@ class Pane(TmuxMappingObject, TmuxRelationalObject): """ - A :term:`tmux(1)` :term:`pane` [#]_. + A :term:`tmux(1)` :term:`Pane` [#]_. ``Pane`` instances can send commands directly to a pane, or traverse between linked tmux objects. @@ -155,7 +155,9 @@ def reset(self): self.cmd('send-keys', r'-R \; clear-history') - def split_window(self, attach=False, vertical=True, start_directory=None, percent=None): + def split_window( + self, attach=False, vertical=True, start_directory=None, percent=None + ): """ Split window at pane and return newly created :class:`Pane`. diff --git a/libtmux/server.py b/libtmux/server.py index d8a9e7fcc..0172eeed2 100644 --- a/libtmux/server.py +++ b/libtmux/server.py @@ -26,7 +26,7 @@ class Server(TmuxRelationalObject, EnvironmentMixin): """ - The :term:`tmux(1)` :term:`server` [#]_. + The :term:`tmux(1)` :term:`Server` [#]_. - :attr:`Server._sessions` [:class:`Session`, ...] diff --git a/libtmux/session.py b/libtmux/session.py index b99f5002e..a5dfe8ba3 100644 --- a/libtmux/session.py +++ b/libtmux/session.py @@ -27,7 +27,7 @@ class Session(TmuxMappingObject, TmuxRelationalObject, EnvironmentMixin): """ - A :term:`tmux(1)` :term:`session` [#]_. + A :term:`tmux(1)` :term:`Session` [#]_. Holds :class:`Window` objects. diff --git a/libtmux/window.py b/libtmux/window.py index 05ee34c33..2641ad793 100644 --- a/libtmux/window.py +++ b/libtmux/window.py @@ -20,7 +20,7 @@ class Window(TmuxMappingObject, TmuxRelationalObject): """ - A :term:`tmux(1)` :term:`window` [#]_. + A :term:`tmux(1)` :term:`Window` [#]_. Holds :class:`Pane` objects. diff --git a/tests/test_common.py b/tests/test_common.py index 26b9534b5..f16f763ea 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -11,6 +11,7 @@ from libtmux.common import ( TMUX_MAX_VERSION, TMUX_MIN_VERSION, + get_libtmux_version, get_version, has_gt_version, has_gte_version, @@ -201,3 +202,11 @@ def test_session_check_name(session_name, raises, exc_msg_regex): assert exc_info.match(exc_msg_regex) else: session_check_name(session_name) + + +def test_get_libtmux_version(): + from libtmux.__about__ import __version__ + + version = get_libtmux_version() + assert isinstance(version, LooseVersion) + assert LooseVersion(__version__) == version