From 0e6605d7a4ee59e16d52fd93e037b5608fd5f61f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 10 May 2015 09:10:18 +0200 Subject: [PATCH] feat(index.html): added back-link to crates.io * url is created per-API and features a nice crates image coming from githubusercontent. Closes #105 [skip ci] --- etc/api/shared.yaml | 3 +++ src/mako/index.html.mako | 5 ++++- src/mako/lib/util.py | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index 06db9c3f25..70d359cb59 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -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 diff --git a/src/mako/index.html.mako b/src/mako/index.html.mako index 2e2b2694f5..78601da82d 100644 --- a/src/mako/index.html.mako +++ b/src/mako/index.html.mako @@ -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' @@ -68,6 +68,9 @@ DO NOT EDIT ! % for api_name in type_names: <% ad = tc[api_name] %> ${ad.make.id.upper()} + % if api_name == 'api': + + % endif % if not loop.last: , % endif diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 259cc344b7..b5e547e7f5 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -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':