Skip to content

Commit

Permalink
Move ref docs menus to manageiq-documentation branches
Browse files Browse the repository at this point in the history
Related to ManageIQ#814
  • Loading branch information
Fryguy committed Oct 20, 2020
1 parent b48ce40 commit eb88e89
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 693 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _site
Gemfile.lock

dest/
site/_data/menus/ref_menu_*.yml
site/docs/guides
site/docs/reference/latest/
site/docs/reference/jansa/
Expand Down
4 changes: 4 additions & 0 deletions lib/miq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def self.docs_dir
Pathname.new ENV.fetch("MIQ_DOCS_DIR", site_dir.join("docs"))
end

def self.menus_dir
site_dir.join("_data", "menus")
end

def self.tmp_dir
working_dir.join(ENV["MIQ_TMP_DIR"] || "tmp")
end
Expand Down
10 changes: 10 additions & 0 deletions lib/miq/legacy_ref_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def sync_files

branches.each do |branch|
rsync_copy(branch)
copy_menu(branch)
end
else
logger.error "Reference docs source directory not present."
Expand All @@ -113,6 +114,15 @@ def rsync_copy(branch)
shell cmd
end

def copy_menu(branch)
menu = Miq.menus_dir.join("ref_menu_#{branch}.yml")

logger.info "Syncing menu to #{menu}"

shell "cd #{tmp_dir} && git checkout #{branch}"
FileUtils.cp(File.join(tmp_dir, "site_menu.yml"), menu)
end

def branch_paths
branches.map { |b| "#{tmp_dir}/#{src_dir}/#{b}/*" }.join(' ')
end
Expand Down
14 changes: 14 additions & 0 deletions lib/miq/ref_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,22 @@ def build_and_sync(branch)
"git checkout #{branch}",
"#{bundler} exec rake clean build"
].join(" && ")

rsync_copy(branch)
copy_menu(branch)
else
logger.error "Reference docs source directory not present."
end
end

def make_master_latest
if File.directory?("#{dst_dir}/master") || debug?
# Move content
shell "rm -rf #{dst_dir}/latest"
shell "mv #{dst_dir}/master #{dst_dir}/latest"

# Move menu
shell "mv #{Miq.menus_dir.join("ref_menu_master.yml")} #{Miq.menus_dir.join("ref_menu_latest.yml")}"
end
end

Expand Down Expand Up @@ -133,6 +139,14 @@ def rsync_copy(branch)
shell cmd
end

def copy_menu(branch)
menu = Miq.menus_dir.join("ref_menu_#{branch}.yml")

logger.info "Syncing menu to #{menu}"

FileUtils.cp(File.join(tmp_dir, "_data", "site_menu.yml"), menu)
end

def branch_paths
branches.map { |b| "#{tmp_dir}/#{src_dir}/#{b}/*" }.join(' ')
end
Expand Down
10 changes: 5 additions & 5 deletions lib/miq/ref_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def build_index
end

def menus
@menus ||= begin
menus = Miq.site_dir.join("_data", "menus").glob("ref_menu_*.yml").sort.map(&:to_s)
latest = menus.index { |m| m.include?("ref_menu_latest.yml") }
menus << menus.delete_at(latest)
end
@menus ||=
Miq.menus_dir.glob("ref_menu_*.yml").sort.map(&:to_s).tap do |menus|
latest = menus.index { |m| m.include?("ref_menu_latest.yml") }
menus << menus.delete_at(latest) if latest
end
end

def menu_version(menu)
Expand Down
85 changes: 0 additions & 85 deletions site/_data/menus/ref_menu_euwe.yml

This file was deleted.

85 changes: 0 additions & 85 deletions site/_data/menus/ref_menu_fine.yml

This file was deleted.

85 changes: 0 additions & 85 deletions site/_data/menus/ref_menu_gaprindashvili.yml

This file was deleted.

Loading

0 comments on commit eb88e89

Please sign in to comment.