API reference
Let it shine!
Creating Shiny Dashboards from Simple Python Mathematical Functions and Sensible Defaults
Imports the standard modules inspect, sys and importlib.
Imports the docstring_parser moudule to generate the input fields
of the Shiny app.
The module docstring_to_markdown is recommended but not needed.
doc_to_markdown(docstring)
Convert docstring to markdown for the documentation tab.
If module docstring_to_markdown is present, then it is used
to format the docstring to markdown. Otherwise the same
docstring is returned.
:param docstring: Docstring to be converted. :type docstring: str
:return: Returns the formated . :rtype: str
len(doc_to_markdown(sum.doc)) 228
Source code in letitshine/__init__.py
letitshine(module_of_function, function_to_interactive, type_of_output=['txt'], tex_output=False)
Create Shiny app from Function in Module
This is the main function of the module.
:param module_of_function: Module of function :type module_of_function: str
:param function_to_interactive: Function to make interactive :type function_to_interactive: str
:return: Returns the code of the shiny app. :rtype: str
Examples
shiny_app=letitshine('letitshine.examples.text_output','say_hello',type_of_output=['txt']) Type of output: ['txt'] Element 0 of output: txt len(shiny_app) 837
Source code in letitshine/__init__.py
shiny_arguments(func, type_of_output='txt', tex_output=False)
Returns the arguments of a function with their default values and types.
The function needs to be a named function. Anonymous functions do not work
Examples
def fun(name:str='Kim'): ... return "Hello "+name ... fun() 'Hello Kim' shiny_fun=shiny_arguments(fun,type_of_output=['txt']) Type of output: ['txt'] Element 0 of output: txt len(shiny_fun) 635
Source code in letitshine/__init__.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
ui_from_function(func)
Takes a Python Function and generates a Shiny UI input
Example:
ui_from_function(lambda my_name: f'Hello {my_name}') '\t\t\tui.input_text("my_name", "my_name?", "Input Text"),\n'
Source code in letitshine/__init__.py
__main__
Use Letitshine module to make Shiny app from function
This script allows the user to generate a shiny python script from a user-supplied function in a Python module.
The requirements are in Python Standard Library: argparse, shutil
sys. The corresponding module is letitshine, see the documentation
of the module for further information.
cli()
Use LetItShine as a command line utility
usage: letitshine_make_app [-h][-i FUNCTION_TO_INTERACTIVE] [-type TYPE_OF_OUTPUT][-create]
This program generates an app.py file to interact with a python code
options: -h, --help show this help message and exit
-i FUNCTION_TO_INTERACTIVE, --function_to_interactive FUNCTION_TO_INTERACTIVE Name of the function and module: name_of_module.funcion_in_module
-type TYPE_OF_OUTPUT, --type_of_output TYPE_OF_OUTPUT Type of Output ('txt', 'tex', 'plot', 'data_frame', 'doc'). If there is more than one output separe them with a comma.
-create, --create_app Create an app file with app_[NAMEOFFUNCTION].py