Skip to content

DOC: Handle exceptions when computing contributors. #23714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions doc/sphinxext/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""
from docutils import nodes
from docutils.parsers.rst import Directive
import git

from announce import build_components

Expand All @@ -19,17 +20,25 @@ class ContributorsDirective(Directive):
name = 'contributors'

def run(self):
components = build_components(self.arguments[0])

message = nodes.paragraph()
message += nodes.Text(components['author_message'])

listnode = nodes.bullet_list()

for author in components['authors']:
para = nodes.paragraph()
para += nodes.Text(author)
listnode += nodes.list_item('', para)
range_ = self.arguments[0]
try:
components = build_components(range_)
except git.GitCommandError:
return [
self.state.document.reporter.warning(
"Cannot find contributors for range '{}'".format(range_),
line=self.lineno)
]
else:
message = nodes.paragraph()
message += nodes.Text(components['author_message'])

listnode = nodes.bullet_list()

for author in components['authors']:
para = nodes.paragraph()
para += nodes.Text(author)
listnode += nodes.list_item('', para)

return [message, listnode]

Expand Down