miniyard 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/miniyard +6 -2
- data/lib/miniyard.rb +15 -4
- data/lib/miniyard/folder.rb +23 -0
- data/lib/miniyard/version.rb +1 -1
- data/lib/templates/index.haml +25 -5
- metadata +5 -4
data/bin/miniyard
CHANGED
@@ -8,6 +8,7 @@ options = {
|
|
8
8
|
root: Dir.pwd,
|
9
9
|
doc: nil,
|
10
10
|
cov: nil,
|
11
|
+
ci: nil,
|
11
12
|
name: nil
|
12
13
|
}
|
13
14
|
|
@@ -19,9 +20,12 @@ OptionParser.new do |opts|
|
|
19
20
|
opts.on("-d SOURCE_DOCS""--doc=SOURCE_DOCS", "Docs folder to copy (requires --name option)") do |v|
|
20
21
|
options[:doc] = v
|
21
22
|
end
|
22
|
-
opts.on("-
|
23
|
+
opts.on("-o SOURCE_COVERAGE", "--cov=SOURCE_COVERAGE", "Coverage folder to copy (requires --name option)") do |v|
|
23
24
|
options[:cov] = v
|
24
25
|
end
|
26
|
+
opts.on("-u CI_URL", "--url=CI_URL", "Full URL to CI for project") do |v|
|
27
|
+
options[:ci] = v
|
28
|
+
end
|
25
29
|
opts.on("-n NAME", "--name=NAME", "The name of the application folder in root. (Only applies to --cpdoc or --cpcov flags)") do |v|
|
26
30
|
options[:name] = v
|
27
31
|
end
|
@@ -31,4 +35,4 @@ if options[:doc] || options[:cov]
|
|
31
35
|
MiniYard::Copy.new(options).run
|
32
36
|
end
|
33
37
|
|
34
|
-
MiniYard::Generate.new(options
|
38
|
+
MiniYard::Generate.new(options).run
|
data/lib/miniyard.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
require "miniyard/version"
|
2
|
+
require "miniyard/folder"
|
2
3
|
require 'fileutils'
|
3
4
|
require 'haml'
|
4
5
|
|
5
6
|
module MiniYard
|
6
7
|
class Generate
|
7
8
|
|
8
|
-
def initialize(
|
9
|
-
raise 'Unable to generate MiniYard at path %s: not a directory' % path unless File.directory?(root)
|
10
|
-
@
|
9
|
+
def initialize(options)
|
10
|
+
raise 'Unable to generate MiniYard at path %s: not a directory' % path unless File.directory?(options[:root])
|
11
|
+
@options = options
|
12
|
+
@root = File.expand_path(@options[:root])
|
11
13
|
end
|
12
14
|
|
13
15
|
def run
|
14
16
|
$stdout.puts('Generating miniyard at '+@root)
|
17
|
+
write_ci_url if @options[:ci]
|
15
18
|
FileUtils.rm(index_file) if index_exists?
|
16
19
|
output = haml_render(index_template)
|
17
20
|
write_file(index_file, output)
|
@@ -19,7 +22,7 @@ module MiniYard
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def folders
|
22
|
-
@folders ||= Dir[File.join(@root, '*')].sort.select{|n| File.directory?(n) }.map{|n|
|
25
|
+
@folders ||= Dir[File.join(@root, '*')].sort.select{|n| File.directory?(n) }.map{|n| MiniYard::Folder.new(n) }
|
23
26
|
end
|
24
27
|
|
25
28
|
def index_template
|
@@ -53,6 +56,14 @@ module MiniYard
|
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
59
|
+
def write_ci_url
|
60
|
+
File.open(ci_path, 'w'){|f| f.write(@options[:ci]) }
|
61
|
+
end
|
62
|
+
|
63
|
+
def ci_path
|
64
|
+
File.join(@root, @options[:name], 'ci.url')
|
65
|
+
end
|
66
|
+
|
56
67
|
def bootstrap_version
|
57
68
|
"1.4.0"
|
58
69
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MiniYard
|
2
|
+
class Folder
|
3
|
+
attr_reader :name, :doc, :cov, :ci
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
@name = File.basename(path)
|
8
|
+
@doc = File.directory?(File.join(path, 'doc')) ? "yes" : "no"
|
9
|
+
@cov = File.directory?(File.join(path, 'cov')) ? "yes" : "no"
|
10
|
+
@ci = get_ci_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_ci_url
|
14
|
+
ci_file = File.join(@path, 'ci.url')
|
15
|
+
if File.file?(ci_file)
|
16
|
+
File.open(ci_file, 'r'){|f| @ci_file = f.read.chop.strip }
|
17
|
+
else
|
18
|
+
"no"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/miniyard/version.rb
CHANGED
data/lib/templates/index.haml
CHANGED
@@ -4,18 +4,35 @@
|
|
4
4
|
%title [ MiniYard ]
|
5
5
|
%link{rel: 'stylesheet', type: 'text/css', href: './bootstrap.1.4.0.min.css'}
|
6
6
|
:javascript
|
7
|
-
function selectFolder(anchor
|
8
|
-
|
9
|
-
|
7
|
+
function selectFolder(anchor) {
|
8
|
+
var docHref = updatePill(anchor.dataset.doc, 'doc-frame-link', './'+anchor.dataset.name+'/doc/index.html');
|
9
|
+
var covHref = updatePill(anchor.dataset.cov, 'cov-frame-link', './'+anchor.dataset.name+'/cov/index.html');
|
10
|
+
var ciHref = updatePill(anchor.dataset.ciurl, 'ci-frame-link', anchor.dataset.ciurl);
|
11
|
+
var frameSrc = (docHref != '#' ? docHref : (covHref != '#' ? covHref : ciHref));
|
12
|
+
if (frameSrc != 'javascript:void(0);')
|
13
|
+
document.getElementById('frame').src = frameSrc;
|
14
|
+
|
10
15
|
setActive(anchor);
|
11
16
|
setActive(document.getElementById('doc-frame-link'));
|
12
17
|
}
|
18
|
+
function updatePill(dataAttr, pillAnchorId, pillAnchorHref) {
|
19
|
+
var link = document.getElementById(pillAnchorId);
|
20
|
+
if (dataAttr == 'no') {
|
21
|
+
link.parentElement.classList.add('hide');
|
22
|
+
link.href = 'javascript:void(0);';
|
23
|
+
} else {
|
24
|
+
link.parentElement.classList.remove('hide');
|
25
|
+
link.href = pillAnchorHref;
|
26
|
+
}
|
27
|
+
return link.href;
|
28
|
+
}
|
13
29
|
function setActive(anchor) {
|
14
30
|
var ul = anchor.parentElement.parentElement;
|
15
31
|
for (var i = 0; i < ul.children.length; i++)
|
16
32
|
ul.children[i].classList.remove('active');
|
17
33
|
anchor.parentNode.classList.add('active');
|
18
34
|
}
|
35
|
+
|
19
36
|
:css
|
20
37
|
html,body { height: 100%; margin: 0; padding: 0; }
|
21
38
|
body { background: #333; color: #fff; }
|
@@ -30,6 +47,7 @@
|
|
30
47
|
.sidebar ul li.active { font-weight: bold; background: #666; }
|
31
48
|
.content ul.pills { margin-bottom: 0; }
|
32
49
|
.content ul.pills a { color: #fff; text-shadow: 0 1px 1px #666; }
|
50
|
+
.content ul.pills li.hide { display: none }
|
33
51
|
.content #frame { width: 100%; min-height: 90%; background: #fff; }
|
34
52
|
|
35
53
|
%body
|
@@ -38,8 +56,8 @@
|
|
38
56
|
%ul
|
39
57
|
- folders.each do |folder|
|
40
58
|
%li
|
41
|
-
%a{id: "#{folder}-link", href:
|
42
|
-
= folder
|
59
|
+
%a{id: "#{folder.name}-link", href: '#', 'data-name' => folder.name, 'data-doc' => folder.doc, 'data-cov' => folder.cov, 'data-ciurl' => folder.ci, onclick: "javascript: selectFolder(this);"}
|
60
|
+
= folder.name
|
43
61
|
|
44
62
|
.content
|
45
63
|
%ul#pill-nav.pills{"data-pills" => "pills"}
|
@@ -47,6 +65,8 @@
|
|
47
65
|
%a{id: "doc-frame-link", href: 'javascript: void(0);', target: "frame", onclick: "javascript: setActive(this)"} Documentation
|
48
66
|
%li
|
49
67
|
%a{id: "cov-frame-link", href: 'javascript: void(0);', target: "frame", onclick: "javascript: setActive(this)"} Coverage
|
68
|
+
%li
|
69
|
+
%a{id: "ci-frame-link", href: 'javascript: void(0);', target: "frame", onclick: "javascript: setActive(this)"} CI
|
50
70
|
%iframe#frame{name: 'frame', frameborder: '0'}
|
51
71
|
%h3.title
|
52
72
|
%span.bracket [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miniyard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164268180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2164268180
|
25
25
|
description: A static html framebuilder to host multiple documentation folders
|
26
26
|
email:
|
27
27
|
- bj.neilsen@gmail.com
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- bin/miniyard
|
37
37
|
- lib/miniyard.rb
|
38
38
|
- lib/miniyard/copy.rb
|
39
|
+
- lib/miniyard/folder.rb
|
39
40
|
- lib/miniyard/version.rb
|
40
41
|
- lib/templates/bootstrap.1.4.0.min.css
|
41
42
|
- lib/templates/index.haml
|