From 65c5f7caad6cda27755ff78b2c49841d1eeb6269 Mon Sep 17 00:00:00 2001 From: Ryan Ische Date: Thu, 23 Oct 2014 14:14:24 -0400 Subject: [PATCH] Proper url_prefix when doc_base_url has multiple folders --- lib/tasks/apipie.rake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tasks/apipie.rake b/lib/tasks/apipie.rake index 0463e3d3..d3f24bae 100644 --- a/lib/tasks/apipie.rake +++ b/lib/tasks/apipie.rake @@ -68,6 +68,8 @@ namespace :apipie do puts "#{Time.now} | Processing docs for #{lang}" cache_dir = ENV["OUT"] || Apipie.configuration.cache_dir subdir = Apipie.configuration.doc_base_url.sub(/\A\//,"") + subdir_levels = subdir.split('/').length + subdir_traversal_prefix = '../' * subdir_levels file_base = File.join(cache_dir, Apipie.configuration.doc_base_url) if generate_index @@ -78,15 +80,15 @@ namespace :apipie do end Apipie.available_versions.each do |version| file_base_version = File.join(file_base, version) - Apipie.url_prefix = "../#{subdir}" + Apipie.url_prefix = "#{subdir_traversal_prefix}#{subdir}" doc = Apipie.to_json(version, nil, nil, lang) doc[:docs][:link_extension] = (lang ? ".#{lang}.html" : ".html") generate_index_page(file_base_version, doc, true, true, lang) if generate_index if generate_resources - Apipie.url_prefix = "../../#{subdir}" + Apipie.url_prefix = "../#{subdir_traversal_prefix}#{subdir}" generate_resource_pages(version, file_base_version, doc, true, lang) - Apipie.url_prefix = "../../../#{subdir}" + Apipie.url_prefix = "../../#{subdir_traversal_prefix}#{subdir}" generate_method_pages(version, file_base_version, doc, true, lang) end end