mirror of
https://github.com/Icinga/icinga-docs-tools.git
synced 2025-07-23 05:44:33 +02:00
Allow subdirectories for main navigation
This commit is contained in:
parent
6c255f865e
commit
9900b949c9
@ -47,13 +47,30 @@ end
|
|||||||
def build_page_index(full_docs_dir, project_docs_dir)
|
def build_page_index(full_docs_dir, project_docs_dir)
|
||||||
pages = []
|
pages = []
|
||||||
puts "Building page index from #{full_docs_dir}"
|
puts "Building page index from #{full_docs_dir}"
|
||||||
Dir.glob("#{full_docs_dir}/*.md", File::FNM_CASEFOLD).sort.each do |file|
|
|
||||||
|
Dir.glob("#{full_docs_dir}/**", File::FNM_CASEFOLD).sort.each do |file|
|
||||||
|
next if !file.match(/.*(\d+)-(.*)$/)
|
||||||
|
|
||||||
filepath = file.gsub(full_docs_dir + '/', project_docs_dir + '/')
|
filepath = file.gsub(full_docs_dir + '/', project_docs_dir + '/')
|
||||||
filename = filepath.match(/.*(\d+)-(.*).md$/)
|
filename = filepath.match(/.*(\d+)-(.*)$/)
|
||||||
if filename
|
|
||||||
header = filename[2].gsub('-', ' ').split.map(&:capitalize).join(' ') unless File.symlink?(filepath)
|
if(File.directory?("#{file}"))
|
||||||
|
subdirectory = []
|
||||||
|
nav_item = filename[2].gsub('-', ' ').split.map(&:capitalize).join(' ') unless File.symlink?(filepath)
|
||||||
|
|
||||||
|
Dir.glob("#{file}/*.md", File::FNM_CASEFOLD).sort.each do |subfile|
|
||||||
|
subfile_path = subfile.gsub(full_docs_dir + '/', project_docs_dir + '/')
|
||||||
|
subfile_name = subfile.match(/.*(\d+)-(.*)$/)
|
||||||
|
|
||||||
|
header = subfile_name[2].gsub('-', ' ').split.map(&:capitalize).join(' ').gsub('.md', '') unless File.symlink?(subfile)
|
||||||
|
subdirectory.push(header => subfile_path) if header
|
||||||
|
end
|
||||||
|
|
||||||
|
pages.push(nav_item => subdirectory) if nav_item
|
||||||
|
else
|
||||||
|
header = filename[2].gsub('-', ' ').split.map(&:capitalize).join(' ').gsub('.md', '') unless File.symlink?(filepath)
|
||||||
|
pages.push(header => filepath) if header
|
||||||
end
|
end
|
||||||
pages.push(header => filepath) if header
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return pages
|
return pages
|
||||||
|
9
examples/developer-guidelines.yml
Normal file
9
examples/developer-guidelines.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
site_name: 'Developer Guidelines'
|
||||||
|
source_dir: '/var/www/docs/source'
|
||||||
|
site_dir: '/var/www/docs/html'
|
||||||
|
project:
|
||||||
|
git: 'https://github.com/Icinga/developer-guidelines.git'
|
||||||
|
ref: 'directories'
|
||||||
|
target: 'developer-guidelines'
|
||||||
|
docs_dir: 'doc'
|
||||||
|
latest: true
|
Loading…
x
Reference in New Issue
Block a user