Skip to content

Commit

Permalink
DOC Generated author list from github (#11708)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDLT authored and rth committed Sep 12, 2018
1 parent 2ed18e0 commit 1906c95
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 77 deletions.
75 changes: 0 additions & 75 deletions AUTHORS.rst

This file was deleted.

4 changes: 4 additions & 0 deletions build_tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Makefile for maintenance tools

authors:
python generate_authors_table.py > ../doc/authors.rst
117 changes: 117 additions & 0 deletions build_tools/generate_authors_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""
This script generates an html table of contributors, with names and avatars.
The list is generated from scikit-learn's teams on GitHub, plus a small number
of hard-coded contributors.
The table should be updated for each new inclusion in the teams.
Generating the table requires admin rights.
"""
from __future__ import print_function

import sys
import requests
import getpass

try:
# With authentication: up to 5000 requests per hour.
print("user:", file=sys.stderr)
user = input()
passwd = getpass.getpass()
auth = (user, passwd)
except IndexError:
# Without authentication: up to 60 requests per hour.
auth = None

ROW_SIZE = 7
LOGO_URL = 'https://avatars2.githubusercontent.com/u/365630?v=4'


def group_iterable(iterable, size):
"""Group iterable into lines"""
group = []
for element in iterable:
group.append(element)
if len(group) == size:
yield group
group = []
if len(group) != 0:
yield group


def get_contributors():
"""Get the list of contributor profiles. Require admin rights."""
# get members of scikit-learn teams on GitHub
members = []
for team in [11523, 33471]:
for page in [1, 2]: # 30 per page
members.extend(requests.get(
"https://api.github.com/teams/%d/members?page=%d"
% (team, page), auth=auth).json())

# keep only the logins
logins = [c['login'] for c in members]
# add missing contributors with GitHub accounts
logins.extend(['dubourg', 'jarrodmillman', 'mbrucher', 'thouis'])
# add missing contributors without GitHub accounts
logins.extend(['Angel Soler Gollonet'])
# remove duplicate
logins = set(logins)
# remove CI
logins.remove('sklearn-ci')

# get profiles from GitHub
profiles = [get_profile(login) for login in logins]
# sort by last name
profiles = sorted(profiles, key=key)

return profiles


def get_profile(login):
"""Get the GitHub profile from login"""
profile = requests.get("https://api.github.com/users/%s" % login,
auth=auth).json()
if 'name' not in profile:
# default profile if the login does not exist
return dict(name=login, avatar_url=LOGO_URL, html_url="")
else:
if profile["name"] is None:
profile["name"] = profile["login"]

# fix missing names
missing_names = {'bthirion': 'Bertrand Thirion',
'dubourg': 'Vincent Dubourg',
'Duchesnay': 'Edouard Duchesnay',
'Lars': 'Lars Buitinck',
'MechCoder': 'Manoj Kumar'}
if profile["name"] in missing_names:
profile["name"] = missing_names[profile["name"]]
return profile


def key(profile):
"""Get the last name in lower case"""
return profile["name"].split(' ')[-1].lower()


contributors = get_contributors()

print(".. raw :: html\n")
print(" <!-- Generated by gen_authors.py -->")
print(" <table>")
print(" <col style='width:%d%%' span='%d'>"
% (int(100 / ROW_SIZE), ROW_SIZE))
print(" <style>")
print(" img.avatar {border-radius: 10px;}")
print(" td {vertical-align: top;}")
print(" </style>")
for row in group_iterable(contributors, size=ROW_SIZE):
print(" <tr>")
for contributor in row:
print(" <td>")
print(" <a href='%s'><img src='%s' class='avatar' /></a> <br />"
% (contributor["html_url"], contributor["avatar_url"]))
print(" <p>%s</p>" % contributor["name"])
print(" </td>")
print(" </tr>")
print(" </table>")
26 changes: 25 additions & 1 deletion doc/about.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
About us
========

.. include:: ../AUTHORS.rst
History
-------

This project was started in 2007 as a Google Summer of Code project by
David Cournapeau. Later that year, Matthieu Brucher started work on
this project as part of his thesis.

In 2010 Fabian Pedregosa, Gael Varoquaux, Alexandre Gramfort and Vincent
Michel of INRIA took leadership of the project and made the first public
release, February the 1st 2010. Since then, several releases have appeared
following a ~3 month cycle, and a thriving international community has
been leading the development.

Authors
-------

The following people have been core contributors to scikit-learn's development
and maintenance:

.. include:: authors.rst

Please do not email the authors directly to ask for assistance or report issues.
Instead, please see `What's the best way to ask questions about scikit-learn
<http://scikit-learn.org/stable/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage>`_
in the FAQ.

.. seealso::

Expand Down
Loading

0 comments on commit 1906c95

Please sign in to comment.