forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_api_toc.rb
More file actions
24 lines (21 loc) · 973 Bytes
/
Copy pathupdate_api_toc.rb
File metadata and controls
24 lines (21 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'jekyll'
require 'octopress-hooks'
module Jekyll
class UpdateApiToc < Octopress::Hooks::Site
def pre_read(site)
beginning_time = Time.now
Jekyll.logger.info "Starting plugin update_api_toc.rb..."
if File.file?("_config.yml") && File.file?("_data/toc.yaml")
# substitute the "{site.latest_engine_api_version}" in the title for the latest
# API docs, based on the latest_engine_api_version parameter in _config.yml
engine_ver = site.config['latest_engine_api_version']
toc_file = File.read("_data/toc.yaml")
replace = toc_file.gsub!("{{ site.latest_engine_api_version }}", engine_ver)
Jekyll.logger.info " Replacing '{{ site.latest_engine_api_version }}' with #{engine_ver} in _data/toc.yaml"
File.open("_data/toc.yaml", "w") { |file| file.puts replace }
end
end_time = Time.now
Jekyll.logger.info "done in #{(end_time - beginning_time)} seconds"
end
end
end