<commit_before>Data Functions
**************

.. contents::
   :local:

.. toctree::

   data/vcs

These functions are designed to be used by themes.

All data functions will return ``true`` (meaning return code ``0``) when they
are both enabled and have data. They will return ``false`` (meaning return code
``1``) when they do not have data. Most will return ``2`` when they are
disabled, either through the config or because the tool they depend on is not
installed. Such disable config options will be documented. Exceptions to this
rule are explicitly documented.

When a function returns ``false``, any return variables are not guaranteed to
be set. If running with ``set -u`` (or when building a theme to be
distributed), guard any return variable accesses with a check of the return
code, or use ``${var-}`` syntax.

Battery
-------

.. function:: _lp_battery() -> var:lp_battery

   Returns a return code depending on the status of the battery:

   * ``5`` if the battery feature is disabled or not available
   * ``4`` if no battery level is found
   * ``3`` if charging and the level is above the threshold
   * ``2`` if charging and the level is under the threshold
   * ``1`` if discharging and the level is above the threshold
   * ``0`` if discharging and the level is under the threshold

   Returns an integer percentage of the current battery level.

   If the threshold is not surpassed, the battery level is still returned.

   The threshold is configured with :attr:`LP_BATTERY_THRESHOLD`.

   Can be disabled by :attr:`LP_ENABLE_BATT`.

Development Environment
-----------------------

.. function:: _lp_kubernetes_context() -> var:lp_kubernetes_context

   Returns ``true`` if a Kubernetes context is found.
   Returns the Kubernetes context name or the first name component.

   Splitting long context names into components is defined by :attr:`LP_DELIMITER_KUBECONTEXT`.

   Can be disabled by :attr:`LP_ENABLE_KUBECONTEXT`.

   .. versionadded:: 2.1

.. function:: _lp_python_env() -> var:lp_python_env

   Retuns ``true`` if a Python or Conda environment is detected. Returns the
   virtual environment name.

   If the environment name contains a forward slash (``/``), only the substring
   after the last forward slash is returned.

   Can be disabled by :attr:`LP_ENABLE_VIRTUALENV`.

   .. versionadded:: 2.0

.. function:: _lp_ruby_env() -> var:lp_ruby_env

   Returns ``true`` if a RVM or RBENV ruby environment is detected. Returns the
   virtual environment name.

   In the case of a RVM environment, the label displayed can be customized
   with the :attr:`LP_RUBY_RVM_PROMPT_OPTIONS`.

   Can be disabled by :attr:`LP_ENABLE_RUBY_VENV`.

   .. versionadded:: 2.1<commit_msg>Fix a typo in a python related function documentation<commit_after>Data Functions
**************

.. contents::
   :local:

.. toctree::

   data/vcs

These functions are designed to be used by themes.

All data functions will return ``true`` (meaning return code ``0``) when they
are both enabled and have data. They will return ``false`` (meaning return code
``1``) when they do not have data. Most will return ``2`` when they are
disabled, either through the config or because the tool they depend on is not
installed. Such disable config options will be documented. Exceptions to this
rule are explicitly documented.

When a function returns ``false``, any return variables are not guaranteed to
be set. If running with ``set -u`` (or when building a theme to be
distributed), guard any return variable accesses with a check of the return
code, or use ``${var-}`` syntax.

Battery
-------

.. function:: _lp_battery() -> var:lp_battery

   Returns a return code depending on the status of the battery:

   * ``5`` if the battery feature is disabled or not available
   * ``4`` if no battery level is found
   * ``3`` if charging and the level is above the threshold
   * ``2`` if charging and the level is under the threshold
   * ``1`` if discharging and the level is above the threshold
   * ``0`` if discharging and the level is under the threshold

   Returns an integer percentage of the current battery level.

   If the threshold is not surpassed, the battery level is still returned.

   The threshold is configured with :attr:`LP_BATTERY_THRESHOLD`.

   Can be disabled by :attr:`LP_ENABLE_BATT`.

Development Environment
-----------------------

.. function:: _lp_kubernetes_context() -> var:lp_kubernetes_context

   Returns ``true`` if a Kubernetes context is found.
   Returns the Kubernetes context name or the first name component.

   Splitting long context names into components is defined by :attr:`LP_DELIMITER_KUBECONTEXT`.

   Can be disabled by :attr:`LP_ENABLE_KUBECONTEXT`.

   .. versionadded:: 2.1

.. function:: _lp_python_env() -> var:lp_python_env

   Returns ``true`` if a Python or Conda environment is detected. Returns the
   virtual environment name.

   If the environment name contains a forward slash (``/``), only the substring
   after the last forward slash is returned.

   Can be disabled by :attr:`LP_ENABLE_VIRTUALENV`.

   .. versionadded:: 2.0

.. function:: _lp_ruby_env() -> var:lp_ruby_env

   Returns ``true`` if a RVM or RBENV ruby environment is detected. Returns the
   virtual environment name.

   In the case of a RVM environment, the label displayed can be customized
   with the :attr:`LP_RUBY_RVM_PROMPT_OPTIONS`.

   Can be disabled by :attr:`LP_ENABLE_RUBY_VENV`.

   .. versionadded:: 2.1
{'fraction_non_alphanumeric': 0.09548198280592647, 'fraction_numerical': 0.0054874702762026705, 'mean_word_length': 3.677502138579983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288970', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1448, 'n_words': 717}