diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index ac86937d77..a4151ff0a0 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -11,6 +11,15 @@ api: # when a resource is supposed to be uploaded upload_action: upload # Contains values shared among all API implementations +make: + # All known program ids. + types: + - id: api + target_suffix: '' + documentation_engine: rustdoc + - id: cli + target_suffix: -cli + documentation_engine: mkdocs directories: # directory under which all generated sources should reside output: gen diff --git a/src/mako/deps.mako b/src/mako/deps.mako index 0eb4fad91e..8ded175ced 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -50,6 +50,9 @@ import os import json + def gen_type_cfg_path(id): + return '$(API_DIR)/type-' + id + '.yaml' + CMN_SRC = '/src/cmn.rs' api_name = util.library_name(an, version) @@ -76,8 +79,8 @@ api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version + make.aggregated_target_suffix, json.load(open(api_json, 'r')).get('revision', '00000000')) api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.yaml' - type_specific_json = '$(API_DIR)/type-' + make.id + '.yaml' - api_json_inputs = api_json + ' $(API_SHARED_INFO) ' + type_specific_json + type_specific_cfg = gen_type_cfg_path(make.id) + api_json_inputs = api_json + ' $(API_SHARED_INFO) ' + type_specific_cfg if os.path.isfile(api_json_overrides): api_json_inputs += ' ' + api_json_overrides api_info.append((api_target, api_clean, api_cargo, api_doc, api_crate_publish_file, gen_root)) @@ -135,8 +138,8 @@ publish${agsuffix}: | gen-all${agsuffix} ${space_join(4)} gen-all${agsuffix}: ${space_join(0)} % if global_targets: -${doc_index}: docs${agsuffix} ${type_specific_json} ## TODO: all type dependencies: docs-api, docs-cli - $(PYPATH) $(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) ${type_specific_json} +${doc_index}: ${' '.join('docs-' + ti.id for ti in make.types)} ${' '.join(gen_type_cfg_path(ti.id) for ti in make.types)} + $(PYPATH) $(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) @echo Documentation index created at '$@' docs-all: ${doc_index} docs-all-clean: diff --git a/src/mako/index.html.mako b/src/mako/index.html.mako index 048ef29e60..05373f14fd 100644 --- a/src/mako/index.html.mako +++ b/src/mako/index.html.mako @@ -1,27 +1,21 @@ <% import os - from util import (library_name, library_to_crate_name, to_extern_crate_name) + from util import (gen_crate_dir, api_index) - def gen_crate_dir(name, version): - return to_extern_crate_name(library_to_crate_name(library_name(name, version), make.target_suffix)) - - def api_index(name, version): - crate_dir = gen_crate_dir(name, version) - index_file_path = crate_dir + '/' + crate_dir + '/index.html' - if os.path.isfile(DOC_ROOT + '/' + index_file_path): - return index_file_path - return None - - title = 'Google Rust Client API Docs' + title = 'Google Service Documentation for Rust' first_api_prefix = None - for an in sorted(api.list.keys()): - for v in api.list[an]: - if api_index(an, v): - first_api_prefix = gen_crate_dir(an, v) - break - # for each version - # for each api name + for ti in make.types: + if ti.documentation_engine != 'rustdoc': + continue + for an in sorted(api.list.keys()): + for v in api.list[an]: + if api_index(DOC_ROOT, an, v, ti): + first_api_prefix = gen_crate_dir(an, v, ti) + break + # for each version + # for each api name + # end for each type assert first_api_prefix %>\ @@ -34,6 +28,10 @@ DO NOT EDIT !