Skip to content

Commit 09e4ce4

Browse files
authored
Improve: convert docstrings to google convention (#298)
2 parents 5adbaaf + 749c366 commit 09e4ce4

File tree

6 files changed

+121
-120
lines changed

6 files changed

+121
-120
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ repos:
6565
rev: 7.0.0
6666
hooks:
6767
- id: flake8
68+
additional_dependencies:
69+
- flake8-docstrings<2
6870
language: python
6971
args:
7072
- --config=setup.cfg
7173
- --select=E9,F63,F7,F82
74+
- --docstring-convention=google
7275

7376
ci:
7477
autofix_prs: true

mkdocs_rss_plugin/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919

2020
class _DateFromMeta(Config):
21+
"""Sub configuration object for related date options."""
22+
2123
# TODO: remove deprecated code in future version. Only str values will be accepted
22-
# for as_creation and as_update
24+
# for as_creation and as_update
2325
as_creation = config_options.Type(Union[bool, str], default="git")
2426
as_update = config_options.Type(Union[bool, str], default="git")
2527
datetime_format = config_options.Type(str, default="%Y-%m-%d %H:%M")
@@ -28,6 +30,8 @@ class _DateFromMeta(Config):
2830

2931

3032
class _FeedsFilenamesConfig(Config):
33+
"""Sub configuration for feeds filenames."""
34+
3135
json_created = config_options.Type(str, default="feed_json_created.json")
3236
json_updated = config_options.Type(str, default="feed_json_updated.json")
3337
rss_created = config_options.Type(str, default="feed_rss_created.xml")

mkdocs_rss_plugin/git_manager/ci.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424
# ############################################################################
2525
# ########## Functions #############
2626
# ##################################
27+
28+
2729
class CiHandler:
2830
def __init__(self, repo: Git):
2931
self.repo = repo
3032

31-
def raise_ci_warnings(self):
33+
def raise_ci_warnings(self) -> None:
3234
"""Raise warnings when users use mkdocs-rss-plugin on CI build runners."""
33-
3435
if not self.is_shallow_clone():
3536
return None
3637

@@ -86,11 +87,11 @@ def raise_ci_warnings(self):
8687
"""
8788
)
8889

89-
def commit_count(self) -> bool:
90+
def commit_count(self) -> int:
9091
"""Helper function to determine the number of commits in a repository.
9192
92-
:return: Number of commits
93-
:rtype: bool
93+
Returns:
94+
int: Number of commits
9495
"""
9596
refs = self.repo.for_each_ref().split("\n")
9697
refs = [x.split()[0] for x in refs]
@@ -101,12 +102,14 @@ def commit_count(self) -> bool:
101102
return max(counts)
102103

103104
def is_shallow_clone(self) -> bool:
104-
"""Helper function to determine if repository is a shallow clone. \
105+
"""Helper function to determine if repository is a shallow clone.
106+
105107
References & Context:
106108
- https://github.com/timvink/mkdocs-rss-plugin/issues/10
107109
- https://stackoverflow.com/a/37203240/5525118
108110
109-
:return: True if a repo is shallow clone
110-
:rtype: bool
111+
112+
Returns:
113+
bool: True if a repo is shallow clone
111114
"""
112115
return path.exists(".git/shallow")

mkdocs_rss_plugin/plugin.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GitRssPlugin(BasePlugin[RssPluginConfig]):
5858
def __init__(self):
5959
"""Instantiation."""
6060
# pages storage
61-
self.pages_to_filter: list = []
61+
self.pages_to_filter: list[PageInformation] = []
6262
# prepare output feeds
6363
self.feed_created: dict = {}
6464
self.feed_updated: dict = {}
@@ -308,17 +308,16 @@ def on_page_content(
308308
)
309309
)
310310

311-
def on_post_build(self, config: config_options.Config) -> dict | None:
312-
"""The post_build event does not alter any variables. \
313-
Use this event to call post-build scripts. \
314-
See: <https://www.mkdocs.org/user-guide/plugins/#on_post_build>
311+
def on_post_build(self, config: config_options.Config) -> None:
312+
"""The post_build event does not alter any variables. Use this event to call
313+
post-build scripts.
315314
316-
:param config: global configuration object
317-
:type config: config_options.Config
318-
:return: global configuration object
319-
:rtype: dict
320-
"""
315+
See:
316+
<https://www.mkdocs.org/user-guide/plugins/#on_post_build>
321317
318+
Args:
319+
config (config_options.Config): global configuration object
320+
"""
322321
# Skip if disabled
323322
if not self.config.enabled:
324323
return

0 commit comments

Comments
 (0)