Skip to content

Commit 26ecd54

Browse files
committed
Updated git_ops and lazy doc strings.
1 parent 2a2c052 commit 26ecd54

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

docsrc/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ API Reference
1212
~configuration
1313
~data_merge
1414
~git_ops
15+
~lazy
1516
~pipeline
1617
~templating
1718
~utilities

docsrc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
]
6262
intersphinx_mapping = {
6363
"python": ("https://docs.python.org/3", None),
64+
"gitpython": ("https://gitpython.readthedocs.io/en/stable/", None),
6465
}
6566

6667
templates_path = ["_templates"]

generate_changelog/git_ops.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""git information access."""
22

3-
from typing import Optional
3+
from typing import List, Optional
44

55
import datetime
66
import os
@@ -85,8 +85,16 @@ def parse_commits(repository: Repo, starting_rev: Optional[str] = None, ending_r
8585
return [repository.commit(commit) for commit in commits if commit]
8686

8787

88-
def get_tags(repository: Repo) -> list:
89-
"""Get all the tags in a repository."""
88+
def get_tags(repository: Repo) -> List[TagInfo]:
89+
"""
90+
Get all the tags in a repository.
91+
92+
Args:
93+
repository: The repository object containing the tags
94+
95+
Returns:
96+
A list of TagInfo objects with the most recent first
97+
"""
9098
tags = repository.tags
9199
tags_list = []
92100

@@ -114,8 +122,18 @@ def get_tags(repository: Repo) -> list:
114122
return tags_list
115123

116124

117-
def get_commits_by_tags(repository: Repo, tag_filter_pattern: str, starting_tag: Optional[str] = None) -> list:
118-
"""Group commits by the tags they belong to."""
125+
def get_commits_by_tags(repository: Repo, tag_filter_pattern: str, starting_tag: Optional[str] = None) -> List[dict]:
126+
"""
127+
Group commits by the tags they belong to.
128+
129+
Args:
130+
repository: The git repository object
131+
tag_filter_pattern: A regular expression pattern that matches valid tags as versions
132+
starting_tag: Only include tags after this one
133+
134+
Returns:
135+
A list of dictionaries with tag information with most recent first
136+
"""
119137
from generate_changelog.utilities import pairs
120138

121139
tags = [tag for tag in get_tags(repository) if re.match(tag_filter_pattern, tag.name)]

generate_changelog/lazy.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ class LazyObject:
1414
A wrapper for another class that can be used to delay instantiation of the wrapped object.
1515
1616
Example:
17-
::
18-
context = LazyObject(lambda: Context())
19-
17+
>>> context = LazyObject(lambda: Context())
2018
# Do some other stuff. Context is not evaluated yet.
21-
some_other_code()
22-
19+
>>> some_other_code()
2320
# Only now is Context instantiated and evaluated,
2421
# since we attempt to access an attribute on it
2522
# using __getattr__ which in turn calls _setup().
26-
print(context.run_id)
23+
>>> print(context.run_id)
2724
"""
2825

2926
_wrapped = None

0 commit comments

Comments
 (0)