Skip to content
4 changes: 3 additions & 1 deletion _build_cfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Dir: welcome
Topics:
- Name: Welcome
File: index
- Name: Contributing
File: doc_guidelines

---
Name: Getting Started
Expand Down Expand Up @@ -72,7 +74,7 @@ Topics:
File: domains
- Name: Applications
File: apps

---
Name: Developing Cartridges
Dir: cartridge_specification_guide
Expand Down
32 changes: 27 additions & 5 deletions _builder_lib/docsitebuilder/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def build_config
validate_config(YAML.load_stream(open(build_config_file)))
end

# Protip: Do cache this! It contains the dev branch config
def dev_build_config
@dev_build_config ||= validate_config(YAML.load_stream(open(build_config_file)))
end

def distro_map
@distro_map ||= begin
{ 'openshift-origin' => {
Expand Down Expand Up @@ -432,9 +437,9 @@ def generate_docs(build_distro,single_page=nil)
single_page_file = single_page.split(':')[1]
puts "Rebuilding '#{single_page}' on branch '#{working_branch}'."
end

if not build_distro == ''
if not distro_map.has_key?(build_distro)
puts "Unrecognized distro '#{build_distro}'; cancelling build."
exit
else
puts "Building the #{distro_map[build_distro][:name]} distribution(s)."
Expand All @@ -443,6 +448,16 @@ def generate_docs(build_distro,single_page=nil)
puts "Building all available distributions."
end

development_branch = nil
if not distro_branches.include?(working_branch)
development_branch = working_branch
if not build_distro == ''
puts "The working branch '#{working_branch}' will be rendered as #{build_distro} documentation."
else
puts "The working branch '#{working_branch}' will be rendered for each build distribution."
end
end

# First, notify the user of missing local branches
missing_branches = []
distro_branches(build_distro).sort.each do |dbranch|
Expand All @@ -458,12 +473,12 @@ def generate_docs(build_distro,single_page=nil)
end

distro_map.each do |distro,distro_config|
if not build_distro == '' and not build_distro == distro
if single_page.nil? and not build_distro == '' and not build_distro == distro
next
end
first_branch = single_page.nil?
distro_config[:branches].each do |branch,branch_config|
if not single_page.nil? and not working_branch == branch
if not single_page.nil? and not working_branch == branch and development_branch.nil?
next
end
if first_branch
Expand All @@ -474,10 +489,13 @@ def generate_docs(build_distro,single_page=nil)
puts "- skipping #{branch}"
next
end
if single_page.nil?
if single_page.nil? and development_branch.nil?
puts "- building #{branch}"
git_checkout(branch)
end
if not development_branch.nil?
branch_config[:dir] = "#{development_branch}_#{distro}"
end

# Create the target dir
branch_path = File.join(preview_dir,branch_config[:dir])
Expand All @@ -495,7 +513,7 @@ def generate_docs(build_distro,single_page=nil)
system("cp -r _images/* #{branch_path}/images")

# Read the _build_config.yml for this distro
distro_build_config = build_config
distro_build_config = development_branch.nil? ? build_config : dev_build_config

# Build the landing page
navigation = nav_tree(distro,distro_build_config)
Expand Down Expand Up @@ -549,6 +567,10 @@ def generate_docs(build_distro,single_page=nil)
end
end
end

if not development_branch.nil?
break
end
end

# Create a distro landing page
Expand Down
Loading