pyreball.html
Main functions that serve as building blocks of the final html file.
Reference
Class for creating references, i.e. anchors in HTML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_text |
Optional[str]
|
Default text of the link.
This text can be overriden by parameter of |
None
|
Print values as strings to HTML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*values |
Any
|
Zero or more values to be printed. Each value is converted to a string first. |
()
|
sep |
str
|
Separator string to concatenate the values with. Defaults to an empty space. |
''
|
end |
str
|
String appended after the values. Defaults to a newline. |
'\n'
|
print_code_block
print_code_block(*values, caption=None, reference=None, align=None, caption_position=None, numbered=None, cl=None, attrs=None, pre_cl=None, pre_attrs=None, sep='', end='\n', syntax_highlight='python')
Print values as a source code into a preformatted block.
This element is used to display a source code in a block.
It is possible to highlight the code syntax by setting syntax_highlight
parameter to an appropriate string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*values |
Any
|
Zero or more values to be enclosed in the tag. All values are converted to strings. |
()
|
caption |
Optional[str]
|
Text caption. |
None
|
reference |
Optional[Reference]
|
Reference object. |
None
|
align |
Optional[str]
|
How to align the code block horizontally.
Acceptable values are |
None
|
caption_position |
Optional[str]
|
Where to place the caption.
Acceptable values are |
None
|
numbered |
Optional[bool]
|
Whether the caption should be numbered.
Defaults to settings from config or CLI arguments if |
None
|
cl |
ClParameter
|
One or more class names to be added to the |
None
|
attrs |
AttrsParameter
|
Additional attributes to be added to the |
None
|
pre_cl |
ClParameter
|
The same as |
None
|
pre_attrs |
AttrsParameter
|
The same as |
None
|
sep |
str
|
String separator of the values inside the tag. Defaults to an empty string. |
''
|
end |
str
|
String appended after the tag. Defaults to a newline. |
'\n'
|
syntax_highlight |
Optional[str]
|
Syntax highlighting language.
Supported values can be obtained from highlight.js table
https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md
- see column "Aliases". If |
'python'
|
print_div
Print values into a div element.
Any value that is not a string is converted to a string first.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*values |
Any
|
Zero or more values to be printed into the div. |
()
|
cl |
ClParameter
|
One or more class names to be added to the |
None
|
attrs |
AttrsParameter
|
Additional attributes to be added to the |
None
|
sep |
str
|
String separator of the values inside the tag. Defaults to an empty string. |
''
|
end |
str
|
String appended after the tag. Defaults to a newline. |
'\n'
|
print_figure
print_figure(fig, caption=None, reference=None, align=None, caption_position=None, numbered=None, matplotlib_format=None, embedded=None)
Print a figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig |
FigType
|
A figure object. |
required |
caption |
Optional[str]
|
Caption of the figure. |
None
|
reference |
Optional[Reference]
|
Reference object for link creation. |
None
|
align |
Optional[str]
|
How to align the graph horizontally.
Acceptable values are |
None
|
caption_position |
Optional[str]
|
Where to place the caption.
Acceptable values are |
None
|
numbered |
Optional[bool]
|
Whether the caption should be numbered.
Defaults to settings from config or CLI arguments if |
None
|
matplotlib_format |
Optional[str]
|
Format for matplotlib figures.
Acceptable values are |
None
|
embedded |
Optional[bool]
|
Whether to embed the figure directly into HTML;
Only applicable for matplotlib svg images.
Defaults to settings from config or CLI arguments if |
None
|
print_h1
Print h1 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_h2
Print h2 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_h3
Print h3 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_h4
Print h4 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_h5
Print h5 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_h6
Print h6 heading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
Content of the heading. |
required |
reference |
Optional[Reference]
|
Reference object. |
None
|
print_table
print_table(df, caption=None, reference=None, align=None, caption_position=None, numbered=None, col_align=None, display_option=None, paging_sizes=None, scroll_y_height=None, scroll_x=None, sortable=None, sorting_definition=None, search_box=None, datatables_style=None, datatables_definition=None, **kwargs)
Print pandas DataFrame into HTML.
It uses DataTables JavaScript library to display the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
Data frame to be printed. |
required |
caption |
Optional[str]
|
Text caption. |
None
|
reference |
Optional[Reference]
|
Reference object. |
None
|
align |
Optional[str]
|
How to align the table horizontally.
Acceptable values are |
None
|
caption_position |
Optional[str]
|
Where to place the caption.
Acceptable values are |
None
|
numbered |
Optional[bool]
|
Whether the caption should be numbered.
Defaults to settings from config or CLI arguments if |
None
|
col_align |
Optional[Union[str, List[str]]]
|
Alignment of individual columns. Can be provided as a list
of values |
None
|
display_option |
Optional[str]
|
How to display the table. This option is useful for long tables,
which should not be displayed fully. Acceptable values are:
|
None
|
paging_sizes |
Optional[List[Union[int, str]]]
|
A list of page sizes to display in paging mode.
Allowed values in the list are integer values and string
|
None
|
scroll_y_height |
Optional[str]
|
Height of the tables when |
None
|
scroll_x |
Optional[bool]
|
Whether to allow scrolling on the x-axis. If set to |
None
|
sortable |
Optional[bool]
|
Whether to allow sortable columns.
Defaults to settings from config or CLI arguments if |
None
|
sorting_definition |
Optional[List[Tuple[int, str]]]
|
How to sort the table columns initially,
in the form of a list of tuples |
None
|
search_box |
Optional[bool]
|
Whether to show the search box for the table.
Defaults to settings from config or CLI arguments if |
None
|
datatables_style |
Optional[Union[str, List[str]]]
|
One or more class names for styling tables using Datatables styling. See https://datatables.net/manual/styling/classes for possible values. Can be either a string with the class name, or a list of class name strings. |
None
|
datatables_definition |
Optional[Dict[str, Any]]
|
Custom setup for datatables in the form of a dictionary.
This dictionary is serialized to json and passed to |
None
|
**kwargs |
Any
|
Other parameters to pandas |
{}
|
set_title
Set page title.
Note that this function does not have to be called at the beginning of the script. If this function is not called via pyreball and parameter keep_stdout is set to True, it just prints the title to stdout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Title string. |
required |