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
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
format¶
format(value: str, *args: Any, **kwargs: Any) -> str
Apply the given values to a printf-style
_ format string, like
DocStrings
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
|
format_code¶
format_code(code: str, line_length: int = 100)
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
86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
format_filter_signature¶
format_filter_signature(fn: 'Callable', 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' | ffs(filter_name: 'str', follow_wrapped: 'bool' = True, eval_str: 'bool' = False) -> 'str'
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable
|
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
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
format_signature¶
format_signature(fn: 'Callable', 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
|
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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
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.12/pprint.py
57 58 59 60 61 62 |
|
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
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
724 725 726 |
|
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
181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
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
|
Source code in src/jinjarope/htmlfilters.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|