Skip to content

Commit

Permalink
feat(index.html): added back-link to crates.io
Browse files Browse the repository at this point in the history
* url is created per-API and features a nice crates image coming
  from githubusercontent.

Closes #105
[skip ci]
  • Loading branch information
Byron committed May 10, 2015
1 parent 5c284e1 commit 0e6605d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ make:
types:
- api
- cli
html_index:
asset_urls:
crates_img: https://raw.githubusercontent.com/rust-lang/crates.io/master/public/favicon.ico
directories:
# directory under which all generated sources should reside
output: gen
Expand Down
5 changes: 4 additions & 1 deletion src/mako/index.html.mako
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
import os
import yaml
from util import (gen_crate_dir, api_index)
from util import (gen_crate_dir, api_index, crates_io_url)
title = 'Google Service Documentation for Rust'
Expand Down Expand Up @@ -68,6 +68,9 @@ DO NOT EDIT !
% for api_name in type_names:
<% ad = tc[api_name] %>
<a class="mod" href="${api_index(DOC_ROOT, an, v, ad.make)}" title="${ad.make.id.upper()} docs for the ${an} ${v}">${ad.make.id.upper()}</a>
% if api_name == 'api':
<a href="${crates_io_url(an, v)}"><img src="${html_index.asset_urls.crates_img}" title="This API on crates.io" height="16" width="16"/></a>
% endif
% if not loop.last:
,
% endif
Expand Down
3 changes: 3 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ def to_extern_crate_name(crate_name):
def gen_crate_dir(name, version, ti):
return to_extern_crate_name(library_to_crate_name(library_name(name, version), ti.target_suffix))

def crates_io_url(name, version):
return "https://crates.io/crates/%s" % library_to_crate_name(library_name(name, version))

def api_index(DOC_ROOT, name, version, ti, check_exists=True):
crate_dir = gen_crate_dir(name, version, ti)
if ti.documentation_engine == 'rustdoc':
Expand Down

0 comments on commit 0e6605d

Please sign in to comment.