Using github and bitbucket icons on plugins_index page
--HG-- branch : integrate-plugin-index-docs
This commit is contained in:
@@ -73,9 +73,34 @@ def obtain_plugins_table(plugins, client):
|
||||
:param plugins: list of (name, version)
|
||||
:param client: ServerProxy
|
||||
"""
|
||||
def get_repo_markup(repo):
|
||||
"""
|
||||
obtains appropriate markup for the given repository, as two lines
|
||||
that should be output in the same table row. We use this to display an icon
|
||||
for known repository hosts (github, etc), just a "?" char when
|
||||
repository is not registered in pypi or a simple link otherwise.
|
||||
"""
|
||||
target = repo
|
||||
if 'github.com' in repo:
|
||||
image = 'github.png'
|
||||
elif 'bitbucket.org' in repo:
|
||||
image = 'bitbucket.png'
|
||||
elif repo.lower() == 'unknown':
|
||||
return '?', ''
|
||||
else:
|
||||
image = None
|
||||
|
||||
if image is not None:
|
||||
image_markup = '.. image:: %s' % image
|
||||
target_markup = ' :target: %s' % repo
|
||||
pad_right = ('%-' + str(len(target_markup)) + 's')
|
||||
return pad_right % image_markup, target_markup
|
||||
else:
|
||||
return '`link <%s>`_' % target, ''
|
||||
|
||||
rows = []
|
||||
ColumnData = namedtuple('ColumnData', 'text link')
|
||||
headers = ['Name', 'Py27', 'Py33', 'Repository', 'Summary']
|
||||
headers = ['Name', 'Py27', 'Py33', 'Repo', 'Summary']
|
||||
pytest_version = pytest.__version__
|
||||
repositories = obtain_override_repositories()
|
||||
print('*** pytest-{0} ***'.format(pytest_version))
|
||||
@@ -90,6 +115,9 @@ def obtain_plugins_table(plugins, client):
|
||||
name=package_name,
|
||||
version=version)
|
||||
|
||||
repository = repositories.get(package_name, release_data['home_page'])
|
||||
repo_markup_1, repo_markup_2 = get_repo_markup(repository)
|
||||
|
||||
# first row: name, images and simple links
|
||||
url = '.. image:: {site}/status/{name}-latest'
|
||||
image_url = url.format(**common_params)
|
||||
@@ -101,7 +129,7 @@ def obtain_plugins_table(plugins, client):
|
||||
ColumnData(image_url.format(py='py33', pytest=pytest_version),
|
||||
None),
|
||||
ColumnData(
|
||||
repositories.get(package_name, release_data['home_page']),
|
||||
repo_markup_1,
|
||||
None),
|
||||
ColumnData(release_data['summary'], None),
|
||||
)
|
||||
@@ -119,8 +147,9 @@ def obtain_plugins_table(plugins, client):
|
||||
None),
|
||||
ColumnData(output_url.format(py='py33', pytest=pytest_version),
|
||||
None),
|
||||
ColumnData(repo_markup_2, None),
|
||||
ColumnData('', None),
|
||||
ColumnData('', None),
|
||||
|
||||
)
|
||||
assert len(row) == len(headers)
|
||||
rows.append(row)
|
||||
|
||||
Reference in New Issue
Block a user