Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ref docs menus to manageiq-documentation branches #913

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is needed to deal with someone doing bin/miq serve directly but without building the docs. Previously the menu files would exist and this would be fine, but now they won't exist unless one builds the docs first.

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