Skip to content

Commit

Permalink
chore: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Sep 23, 2023
1 parent 2cf9bad commit 7efde0e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mknodes/basenodes/mknode.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def to_html(self) -> str:
md = self.to_markdown()
reqs = self.get_requirements()
configs = reqs.markdown_extensions
exts = list(configs.keys())
exts = [*list(configs.keys()), "attr_list", "md_in_html"]
return markdown.Markdown(extensions=exts, extension_configs=configs).convert(md)


Expand Down
2 changes: 1 addition & 1 deletion mknodes/theme/mkblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MkBlog(mknav.MkNav):
def __init__(self, section: str | None = "Blog", **kwargs: Any):
super().__init__(section=section, **kwargs)
self.authors: dict[str, Author] = {}
self.posts = mknav.MkNav("posts", parent=self)
# self.posts = mknav.MkNav("posts", parent=self)
# self.index_page = mkpage.MkPage()

def add_author(
Expand Down
11 changes: 11 additions & 0 deletions mknodes/theme/mkgitblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class Commit:


def get_latest_commits(owner: str, repo: str, page: int = 1):
"""Return latest commits from given repository.
Arguments:
owner: Repository owner
repo: Repository name
page: page to get. Each page contains max 100 commits.
"""
url = f"https://api.github.com/repos/{owner}/{repo}/commits?per_page=100&page={page}"
response = downloadhelpers.download(url)
commits = json.loads(response.decode())
Expand Down Expand Up @@ -61,6 +68,8 @@ def get_latest_commits(owner: str, repo: str, page: int = 1):


class MkGitBlog(mkblog.MkBlog):
"""The MkDocs-Material plugin-blog, misused as a Git log."""

def __init__(self, org: str, repo: str, posts_dir: str | os.PathLike, **kwargs):
super().__init__(**kwargs)
self.commits: list[mkblog.MkBlogPost] = []
Expand All @@ -69,6 +78,7 @@ def __init__(self, org: str, repo: str, posts_dir: str | os.PathLike, **kwargs):
self.repo = repo

def add_commits(self):
"""Fetch commits and add them to the blog."""
commits = get_latest_commits(self.org, self.repo)
for c in commits:
if c.author_login not in self.authors:
Expand All @@ -84,6 +94,7 @@ def add_commits(self):
avatar=c.committer_avatar,
)
self.add_post(
title=c.message,
date=c.author_date,
authors=list({c.author_login, c.committer_login}),
text=c.message,
Expand Down

0 comments on commit 7efde0e

Please sign in to comment.