Utility Functions¶
Utilities for inline manipulating strings.
badge(label, color, message=None, alt='')
¶
Shields.io badge helper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str |
Badge label. |
required |
color |
str |
Badge color. |
required |
message |
Optional[str] |
Badge message. Defaults to None. |
None |
alt |
str |
Alt tag for the badge. Defaults to "". |
'' |
Returns:
Type | Description |
---|---|
str |
description |
bold(text)
¶
Bold wrapper.
code(text)
¶
Code wrapper.
fileobj_open(path_or_file)
¶
Fileobject or Path opener.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_or_file |
Union[str, StringIO] |
Fileobject or Path. |
required |
Returns:
Type | Description |
---|---|
StringIO |
Document fileobject. |
Yields:
Type | Description |
---|---|
Iterator[StringIO] |
Document fileobject. |
from_file(path, start=1, end=None)
¶
File reader helper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[Path,str] |
File path to open. |
required |
start |
int |
Start Line. Defaults to None. |
1 |
end |
int |
End Line. Defaults to None. |
None |
Returns:
Type | Description |
---|---|
str |
Text block. |
header(heading, level)
¶
Heading wrapper.
image(uri, *, text=None, title=None)
¶
Add an image to the document.
italic(text)
¶
Bold wrapper.
link(uri, *, text=None, title=None)
¶
Add an link to the document.
list_item(item, ordered=False, prefix=None)
¶
Returns a list item.
quote(text, qoute_all_lines=False)
¶
Quotes text.
remove_duplicates(seq)
¶
Remove duplicates in a sequence and retain order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seq |
iterable |
Any sequence. |
required |
Returns:
Type | Description |
---|---|
list |
Ordered, unique values. |
sanitise_attribute(string)
¶
Converts any string into a safe python attribute string.
strikethrough(text)
¶
Strikethrough wrapper.