Metadata-Version: 2.4
Name: letitshine
Version: 1.1.0
Summary: Let It Shine! Creating Shiny Dashboards from simple Python functions
Author-email: Joaquim Puig <joaquim.puig@upc.edu>
License-Expression: GPL-3.0-or-later
Project-URL: Changelog, https://www.codeberg.org/joaquimpuig/letitshine/blob/main/CHANGELOG.md
Project-URL: Source, https://www.codeberg.org/joaquimpuig/letitshine
Project-URL: Tracker, https://www.codeberg.org/joaquimpuig/letitshine/issues
Project-URL: Documentation, https://web.mat.upc.edu/joaquim.puig/letitshine
Keywords: letitshine
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docstring_parser>=0.17.0
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: coverage; extra == "test"
Provides-Extra: shiny
Requires-Dist: shiny; extra == "shiny"
Provides-Extra: extra
Requires-Dist: docstring_to_markdown>=0.17; extra == "extra"
Provides-Extra: examples
Requires-Dist: pandas; extra == "examples"
Requires-Dist: numpy; extra == "examples"
Requires-Dist: sympy; extra == "examples"
Requires-Dist: matplotlib; extra == "examples"
Dynamic: license-file

[![license](https://img.shields.io/crates/l/wallust?style=flat-square)](https://codeberg.org/letitshine/LICENSE)
[![CodeBerg](https://img.shields.io/badge/Hosted_at-Codeberg-%232185D0?style=flat-square&logo=CodeBerg)](https://codeberg.org/letitshine)

# Let It Shine! 

## Shiny Dashboards from Simple Python Mathematical Functions


![Creating Simple Shiny apps](./docs/assets/img/taylor_limit.gif)


`letitshine` is a Python Module and command line utility that creates an interactive [Shiny](https://shiny.posit.co/py) from a function in a Python module. It tries to use sensible outputs based on the function definition and to be minimal so that the produced Python code can be used as a boilerplate. With the use of [Shinilive for Python](https://shiny.posit.co/py/docs/shinylive.html) it can be further deployed to an interactive static app which is run entirely on the client (no server configuration necessary). It is aimed at users with a basic knowledge of Python but who are users of mathematical and computing libraries in Python and want to share their applications in teaching and research. It does not aim to replace Shiny but to encourage its use lowering the entry barrier.

There are many different possible outputs and inputs a Python can take. In `letitshine`we focus on data types which are common in mathematical and data analysis functions. Presently `letitshine`supports an arbitrary number of input arguments of the following types

Input types
- Boolean: produces a switch.
- Numeric (`int`, `float`): generates input prompts or sliders.
- Strings: generates input boxes and text areas.

and supports any of the following outputs

- String or Numerical output
- Strings with TeX support using KaTex.
- Pyplot plot
- Pandas Dataframes

The dependencies of the pure Python package`letitshine` are minimal. It can be installed as
```bash
git clone https://codeberg.org/joaquimpuig/python-letitshine.git 
pip install -e letitshine
```
prefereably using a Python virtual environment. It will soon be available as a Python package through Pypi.

To check the usage of `letitshine` take a simple  `hello world!` [example](letitshine/examples/text_output.py) written in the the file `text_output.py`

```python
def hello_world(your_name):
    return f'Hello {your_name}, how are you?\n'
```

To create your Shiny app call

```bash
letitshine  -type text  -i  text_output.hello_world  --create_app
```

and this will create an `app_hello_world.py` file which can be rendered with Shiny (assuming Shiny is installed):

```bash
shiny run app_hello_world.py
``` 
and gives a simple Shiny interactive app

![Simple Hello world screenshot](docs/assets/img/hello_world_screenshot.png)

This file can be further custimized according to your needs and knowledge of Shiny. The idea of `letitshine`is to use sensible (opinonated) choices on outputs and inputs which are common in simple mathematical, computing and data apps and which can help beginners share and showcase their computations.

For instance, if we improve the previous simple function with types and docs, such as the `say_hello` function found in the [examples](letitshine/examples/text_output.py):

```python
def say_hello(your_name:str='Agnesi', say_today:bool=True):
    r"""
    What is your name?
    
    In this simple app We simply print your name.

    :param your_name: Name to be printed
    :type your_name: str

    :param say_today: Say today in the sentence?
    :type say_today: bool 
    
    :return: Printed message
    :rtype: str

    Examples
    ===========
    >>> say_hello('Descartes')
    'Hello Descartes, how are you today?\n'
    """
    message= f'Hello {your_name}, how are you today?\n' if say_today else f'Hello {your_name}, how are you?\n'
    return message
```
and running the 

```bash
letitshine -type txt,doc  -i  text_output.say_hello  --create_app 
```
we obtain,`app_say_hello.py` an interactive function for Shiny whose inputs are better suited

![Say Hello screenshot](./docs/assets/img/say_hello_screenshot.png)

## Authors

Joaquim Puig 
