format (11)
dirname_to_title¶
dirname_to_title(dirname: 'str | os.PathLike[str]') -> 'str'
Return a page tile obtained from a directory name.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirname
|
str | PathLike[str]
|
directory to get a title for |
required |
Source code in src/jinjarope/textfilters.py
extract_body¶
extract_body(src: str) -> str
Get body of source code of given function / class.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
Source code to extract the body from |
required |
Source code in src/jinjarope/textfilters.py
format¶
format(value: str, *args: Any, **kwargs: Any) -> str
Apply the given values to a printf-style_ format string, like
DocStrings
Source code in jinja2/filters.py
format_code¶
format_code(code: str, line_length: int = 100) -> str
Format code to given line length using black.
Example
Jinja call:
Result:AVeryLargeCodeBlock(a_parameter=3, another_parameter=4, abc=False)
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The code to format |
required |
line_length
|
int
|
Line length limit for formatted code |
100
|
Source code in src/jinjarope/textfilters.py
format_filter_signature¶
format_filter_signature(fn: 'Callable[..., Any]', filter_name: 'str', follow_wrapped: 'bool' = True, eval_str: 'bool' = False) -> 'str'
Create a signature for a jinja filter based on filter name and callable.
Example
Jinja call:
Result:fn: 'Callable[..., Any]' | ffs(filter_name: 'str', follow_wrapped: 'bool' = True, eval_str: 'bool' = False) -> 'str'
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Any]
|
The callable to format the signature from |
required |
filter_name
|
str
|
Name of the jinja filter |
required |
follow_wrapped
|
bool
|
Whether to unwrap the callable |
True
|
eval_str
|
bool
|
Un-stringize annotations using eval |
False
|
Source code in src/jinjarope/textfilters.py
format_signature¶
format_signature(fn: 'Callable[..., Any]', follow_wrapped: 'bool' = True, eval_str: 'bool' = True, remove_jinja_arg: 'bool' = False) -> 'str'
Format signature of a callable.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Any]
|
The callable to format the signature from |
required |
follow_wrapped
|
bool
|
Whether to unwrap the callable |
True
|
eval_str
|
bool
|
Un-stringize annotations using eval |
True
|
remove_jinja_arg
|
bool
|
If true, remove the first argument for pass_xyz decorated fns. |
False
|
Source code in src/jinjarope/textfilters.py
pformat¶
pformat(object, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False)
Format a Python object into a pretty-printed representation.
Example
Jinja call:
Result:[1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3,
1,
2,
3]
DocStrings
Source code in python3.13/pprint.py
pprint¶
pprint(value: Any) -> str
Pretty print a variable. Useful for debugging.
Example
Jinja call:
Result:[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]
DocStrings
repr¶
repr(obj, /)
Return the canonical string representation of the object.
DocStrings
slugify¶
slugify(text: 'str | os.PathLike[str]') -> 'str'
Create a slug for given text.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | PathLike[str]
|
text to get a slug for |
required |
Source code in src/jinjarope/textfilters.py
split_url¶
split_url(value: str, query: Optional[Literal['fragment', 'hostname', 'netloc', 'password', 'path', 'port', 'query', 'scheme', 'username']] = None) -> str | dict[str, str]
Split a URL into its parts (and optionally return a specific part).
Example
Jinja call:
{{ "scheme://netloc/path;parameters?query#fragment" | split_url }}
{{ "scheme://netloc/path;parameters?query#fragment" | split_url("path") }}
{'fragment': 'fragment', 'hostname': 'netloc', 'netloc': 'netloc', 'password': None, 'path': '/path;parameters', 'port': None, 'query': 'query', 'scheme': 'scheme', 'username': None}
/path;parameters
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The URL to split |
required |
query
|
QueryStr | None
|
Optional URL part to extract |
None
|