utils
find_comment_ids(text)
Identify ids in a file.
We encode IDs used in a file in markdown comments to make them easier to find. This function retrieves them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The string to search for the IDs. |
required |
Returns:
Type | Description |
---|---|
Set[str]
|
Set[str]: A set with all identified IDs. |
Source code in mkreports/utils.py
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 |
|
func_ref(x)
Encode a function reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
str
|
reference to a function. |
required |
Returns:
Type | Description |
---|---|
str
|
The encoded string. |
Source code in mkreports/utils.py
87 88 89 90 91 92 93 94 95 96 97 98 |
|
relative_repo_root(path)
Path relative to repo root or just the name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[Path, str]
|
Path to analyze |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path relative to the repo root, just the name otherwise. |
Source code in mkreports/utils.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
repo_root(path=Path('.'))
Find the root of the current repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
A path in the repository. |
Path('.')
|
Returns:
Type | Description |
---|---|
Optional[Path]
|
Optional[Path]: The root of the repo if it is a repo, None otherwise. |
Source code in mkreports/utils.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
serialize_json(obj)
Serialize an object to JSON, removing quotes for special strings.
Source code in mkreports/utils.py
101 102 103 |
|
snake_to_text(x)
Convert snake case to regular text, with each word capitalized.
Source code in mkreports/utils.py
82 83 84 |
|