vocco 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/docs/README.html +159 -0
- data/docs/lib-vocco-cli.rb.html +97 -0
- data/docs/lib-vocco-generator-css.rb.html +117 -0
- data/docs/lib-vocco-generator-source_file-html_template.rb.html +99 -0
- data/docs/lib-vocco-generator-source_file.rb.html +160 -0
- data/docs/lib-vocco-generator.rb.html +189 -0
- data/docs/lib-vocco.rb.html +173 -0
- data/lib/vocco.rb +3 -2
- data/vocco.gemspec +9 -2
- metadata +24 -3
@@ -0,0 +1,160 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<title>Vocco : source_file.rb</title>
|
6
|
+
<meta name="Generator" content="Vim/7.2" />
|
7
|
+
<meta content="text/html; charset=utf8" http-equiv="content-type" />
|
8
|
+
<style type="text/css">
|
9
|
+
<!--
|
10
|
+
.Identifier { color: #c6b6ee; }
|
11
|
+
.rubyIdentifier { color: #c6b6fe; }
|
12
|
+
.PreProc { color: #8fbfdc; }
|
13
|
+
.StringDelimiter { color: #556633; }
|
14
|
+
.String { color: #99ad6a; }
|
15
|
+
.Function { color: #fad07a; }
|
16
|
+
.rubyInstanceVariable { color: #c6b6fe; }
|
17
|
+
.Statement { color: #8197bf; }
|
18
|
+
.rubySymbol { color: #7697d6; }
|
19
|
+
.Comment { color: #888888; font-style: italic; }
|
20
|
+
.rubyRegexpDelimiter { color: #540063; }
|
21
|
+
.rubyRegexpSpecial { color: #a40073; }
|
22
|
+
.rubyControl { color: #7597c6; }
|
23
|
+
.Type { color: #ffb964; }
|
24
|
+
body { color: #e8e8d3; background-color: #151515; font-family: monospace; }
|
25
|
+
.rubyClass { color: #447799; }
|
26
|
+
-->
|
27
|
+
</style><style type="text/css">body {
|
28
|
+
font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif;
|
29
|
+
font-size: 15px; }
|
30
|
+
|
31
|
+
html, body {
|
32
|
+
height: 100%; }
|
33
|
+
|
34
|
+
body {
|
35
|
+
padding: 1em; }
|
36
|
+
|
37
|
+
.code {
|
38
|
+
font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace;
|
39
|
+
font-size: 16px;
|
40
|
+
padding: 1em;
|
41
|
+
width: 50%; }
|
42
|
+
|
43
|
+
.nav {
|
44
|
+
width: 40%;
|
45
|
+
position: fixed;
|
46
|
+
top: 0;
|
47
|
+
left: 55%;
|
48
|
+
height: 100%;
|
49
|
+
font-size: 15px;
|
50
|
+
line-height: 22px;
|
51
|
+
color: #252519; }
|
52
|
+
.nav .wrapper {
|
53
|
+
color: black;
|
54
|
+
height: 100%; }
|
55
|
+
.nav .wrapper .area {
|
56
|
+
background-color: #cccccc;
|
57
|
+
padding: 1em 1em 1em 1em;
|
58
|
+
border-bottom: 1px dashed #bbbbbb;
|
59
|
+
border-top: 1px dashed #666666; }
|
60
|
+
.nav .wrapper .area .autohide {
|
61
|
+
opacity: 0;
|
62
|
+
height: 0px;
|
63
|
+
-webkit-transition: all 0.2s linear;
|
64
|
+
overflow: auto; }
|
65
|
+
.nav .wrapper .area:hover .autohide {
|
66
|
+
height: 150px;
|
67
|
+
opacity: 1; }
|
68
|
+
.nav .wrapper .notes {
|
69
|
+
max-height: 40%;
|
70
|
+
overflow: auto; }
|
71
|
+
|
72
|
+
table th {
|
73
|
+
text-align: right; }
|
74
|
+
|
75
|
+
</style>
|
76
|
+
</head>
|
77
|
+
<body><div class="code">
|
78
|
+
<br />
|
79
|
+
<br />
|
80
|
+
<br />
|
81
|
+
<span class="rubyClass">class</span> <span class="Type">Vocco</span>::<span class="Type">Generator</span>::<span class="Type">SourceFile</span><br />
|
82
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">vocco/generator/source_file/html_template</span><span class="StringDelimiter">'</span><br />
|
83
|
+
<br />
|
84
|
+
<span class="Type">NOTE_FORMATS</span> = <span class="StringDelimiter">'</span><span class="String">.{textile,md,mkd,markdown,rdoc}</span><span class="StringDelimiter">'</span><br />
|
85
|
+
<br />
|
86
|
+
<span class="PreProc">def</span> <span class="Function">initialize</span>(file, generator)<br />
|
87
|
+
<span class="rubyInstanceVariable">@file</span> = file<br />
|
88
|
+
<span class="rubyInstanceVariable">@gen</span> = generator<br />
|
89
|
+
<span class="PreProc">end</span><br />
|
90
|
+
<br />
|
91
|
+
<span class="Statement">attr_reader</span> <span class="rubySymbol">:file</span> <span class="Comment"># full file path</span><br />
|
92
|
+
<br />
|
93
|
+
<span class="Comment"># full dirname</span><br />
|
94
|
+
<span class="PreProc">def</span> <span class="Function">dirname</span><br />
|
95
|
+
<span class="Type">File</span>.dirname(<span class="rubyInstanceVariable">@file</span>)<br />
|
96
|
+
<span class="PreProc">end</span><br />
|
97
|
+
<br />
|
98
|
+
<span class="PreProc">def</span> <span class="Function">basename</span><br />
|
99
|
+
<span class="Type">File</span>.basename(<span class="rubyInstanceVariable">@file</span>)<br />
|
100
|
+
<span class="PreProc">end</span><br />
|
101
|
+
<br />
|
102
|
+
<span class="Comment"># file path with glob dir scope trimmed off</span><br />
|
103
|
+
<span class="PreProc">def</span> <span class="Function">short_path</span><br />
|
104
|
+
<span class="rubyInstanceVariable">@short_path</span> ||= <span class="rubyInstanceVariable">@file</span>.sub(<span class="rubyInstanceVariable">@gen</span>.glob_regex, <span class="StringDelimiter">''</span>)<br />
|
105
|
+
<span class="PreProc">end</span><br />
|
106
|
+
<br />
|
107
|
+
<span class="Comment"># dirname of the above</span><br />
|
108
|
+
<span class="PreProc">def</span> <span class="Function">short_dirname</span><br />
|
109
|
+
<span class="Type">File</span>.dirname(short_path).sub(<span class="rubyRegexpDelimiter">/</span><span class="rubyRegexpSpecial">^</span><span class="rubyRegexpSpecial">\.\/</span><span class="rubyRegexpDelimiter">/</span>, <span class="StringDelimiter">''</span>)<br />
|
110
|
+
<span class="PreProc">end</span><br />
|
111
|
+
<br />
|
112
|
+
<span class="Comment"># corresponding doc file basename</span><br />
|
113
|
+
<span class="PreProc">def</span> <span class="Function">doc_basename</span><br />
|
114
|
+
doc_scope + basename + <span class="StringDelimiter">'</span><span class="String">.html</span><span class="StringDelimiter">'</span><br />
|
115
|
+
<span class="PreProc">end</span><br />
|
116
|
+
<br />
|
117
|
+
<span class="Comment"># corresponding doc file path</span><br />
|
118
|
+
<span class="PreProc">def</span> <span class="Function">doc_path</span><br />
|
119
|
+
<span class="Type">File</span>.join(<span class="rubyInstanceVariable">@gen</span>.out, doc_basename)<br />
|
120
|
+
<span class="PreProc">end</span><br />
|
121
|
+
<br />
|
122
|
+
<span class="Comment"># relative link to doc</span><br />
|
123
|
+
<span class="PreProc">def</span> <span class="Function">doc_link</span><br />
|
124
|
+
<span class="StringDelimiter">'</span><span class="String">./</span><span class="StringDelimiter">'</span> + doc_basename<br />
|
125
|
+
<span class="PreProc">end</span><br />
|
126
|
+
<br />
|
127
|
+
<span class="PreProc">def</span> <span class="Function">notes</span><br />
|
128
|
+
<span class="rubyInstanceVariable">@notes</span> ||= <span class="Type">Dir</span>[note_glob].map <span class="rubyControl">do</span> |<span class="rubyIdentifier">path</span>|<br />
|
129
|
+
<span class="Type">Tilt</span>.new(path).render<br />
|
130
|
+
<span class="rubyControl">end</span><br />
|
131
|
+
<span class="PreProc">end</span><br />
|
132
|
+
<br />
|
133
|
+
<span class="Comment"># make a method for the html template</span><br />
|
134
|
+
<span class="Statement">class_eval</span> <<-<span class="StringDelimiter">EOF</span>, <span class="StringDelimiter">'</span><span class="String">(template)</span><span class="StringDelimiter">'</span><br />
|
135
|
+
<span class="String"> def render_template</span><br />
|
136
|
+
<span class="String"> </span><span class="Identifier">#{</span><span class="Type">HTML_TEMPLATE</span><span class="Identifier">}</span><br />
|
137
|
+
<span class="String"> end</span><br />
|
138
|
+
<span class="String"> </span><span class="StringDelimiter">EOF</span><br />
|
139
|
+
<br />
|
140
|
+
<span class="Statement">private</span><br />
|
141
|
+
<span class="Comment"># doc filename prefix based on source file folder</span><br />
|
142
|
+
<span class="PreProc">def</span> <span class="Function">doc_scope</span><br />
|
143
|
+
short_dirname == <span class="StringDelimiter">'</span><span class="String">.</span><span class="StringDelimiter">'</span> ? <span class="StringDelimiter">''</span> : short_dirname.gsub(<span class="StringDelimiter">'</span><span class="String">/</span><span class="StringDelimiter">'</span>, <span class="StringDelimiter">'</span><span class="String">-</span><span class="StringDelimiter">'</span>) + <span class="StringDelimiter">'</span><span class="String">-</span><span class="StringDelimiter">'</span><br />
|
144
|
+
<span class="PreProc">end</span><br />
|
145
|
+
<br />
|
146
|
+
<span class="Comment"># the dirs in which to look for notes concerning this file.</span><br />
|
147
|
+
<span class="PreProc">def</span> <span class="Function">note_dirs</span><br />
|
148
|
+
<span class="rubyInstanceVariable">@gen</span>.notes.inject([dirname]) <span class="rubyControl">do</span> |<span class="rubyIdentifier">dirs</span>, <span class="rubyIdentifier">dir</span>|<br />
|
149
|
+
dirs << <span class="Type">File</span>.join(dir, short_dirname)<br />
|
150
|
+
<span class="rubyControl">end</span><br />
|
151
|
+
<span class="PreProc">end</span><br />
|
152
|
+
<br />
|
153
|
+
<span class="Comment"># glob matching notes concerning this file</span><br />
|
154
|
+
<span class="PreProc">def</span> <span class="Function">note_glob</span><br />
|
155
|
+
<span class="StringDelimiter">'</span><span class="String">{</span><span class="StringDelimiter">'</span> + note_dirs.join(<span class="StringDelimiter">'</span><span class="String">,</span><span class="StringDelimiter">'</span>) + <span class="StringDelimiter">'</span><span class="String">}/</span><span class="StringDelimiter">'</span> + basename + <span class="Type">NOTE_FORMATS</span><br />
|
156
|
+
<span class="PreProc">end</span><br />
|
157
|
+
<span class="rubyClass">end</span><br />
|
158
|
+
<br />
|
159
|
+
</div><div class="nav"><div class="wrapper"><div class="area"><h3><strong><a href="http://github.com/jbe/vocco">Vocco</a></strong><span> : </span><span>source_file.rb</span></h3><p class="autohide">lib/vocco/<a href="./lib-vocco-generator.rb.html">generator.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-css.rb.html">css.rb</a><br />lib/vocco/generator/source_file/<a href="./lib-vocco-generator-source_file-html_template.rb.html">html_template.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-source_file.rb.html">source_file.rb</a><br />lib/vocco/<a href="./lib-vocco-cli.rb.html">cli.rb</a><br />lib/<a href="./lib-vocco.rb.html">vocco.rb</a><br /><a href="./README.html">README</a><br /></p></div><div class="area"><table><tr><th>Generated:</th><td>Mon Mar 14 01:26:25 +0100 2011</td></tr></table></div></div></div></body>
|
160
|
+
</html>
|
@@ -0,0 +1,189 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<title>Vocco : generator.rb</title>
|
6
|
+
<meta name="Generator" content="Vim/7.2" />
|
7
|
+
<meta content="text/html; charset=utf8" http-equiv="content-type" />
|
8
|
+
<style type="text/css">
|
9
|
+
<!--
|
10
|
+
.Special { color: #799d6a; }
|
11
|
+
.Identifier { color: #c6b6ee; }
|
12
|
+
.rubyIdentifier { color: #c6b6fe; }
|
13
|
+
.rubyRegexpDelimiter { color: #540063; }
|
14
|
+
.rubyRegexpSpecial { color: #a40073; }
|
15
|
+
.Constant { color: #cf6a4c; }
|
16
|
+
.Comment { color: #888888; font-style: italic; }
|
17
|
+
.Statement { color: #8197bf; }
|
18
|
+
.rubySymbol { color: #7697d6; }
|
19
|
+
.Function { color: #fad07a; }
|
20
|
+
.rubyInstanceVariable { color: #c6b6fe; }
|
21
|
+
.rubyControl { color: #7597c6; }
|
22
|
+
.Type { color: #ffb964; }
|
23
|
+
.StringDelimiter { color: #556633; }
|
24
|
+
.String { color: #99ad6a; }
|
25
|
+
.rubyClass { color: #447799; }
|
26
|
+
body { color: #e8e8d3; background-color: #151515; font-family: monospace; }
|
27
|
+
.PreProc { color: #8fbfdc; }
|
28
|
+
-->
|
29
|
+
</style><style type="text/css">body {
|
30
|
+
font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif;
|
31
|
+
font-size: 15px; }
|
32
|
+
|
33
|
+
html, body {
|
34
|
+
height: 100%; }
|
35
|
+
|
36
|
+
body {
|
37
|
+
padding: 1em; }
|
38
|
+
|
39
|
+
.code {
|
40
|
+
font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace;
|
41
|
+
font-size: 16px;
|
42
|
+
padding: 1em;
|
43
|
+
width: 50%; }
|
44
|
+
|
45
|
+
.nav {
|
46
|
+
width: 40%;
|
47
|
+
position: fixed;
|
48
|
+
top: 0;
|
49
|
+
left: 55%;
|
50
|
+
height: 100%;
|
51
|
+
font-size: 15px;
|
52
|
+
line-height: 22px;
|
53
|
+
color: #252519; }
|
54
|
+
.nav .wrapper {
|
55
|
+
color: black;
|
56
|
+
height: 100%; }
|
57
|
+
.nav .wrapper .area {
|
58
|
+
background-color: #cccccc;
|
59
|
+
padding: 1em 1em 1em 1em;
|
60
|
+
border-bottom: 1px dashed #bbbbbb;
|
61
|
+
border-top: 1px dashed #666666; }
|
62
|
+
.nav .wrapper .area .autohide {
|
63
|
+
opacity: 0;
|
64
|
+
height: 0px;
|
65
|
+
-webkit-transition: all 0.2s linear;
|
66
|
+
overflow: auto; }
|
67
|
+
.nav .wrapper .area:hover .autohide {
|
68
|
+
height: 150px;
|
69
|
+
opacity: 1; }
|
70
|
+
.nav .wrapper .notes {
|
71
|
+
max-height: 40%;
|
72
|
+
overflow: auto; }
|
73
|
+
|
74
|
+
table th {
|
75
|
+
text-align: right; }
|
76
|
+
|
77
|
+
</style>
|
78
|
+
</head>
|
79
|
+
<body><div class="code">
|
80
|
+
<br />
|
81
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">fileutils</span><span class="StringDelimiter">'</span><br />
|
82
|
+
<br />
|
83
|
+
<br />
|
84
|
+
<span class="rubyClass">class</span> <span class="Type">Vocco</span>::<span class="Type">Generator</span><br />
|
85
|
+
<br />
|
86
|
+
<span class="Comment"># File What</span><br />
|
87
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">vocco/generator/css</span><span class="StringDelimiter">'</span> <span class="Comment"># CSS additions</span><br />
|
88
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">vocco/generator/source_file</span><span class="StringDelimiter">'</span> <span class="Comment"># SourceFile class</span><br />
|
89
|
+
<br />
|
90
|
+
<span class="Statement">attr_reader</span> <span class="rubySymbol">:globs</span>, <span class="rubySymbol">:notes</span>, <span class="rubySymbol">:out</span>, <span class="rubySymbol">:name</span>, <span class="rubySymbol">:site</span><br />
|
91
|
+
<br />
|
92
|
+
<span class="PreProc">def</span> <span class="Function">initialize</span>(opts)<br />
|
93
|
+
<span class="rubyInstanceVariable">@globs</span> = Array(opts[<span class="rubySymbol">:files</span>]<br />
|
94
|
+
).compact.map <span class="rubyControl">do</span> |<span class="rubyIdentifier">glob</span>|<br />
|
95
|
+
glob.gsub(<span class="rubyRegexpDelimiter">/</span><span class="rubyRegexpSpecial">(</span><span class="rubyRegexpSpecial">^</span><span class="rubyRegexpSpecial">\.\/</span><span class="rubyRegexpSpecial">)|(</span><span class="rubyRegexpSpecial">\/</span><span class="rubyRegexpSpecial">$</span><span class="rubyRegexpSpecial">)</span><span class="rubyRegexpDelimiter">/</span>, <span class="StringDelimiter">''</span>)<br />
|
96
|
+
<span class="rubyControl">end</span><br />
|
97
|
+
<span class="rubyInstanceVariable">@out</span> = opts[<span class="rubySymbol">:out</span>]<br />
|
98
|
+
<span class="rubyInstanceVariable">@notes</span> = Array(opts[<span class="rubySymbol">:notes</span>]).compact<br />
|
99
|
+
<span class="rubyInstanceVariable">@name</span> = opts[<span class="rubySymbol">:name</span>].capitalize<br />
|
100
|
+
<span class="rubyInstanceVariable">@site</span> = opts[<span class="rubySymbol">:site</span>]<br />
|
101
|
+
<span class="rubyInstanceVariable">@vim</span> = Array(opts[<span class="rubySymbol">:vim</span>]).compact<br />
|
102
|
+
<br />
|
103
|
+
<span class="Type">FileUtils</span>.mkdir_p(<span class="rubyInstanceVariable">@out</span>) <span class="Comment"># ensure out dir exists</span><br />
|
104
|
+
<span class="PreProc">end</span><br />
|
105
|
+
<br />
|
106
|
+
<span class="Comment"># the paths underneath which the @globs are globbing;</span><br />
|
107
|
+
<span class="Comment"># the static part of the glob, or "scope" of sorts</span><br />
|
108
|
+
<span class="PreProc">def</span> <span class="Function">scopes</span><br />
|
109
|
+
<span class="rubyInstanceVariable">@scopes</span> ||= <span class="rubyInstanceVariable">@globs</span>.map <span class="rubyControl">do</span> |<span class="rubyIdentifier">glob</span>|<br />
|
110
|
+
tokens = glob.split(<span class="StringDelimiter">'</span><span class="String">*</span><span class="StringDelimiter">'</span>)<br />
|
111
|
+
tokens.size > <span class="Constant">1</span> ? tokens.first : <span class="Constant">nil</span><br />
|
112
|
+
<span class="rubyControl">end</span>.compact<br />
|
113
|
+
<span class="PreProc">end</span><br />
|
114
|
+
<br />
|
115
|
+
<span class="Comment"># regex to trim the glob dir scopes off a source</span><br />
|
116
|
+
<span class="Comment"># file path.</span><br />
|
117
|
+
<span class="PreProc">def</span> <span class="Function">glob_regex</span><br />
|
118
|
+
<span class="rubyInstanceVariable">@glob_regex</span> ||= <span class="rubyControl">begin</span><br />
|
119
|
+
str = scopes.map <span class="rubyControl">do</span> |<span class="rubyIdentifier">scope</span>|<br />
|
120
|
+
<span class="Type">Regexp</span>::escape(scope)<br />
|
121
|
+
<span class="rubyControl">end</span>.join(<span class="StringDelimiter">'</span><span class="String">|</span><span class="StringDelimiter">'</span>)<br />
|
122
|
+
<span class="rubyRegexpDelimiter">/</span><span class="rubyRegexpSpecial">^</span><span class="rubyRegexpSpecial">(</span><span class="rubyRegexpSpecial">\.\/</span><span class="rubyRegexpSpecial">)</span><span class="rubyRegexpSpecial">?</span><span class="rubyRegexpSpecial">(</span><span class="Identifier">#{</span>str<span class="Identifier">}</span><span class="rubyRegexpSpecial">)(</span><span class="rubyRegexpSpecial">\/</span><span class="rubyRegexpSpecial">)</span><span class="rubyRegexpSpecial">?</span><span class="rubyRegexpDelimiter">/</span><br />
|
123
|
+
<span class="rubyControl">end</span><br />
|
124
|
+
<span class="PreProc">end</span><br />
|
125
|
+
<br />
|
126
|
+
<span class="Comment"># array of SourceFile's mapped from the glob matches</span><br />
|
127
|
+
<span class="PreProc">def</span> <span class="Function">files</span><br />
|
128
|
+
<span class="rubyInstanceVariable">@files</span> ||= <span class="rubyInstanceVariable">@globs</span>.map <span class="rubyControl">do</span> |<span class="rubyIdentifier">glob</span>|<br />
|
129
|
+
<span class="Type">Dir</span>[glob]<br />
|
130
|
+
<span class="rubyControl">end</span>.flatten.uniq.map <span class="rubyControl">do</span> |<span class="rubyIdentifier">path</span>|<br />
|
131
|
+
<span class="Type">SourceFile</span>.new(path, <span class="Constant">self</span>)<br />
|
132
|
+
<span class="rubyControl">end</span><br />
|
133
|
+
<span class="PreProc">end</span><br />
|
134
|
+
<br />
|
135
|
+
<span class="PreProc">def</span> <span class="Function">run</span><br />
|
136
|
+
run_vim; postprocess<br />
|
137
|
+
<span class="PreProc">end</span><br />
|
138
|
+
<span class="PreProc">alias</span> <span class="rubySymbol">:run!</span> <span class="rubySymbol">:run</span><br />
|
139
|
+
<br />
|
140
|
+
<span class="Statement">private</span><br />
|
141
|
+
<br />
|
142
|
+
<span class="PreProc">def</span> <span class="Function">run_vim</span><br />
|
143
|
+
script = <span class="Type">Tempfile</span>.new(<span class="StringDelimiter">'</span><span class="String">vimdocco</span><span class="StringDelimiter">'</span>)<br />
|
144
|
+
script.write(vimscript)<br />
|
145
|
+
script.close<br />
|
146
|
+
puts <span class="StringDelimiter">'</span><span class="String">Running </span><span class="StringDelimiter">'</span> + vim_command + <span class="StringDelimiter">'</span><span class="String">:</span><span class="StringDelimiter">'</span><br />
|
147
|
+
system <span class="StringDelimiter">"</span><span class="Identifier">#{</span>vim_command<span class="Identifier">}</span><span class="String"> -f -S </span><span class="Identifier">#{</span>script.path<span class="Identifier">}</span><span class="StringDelimiter">"</span><br />
|
148
|
+
script.delete<br />
|
149
|
+
<span class="PreProc">end</span><br />
|
150
|
+
<br />
|
151
|
+
<span class="PreProc">def</span> <span class="Function">vim_command</span><br />
|
152
|
+
<span class="rubyInstanceVariable">@vim_command</span> ||= <span class="rubyInstanceVariable">@vim</span>.detect <span class="rubyControl">do</span> |<span class="rubyIdentifier">c</span>|<br />
|
153
|
+
<span class="StringDelimiter">`</span><span class="String">which </span><span class="Identifier">#{</span>c<span class="Identifier">}</span><span class="StringDelimiter">`</span>.chomp.strip != <span class="StringDelimiter">''</span><br />
|
154
|
+
<span class="rubyControl">end</span> || <span class="rubyControl">abort</span>(<span class="StringDelimiter">"</span><span class="String">You must install one of </span><span class="Identifier">#{</span><span class="rubyInstanceVariable">@vim</span>.inspect<span class="Identifier">}</span><span class="String">.</span><span class="StringDelimiter">"</span>)<br />
|
155
|
+
<span class="PreProc">end</span><br />
|
156
|
+
<br />
|
157
|
+
<span class="PreProc">def</span> <span class="Function">vimscript</span><br />
|
158
|
+
<span class="rubyInstanceVariable">@vimscript</span> ||= <span class="rubyControl">begin</span><br />
|
159
|
+
s = <span class="StringDelimiter">"</span><span class="String">let html_no_pre = 1</span><span class="Special">\n</span><span class="StringDelimiter">"</span><br />
|
160
|
+
files.each <span class="rubyControl">do</span> |<span class="rubyIdentifier">file</span>|<br />
|
161
|
+
s << <span class="StringDelimiter">"</span><span class="String">view! </span><span class="Identifier">#{</span>file.file<span class="Identifier">}</span><span class="Special">\n</span><span class="StringDelimiter">"</span><br />
|
162
|
+
s << <span class="StringDelimiter">"</span><span class="String">TOhtml</span><span class="Special">\n</span><span class="StringDelimiter">"</span><br />
|
163
|
+
s << <span class="StringDelimiter">"</span><span class="String">w! </span><span class="Identifier">#{</span>file.doc_path<span class="Identifier">}</span><span class="Special">\n</span><span class="StringDelimiter">"</span><br />
|
164
|
+
<span class="rubyControl">end</span><br />
|
165
|
+
s << <span class="StringDelimiter">"</span><span class="String">:qall!</span><span class="Special">\n</span><span class="StringDelimiter">"</span><br />
|
166
|
+
<span class="rubyControl">end</span><br />
|
167
|
+
<span class="PreProc">end</span><br />
|
168
|
+
<br />
|
169
|
+
<span class="PreProc">def</span> <span class="Function">postprocess</span><br />
|
170
|
+
hpricotify_docs <span class="rubyControl">do</span> |<span class="rubyIdentifier">doc</span>, <span class="rubyIdentifier">file</span>|<br />
|
171
|
+
doc.at(<span class="StringDelimiter">'</span><span class="String">style</span><span class="StringDelimiter">'</span>).after(<span class="StringDelimiter">'</span><span class="String"><style type="text/css"></span><span class="StringDelimiter">'</span> + <span class="Type">CSS</span> + <span class="StringDelimiter">'</span><span class="String"></style></span><span class="StringDelimiter">'</span>)<br />
|
172
|
+
doc.at(<span class="StringDelimiter">'</span><span class="String">title</span><span class="StringDelimiter">'</span>).inner_html = name + <span class="StringDelimiter">'</span><span class="String"> : </span><span class="StringDelimiter">'</span> + file.basename<br />
|
173
|
+
inner = doc.at(<span class="StringDelimiter">'</span><span class="String">body</span><span class="StringDelimiter">'</span>).inner_html<br />
|
174
|
+
doc.at(<span class="StringDelimiter">'</span><span class="String">body</span><span class="StringDelimiter">'</span>).swap <span class="StringDelimiter">"</span><span class="String"><body><div class='code'></span><span class="Identifier">#{</span>inner<span class="Identifier">}</span><span class="String"></div></body></span><span class="StringDelimiter">"</span><br />
|
175
|
+
doc.at(<span class="StringDelimiter">'</span><span class="String">.code</span><span class="StringDelimiter">'</span>).after file.render_template<br />
|
176
|
+
<span class="rubyControl">end</span><br />
|
177
|
+
<span class="PreProc">end</span><br />
|
178
|
+
<br />
|
179
|
+
<span class="PreProc">def</span> <span class="Function">hpricotify_docs</span><br />
|
180
|
+
files.each <span class="rubyControl">do</span> |<span class="rubyIdentifier">file</span>|<br />
|
181
|
+
doc = <span class="Type">File</span>.open(file.doc_path) {|<span class="rubyIdentifier">f</span>| Hpricot(f) }<br />
|
182
|
+
<span class="Statement">yield</span>(doc, file)<br />
|
183
|
+
<span class="Type">File</span>.open(file.doc_path, <span class="StringDelimiter">'</span><span class="String">w</span><span class="StringDelimiter">'</span>) {|<span class="rubyIdentifier">f</span>| f.write(doc.to_html) }<br />
|
184
|
+
<span class="rubyControl">end</span><br />
|
185
|
+
<span class="PreProc">end</span><br />
|
186
|
+
<span class="rubyClass">end</span><br />
|
187
|
+
<br />
|
188
|
+
</div><div class="nav"><div class="wrapper"><div class="area"><h3><strong><a href="http://github.com/jbe/vocco">Vocco</a></strong><span> : </span><span>generator.rb</span></h3><p class="autohide">lib/vocco/<a href="./lib-vocco-generator.rb.html">generator.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-css.rb.html">css.rb</a><br />lib/vocco/generator/source_file/<a href="./lib-vocco-generator-source_file-html_template.rb.html">html_template.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-source_file.rb.html">source_file.rb</a><br />lib/vocco/<a href="./lib-vocco-cli.rb.html">cli.rb</a><br />lib/<a href="./lib-vocco.rb.html">vocco.rb</a><br /><a href="./README.html">README</a><br /></p></div><div class="area"><table><tr><th>Generated:</th><td>Mon Mar 14 01:26:25 +0100 2011</td></tr></table></div></div></div></body>
|
189
|
+
</html>
|
@@ -0,0 +1,173 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<title>Vocco : vocco.rb</title>
|
6
|
+
<meta name="Generator" content="Vim/7.2" />
|
7
|
+
<meta content="text/html; charset=utf8" http-equiv="content-type" />
|
8
|
+
<style type="text/css">
|
9
|
+
<!--
|
10
|
+
.rubyIdentifier { color: #c6b6fe; }
|
11
|
+
.rubyInstanceVariable { color: #c6b6fe; }
|
12
|
+
.rubyControl { color: #7597c6; }
|
13
|
+
.Identifier { color: #c6b6ee; }
|
14
|
+
.Type { color: #ffb964; }
|
15
|
+
.Constant { color: #cf6a4c; }
|
16
|
+
.Function { color: #fad07a; }
|
17
|
+
.rubySymbol { color: #7697d6; }
|
18
|
+
.Statement { color: #8197bf; }
|
19
|
+
.StringDelimiter { color: #556633; }
|
20
|
+
.String { color: #99ad6a; }
|
21
|
+
.rubyClass { color: #447799; }
|
22
|
+
body { color: #e8e8d3; background-color: #151515; font-family: monospace; }
|
23
|
+
.Comment { color: #888888; font-style: italic; }
|
24
|
+
.PreProc { color: #8fbfdc; }
|
25
|
+
-->
|
26
|
+
</style><style type="text/css">body {
|
27
|
+
font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif;
|
28
|
+
font-size: 15px; }
|
29
|
+
|
30
|
+
html, body {
|
31
|
+
height: 100%; }
|
32
|
+
|
33
|
+
body {
|
34
|
+
padding: 1em; }
|
35
|
+
|
36
|
+
.code {
|
37
|
+
font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace;
|
38
|
+
font-size: 16px;
|
39
|
+
padding: 1em;
|
40
|
+
width: 50%; }
|
41
|
+
|
42
|
+
.nav {
|
43
|
+
width: 40%;
|
44
|
+
position: fixed;
|
45
|
+
top: 0;
|
46
|
+
left: 55%;
|
47
|
+
height: 100%;
|
48
|
+
font-size: 15px;
|
49
|
+
line-height: 22px;
|
50
|
+
color: #252519; }
|
51
|
+
.nav .wrapper {
|
52
|
+
color: black;
|
53
|
+
height: 100%; }
|
54
|
+
.nav .wrapper .area {
|
55
|
+
background-color: #cccccc;
|
56
|
+
padding: 1em 1em 1em 1em;
|
57
|
+
border-bottom: 1px dashed #bbbbbb;
|
58
|
+
border-top: 1px dashed #666666; }
|
59
|
+
.nav .wrapper .area .autohide {
|
60
|
+
opacity: 0;
|
61
|
+
height: 0px;
|
62
|
+
-webkit-transition: all 0.2s linear;
|
63
|
+
overflow: auto; }
|
64
|
+
.nav .wrapper .area:hover .autohide {
|
65
|
+
height: 150px;
|
66
|
+
opacity: 1; }
|
67
|
+
.nav .wrapper .notes {
|
68
|
+
max-height: 40%;
|
69
|
+
overflow: auto; }
|
70
|
+
|
71
|
+
table th {
|
72
|
+
text-align: right; }
|
73
|
+
|
74
|
+
</style>
|
75
|
+
</head>
|
76
|
+
<body><div class="code">
|
77
|
+
<br />
|
78
|
+
<br />
|
79
|
+
<span class="Comment"># Gem Use</span><br />
|
80
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">hpricot</span><span class="StringDelimiter">'</span> <span class="Comment"># parse and modify html</span><br />
|
81
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">tilt</span><span class="StringDelimiter">'</span> <span class="Comment"># generate sidebar html</span><br />
|
82
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">tempfile</span><span class="StringDelimiter">'</span> <span class="Comment"># temporary vimscript</span><br />
|
83
|
+
<br />
|
84
|
+
<br />
|
85
|
+
<span class="rubyClass">module</span> <span class="Type">Vocco</span><br />
|
86
|
+
<br />
|
87
|
+
<span class="Comment"># File Responsibility</span><br />
|
88
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">vocco/generator</span><span class="StringDelimiter">'</span> <span class="Comment"># Generate docs</span><br />
|
89
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">vocco/cli</span><span class="StringDelimiter">'</span> <span class="Comment"># Command line interface</span><br />
|
90
|
+
<br />
|
91
|
+
<span class="rubyClass">class</span> << <span class="Constant">self</span><br />
|
92
|
+
<br />
|
93
|
+
<span class="Comment"># Vocco::run is the interface for using Vocco as a gem.</span><br />
|
94
|
+
<span class="PreProc">def</span> <span class="Function">run</span>(opts)<br />
|
95
|
+
validate(opts)<br />
|
96
|
+
<span class="Type">Generator</span>.new(<br />
|
97
|
+
<span class="Type">DEFAULTS</span>.merge(opts)<br />
|
98
|
+
).run<br />
|
99
|
+
<span class="PreProc">end</span><br />
|
100
|
+
<br />
|
101
|
+
<span class="PreProc">alias</span> <span class="rubySymbol">:run!</span> <span class="rubySymbol">:run</span><br />
|
102
|
+
<span class="PreProc">alias</span> <span class="rubySymbol">:start</span> <span class="rubySymbol">:run</span><br />
|
103
|
+
<br />
|
104
|
+
<span class="PreProc">def</span> <span class="Function">validate</span>(opts)<br />
|
105
|
+
bad_opts = opts.keys - <span class="Type">OPTION_NAMES</span><br />
|
106
|
+
<br />
|
107
|
+
<span class="Statement">if</span> bad_opts.any?<br />
|
108
|
+
<span class="Statement">raise</span> <span class="StringDelimiter">"</span><span class="String">Invalid options: </span><span class="Identifier">#{</span>bad_opts<span class="Identifier">}</span><span class="StringDelimiter">"</span><br />
|
109
|
+
<span class="Statement">end</span><br />
|
110
|
+
<span class="PreProc">end</span><br />
|
111
|
+
<br />
|
112
|
+
<span class="Comment"># Tries to read a property from the gemspec with the same name</span><br />
|
113
|
+
<span class="Comment"># as the working dir, in the working dir.</span><br />
|
114
|
+
<span class="PreProc">def</span> <span class="Function">gemspec</span>(prop)<br />
|
115
|
+
<span class="rubyControl">begin</span><br />
|
116
|
+
<span class="PreProc">require</span> <span class="StringDelimiter">'</span><span class="String">rubygems</span><span class="StringDelimiter">'</span><br />
|
117
|
+
<span class="rubyInstanceVariable">@gemspec</span> ||= <span class="Type">Gem</span>::<span class="Type">Specification</span>.load(<br />
|
118
|
+
<span class="Type">Dir</span>[<span class="StringDelimiter">'</span><span class="String">**/*.gemspec</span><span class="StringDelimiter">'</span>].first<br />
|
119
|
+
)<br />
|
120
|
+
<span class="rubyInstanceVariable">@gemspec</span>.send prop<br />
|
121
|
+
<span class="rubyControl">rescue</span><br />
|
122
|
+
<span class="Constant">nil</span><br />
|
123
|
+
<span class="rubyControl">end</span><br />
|
124
|
+
<span class="PreProc">end</span><br />
|
125
|
+
<span class="rubyClass">end</span><br />
|
126
|
+
<br />
|
127
|
+
<br />
|
128
|
+
<span class="Comment"># These are the available options. They can be given on</span><br />
|
129
|
+
<span class="Comment"># the command line, the linux way, or as a hash to</span><br />
|
130
|
+
<span class="Comment"># Vocco.run(...), the Rubygem way. The format is:</span><br />
|
131
|
+
<span class="Comment">#</span><br />
|
132
|
+
<span class="Comment"># [name, description,</span><br />
|
133
|
+
<span class="Comment"># default_value</span><br />
|
134
|
+
<span class="Comment"># ]</span><br />
|
135
|
+
<br />
|
136
|
+
<span class="Type">OPTIONS</span> = [<br />
|
137
|
+
[<span class="rubySymbol">:files</span>, <span class="StringDelimiter">"</span><span class="String">File match globs</span><span class="StringDelimiter">"</span>,<br />
|
138
|
+
<span class="StringDelimiter">%w{</span><span class="String">**/*.rb README LICENSE</span><span class="StringDelimiter">}</span><br />
|
139
|
+
],<br />
|
140
|
+
<br />
|
141
|
+
[<span class="rubySymbol">:out</span>, <span class="StringDelimiter">"</span><span class="String">Output directory</span><span class="StringDelimiter">"</span>,<br />
|
142
|
+
<span class="StringDelimiter">'</span><span class="String">./docs</span><span class="StringDelimiter">'</span><br />
|
143
|
+
],<br />
|
144
|
+
<br />
|
145
|
+
[<span class="rubySymbol">:notes</span>, <span class="StringDelimiter">"</span><span class="String">Note directories</span><span class="StringDelimiter">"</span>,<br />
|
146
|
+
[<span class="StringDelimiter">'</span><span class="String">./notes</span><span class="StringDelimiter">'</span>]<br />
|
147
|
+
],<br />
|
148
|
+
<br />
|
149
|
+
[<span class="rubySymbol">:name</span>, <span class="StringDelimiter">"</span><span class="String">Project name</span><span class="StringDelimiter">"</span>,<br />
|
150
|
+
gemspec(<span class="rubySymbol">:name</span>) || <span class="Type">File</span>.basename(<span class="Type">Dir</span>.pwd)<br />
|
151
|
+
],<br />
|
152
|
+
<br />
|
153
|
+
[<span class="rubySymbol">:site</span>, <span class="StringDelimiter">"</span><span class="String">Project url</span><span class="StringDelimiter">"</span>,<br />
|
154
|
+
gemspec(<span class="rubySymbol">:homepage</span>)<br />
|
155
|
+
],<br />
|
156
|
+
<br />
|
157
|
+
[<span class="rubySymbol">:vim</span>, <span class="StringDelimiter">"</span><span class="String">Vim command</span><span class="StringDelimiter">"</span>, <span class="StringDelimiter">%w{</span><span class="String">macvim gvim vim</span><span class="StringDelimiter">}</span><br />
|
158
|
+
]<br />
|
159
|
+
]<br />
|
160
|
+
<br />
|
161
|
+
<span class="Type">OPTION_NAMES</span> = <span class="Type">OPTIONS</span>.map {|<span class="rubyIdentifier">opt</span>| opt.first }<br />
|
162
|
+
<br />
|
163
|
+
<span class="Type">DEFAULTS</span> = {}<br />
|
164
|
+
<br />
|
165
|
+
<span class="Type">OPTIONS</span>.each <span class="rubyControl">do</span> |<span class="rubyIdentifier">opt</span>|<br />
|
166
|
+
<span class="Type">DEFAULTS</span>[opt[<span class="Constant">0</span>]] = opt[<span class="Constant">2</span>]<br />
|
167
|
+
<span class="rubyControl">end</span><br />
|
168
|
+
<br />
|
169
|
+
<span class="rubyClass">end</span><br />
|
170
|
+
<br />
|
171
|
+
<br />
|
172
|
+
</div><div class="nav"><div class="wrapper"><div class="area"><h3><strong><a href="http://github.com/jbe/vocco">Vocco</a></strong><span> : </span><span>vocco.rb</span></h3><p class="autohide">lib/vocco/<a href="./lib-vocco-generator.rb.html">generator.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-css.rb.html">css.rb</a><br />lib/vocco/generator/source_file/<a href="./lib-vocco-generator-source_file-html_template.rb.html">html_template.rb</a><br />lib/vocco/generator/<a href="./lib-vocco-generator-source_file.rb.html">source_file.rb</a><br />lib/vocco/<a href="./lib-vocco-cli.rb.html">cli.rb</a><br />lib/<a href="./lib-vocco.rb.html">vocco.rb</a><br /><a href="./README.html">README</a><br /></p></div><div class="area"><table><tr><th>Generated:</th><td>Mon Mar 14 01:26:25 +0100 2011</td></tr></table></div></div></div></body>
|
173
|
+
</html>
|