Optimizations for single project usage
This commit is contained in:
parent
699bd3e962
commit
14d314dd8f
Binary file not shown.
|
@ -1,3 +1,4 @@
|
|||
config.yml
|
||||
mkdocs.yml
|
||||
.bundle/
|
||||
vendor/
|
||||
|
@ -5,8 +6,6 @@ Gemfile.lock
|
|||
html/
|
||||
projects/*
|
||||
!projects/
|
||||
!projects/index.md
|
||||
!projects/archive.md
|
||||
|
||||
.idea/
|
||||
.DS_Store
|
||||
|
|
12
README.md
12
README.md
|
@ -61,6 +61,18 @@ Clone this repository and install dependencies:
|
|||
user@localhost ~/ $ git clone https://github.com/Icinga/icinga-docs-tools.git
|
||||
user@localhost ~/ $ cd icinga-docs-tools
|
||||
user@localhost ~/ $ bundle install --path vendor
|
||||
```
|
||||
|
||||
Create and configure configuration file:
|
||||
|
||||
``` bash
|
||||
user@localhost ~/ $ cp config.example.yml config.yml
|
||||
user@localhost ~/ $ vim config.yml
|
||||
```
|
||||
|
||||
Build documentation:
|
||||
|
||||
``` bash
|
||||
user@localhost ~/ $ bundle exec build-docs.rb
|
||||
```
|
||||
|
||||
|
|
|
@ -1,18 +1,47 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'optparse'
|
||||
require 'fileutils'
|
||||
require 'yaml'
|
||||
require 'git'
|
||||
|
||||
config = YAML::load_file('config.yml')
|
||||
mkdocs = YAML::load_file('mkdocs.template.yml')
|
||||
options = {}
|
||||
OptionParser.new { |opts|
|
||||
opts.banner = "Usage: #{File.basename($0)} -c config.yml -t mkdocs.template.yml}"
|
||||
|
||||
options[:config] = 'config.yml'
|
||||
opts.on('-f',
|
||||
'--config FILENAME',
|
||||
'Configuration file with project definition. Defaults to "config.yml"') do |config|
|
||||
options[:config] = config
|
||||
end
|
||||
|
||||
options[:template] = 'mkdocs.template.yml'
|
||||
opts.on('-t',
|
||||
'--template FILENAME',
|
||||
'This file is used as template for the generated mkdocs.yaml. Defaults to "mkdocs.template.yml"') do |template|
|
||||
options[:template] = template
|
||||
end
|
||||
|
||||
opts.on_tail('-h', '--help', 'Show this message') do
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
}.parse!
|
||||
|
||||
|
||||
config = YAML::load_file(options[:config])
|
||||
mkdocs = YAML::load_file(options[:template])
|
||||
categories = {}
|
||||
mkdocs['pages'] = []
|
||||
|
||||
config['projects'].each do |project_name, project_config|
|
||||
puts "== #{project_name}"
|
||||
|
||||
mkdocs['site_name'] = project_name
|
||||
|
||||
project_dir = config['projects_dir'] + '/' + project_config['target']
|
||||
|
||||
if project_config['latest'] == true
|
||||
if project_config['latest']
|
||||
clone_target = project_dir + '/latest'
|
||||
elsif project_config['ref'] == 'master'
|
||||
clone_target = project_dir + '/snapshot'
|
||||
|
@ -34,13 +63,12 @@ config['projects'].each do |project_name, project_config|
|
|||
repo.fetch()
|
||||
puts "Checkout ref '#{project_config['ref']}'"
|
||||
repo.branch(project_config['ref']).checkout
|
||||
repo.pull('origin', project_config['ref'])
|
||||
end
|
||||
|
||||
puts "Building page index from #{project_docs_dir}"
|
||||
Dir.glob("#{project_docs_dir}/*.md", File::FNM_CASEFOLD).sort.each do |file|
|
||||
filepath = file.gsub('projects/', '')
|
||||
filename = filepath.match(/(\d+)-(.*).md$/)
|
||||
filename = filepath.match(/.*(\d+)-(.*).md$/)
|
||||
header = filename[2].gsub('-', ' ').split.map(&:capitalize).join(' ')
|
||||
pages.push(header => filepath)
|
||||
end
|
||||
|
@ -49,7 +77,11 @@ config['projects'].each do |project_name, project_config|
|
|||
categories[project_config['category']] = [] unless categories[project_config['category']]
|
||||
categories[project_config['category']].push(project_name => pages)
|
||||
else
|
||||
mkdocs['pages'].push(project_name => pages)
|
||||
# MKdocs allows only 'index.md' as homepage. This is a dirty workaround to use the first markdown file instead
|
||||
FileUtils.ln_s("#{pages[0].values[0]}", 'projects/index.md', :force => true)
|
||||
mkdocs['pages'].push('' => 'index.md')
|
||||
|
||||
mkdocs['pages'].push(*pages)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,8 +91,10 @@ if categories
|
|||
end
|
||||
end
|
||||
|
||||
mkdocs['extra']['append_pages'].each do |name, target|
|
||||
mkdocs['pages'].push(name => target)
|
||||
if mkdocs['extra']['append_pages']
|
||||
mkdocs['extra']['append_pages'].each do |name, target|
|
||||
mkdocs['pages'].push(name => target)
|
||||
end
|
||||
end
|
||||
|
||||
File.write('mkdocs.yml', mkdocs.to_yaml)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
projects_dir: 'projects'
|
||||
projects:
|
||||
Icinga Web 2:
|
||||
git: 'https://github.com/Icinga/icingaweb2.git'
|
||||
ref: 'tags/v2.4.2'
|
||||
latest: true
|
||||
target: 'icingaweb2'
|
||||
docs_dir: 'doc'
|
||||
|
43
config.yml
43
config.yml
|
@ -1,43 +0,0 @@
|
|||
---
|
||||
projects_dir: 'projects'
|
||||
projects:
|
||||
Icinga 2:
|
||||
git: 'https://github.com/Icinga/icinga2.git'
|
||||
ref: 'support/2.7'
|
||||
latest: true
|
||||
target: 'icinga2'
|
||||
docs_dir: 'doc'
|
||||
Icinga Web 2:
|
||||
git: 'https://github.com/Icinga/icingaweb2.git'
|
||||
ref: 'tags/v2.4.1'
|
||||
latest: true
|
||||
target: 'icingaweb2'
|
||||
docs_dir: 'doc'
|
||||
Director:
|
||||
git: 'https://github.com/Icinga/icingaweb2-module-director.git'
|
||||
ref: 'tags/v1.3.1'
|
||||
latest: true
|
||||
target: 'director'
|
||||
docs_dir: 'doc'
|
||||
category: 'Modules'
|
||||
Business Process:
|
||||
git: 'https://github.com/Icinga/icingaweb2-module-businessprocess.git'
|
||||
ref: 'tags/v2.1.0'
|
||||
latest: true
|
||||
target: 'businessprocess'
|
||||
docs_dir: 'doc'
|
||||
category: 'Modules'
|
||||
Fileshipper:
|
||||
git: 'https://github.com/Icinga/icingaweb2-module-fileshipper.git'
|
||||
ref: 'tags/v1.0.0'
|
||||
latest: true
|
||||
target: 'fileshipper'
|
||||
docs_dir: 'doc'
|
||||
category: 'Modules'
|
||||
vSphere:
|
||||
git: 'https://github.com/Icinga/icingaweb2-module-vsphere.git'
|
||||
ref: 'tags/v1.1.0'
|
||||
latest: true
|
||||
target: 'vsphere'
|
||||
docs_dir: 'doc'
|
||||
category: 'Modules'
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
projects_dir: 'projects'
|
||||
projects:
|
||||
Icinga 2:
|
||||
git: 'https://github.com/Icinga/icinga2.git'
|
||||
ref: 'support/v2.7'
|
||||
latest: true
|
||||
target: 'icinga2'
|
||||
docs_dir: 'doc'
|
||||
|
|
@ -1,14 +1,9 @@
|
|||
---
|
||||
site_name: Documentation
|
||||
theme: material
|
||||
theme_dir: theme
|
||||
docs_dir: projects
|
||||
site_dir: 'html'
|
||||
pages:
|
||||
- Introduction: index.md
|
||||
extra:
|
||||
append_pages:
|
||||
Archive: archive.md
|
||||
font:
|
||||
text: 'Open Sans:300,400,400i,600,700'
|
||||
menu:
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# Archive
|
||||
Here you will find older versions of documentations and docs of older products.
|
||||
|
||||
#### Icinga 1.x
|
||||
* [English Online](https://www.icinga.com/docs/icinga1/latest/en/)
|
||||
* [German Online](https://www.icinga.com/docs/icinga1/latest/de/)
|
|
@ -1,6 +0,0 @@
|
|||
# Icinga Documentation
|
||||
|
||||
Welcome to the Icinga Documation. Please select your preferred product on the left.
|
||||
|
||||
Built on proven technologies and concepts as well as progressive frameworks and standards, Icinga is a product of the
|
||||
community - their ideas, needs and combined passion for innovation.
|
|
@ -0,0 +1 @@
|
|||
icinga2/latest/doc/01-about.md
|
|
@ -116,6 +116,52 @@
|
|||
line-height: 1em;
|
||||
font-family: "Open Sans";
|
||||
font-weight: 700;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.md-search__form {
|
||||
margin-bottom: -3px;
|
||||
}
|
||||
|
||||
.md-breadcrump-main {
|
||||
background-color: #F3F3F4;
|
||||
position: relative;
|
||||
float: left;
|
||||
width: 100%;
|
||||
padding: 4px;
|
||||
padding-bottom: 2px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.md-breadcrump-inner {
|
||||
position: relative;
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.md-breadcrump-innner ul {
|
||||
}
|
||||
|
||||
#breadcrump-list {
|
||||
list-style-type: disc;
|
||||
padding-left: 0px;
|
||||
margin: 0px;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.md-breadcrump-inner li a {
|
||||
color: #0095bf;
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
margin: 0 5px;
|
||||
padding: 5px 10px;
|
||||
font-family: "Open Sans";
|
||||
}
|
||||
|
||||
.md-breadcrump-inner li {
|
||||
display: inline-block;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.md-container {
|
||||
|
@ -123,6 +169,21 @@
|
|||
font-family: "Open Sans"
|
||||
}
|
||||
|
||||
.md-breadcrump-seperator {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
|
||||
.md-grid {
|
||||
max-width: 1255px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
.md-main__inner {
|
||||
min-height: 100vh;
|
||||
|
@ -133,6 +194,14 @@
|
|||
min-height: 60vh;
|
||||
}
|
||||
|
||||
.md-sidebar--primary .md-nav__item {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.md-sidebar--primary .md-nav__item--nested li {
|
||||
padding: 0 1.2rem;
|
||||
}
|
||||
|
||||
.md-content a {
|
||||
color: #0095BF;
|
||||
}
|
||||
|
|
|
@ -43,4 +43,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
</header>
|
||||
|
||||
<div class="md-breadcrump-main">
|
||||
<div class="md-breadcrump-inner">
|
||||
<ul id="breadcrump-list">
|
||||
<li><a href="https://www.icinga.com/docs">Documentation</a></li>
|
||||
<li>
|
||||
<span class="md-breadcrump-seperator">/</span>
|
||||
<a href="{{ base_url }}">{{ config.site_name }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,14 @@
|
|||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||
{% if config.repo_url %}
|
||||
<div class="md-nav__source">
|
||||
{% include "partials/source.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<ul class="md-nav__list" data-md-scrollfix>
|
||||
{% for nav_item in nav %}
|
||||
{% set path = "nav-" + loop.index | string %}
|
||||
{% set level = 1 %}
|
||||
{% include "partials/nav-item.html" %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
Loading…
Reference in New Issue