rokko 0.1.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .rbenv-version
5
+ Gemfile.lock
6
+ .DS_Store
data/README.md CHANGED
@@ -7,7 +7,7 @@ the quick-and-dirty, hundred-line-long, literate-programming-style documentation
7
7
  Rokko reads Ruby source files and produces annotated source documentation in HTML format.
8
8
  Comments are formatted with Markdown and presented alongside syntax highlighted code so as to give an annotation effect.
9
9
 
10
- ##Why Rokko?
10
+ ## Why Rokko?
11
11
 
12
12
  * Rokko supports only Ruby source files (consider using [Rocco](http://rtomayko.github.com/rocco/)
13
13
  if you need more languages).
@@ -15,7 +15,7 @@ Comments are formatted with Markdown and presented alongside syntax highlighted
15
15
  * Rokko can generate offline-ready documentation (all assets are bundled).
16
16
  * Rokko can generate an index file with links to everything (like Table of Contents).
17
17
 
18
- ##Installation
18
+ ## Installation
19
19
 
20
20
  Install with Rubygems:
21
21
 
@@ -25,7 +25,7 @@ or Bundler:
25
25
 
26
26
  gem 'rokko'
27
27
 
28
- ##Usage
28
+ ## Usage
29
29
 
30
30
  `rokko` command can be used to generate documentation for a set of Ruby source files:
31
31
 
@@ -35,19 +35,23 @@ It is also possible to use Rokko as a Rake task:
35
35
 
36
36
  require 'rokko/task'
37
37
 
38
- Rokko::Task.new(:rokko, 'docs', ['lib/**/*.rb', 'README.md'], {:index => true, :local => true})
38
+ Rokko::Task.new(:rokko, 'docs', # task name, output directory
39
+ ['lib/**/*.rb', 'README.md'],
40
+ {:index => true, :local => true})
39
41
 
40
42
  And run:
41
43
 
42
44
  rake rokko
43
45
 
44
- ##Options and configuration
46
+ ## Options and configuration
45
47
 
46
- * `-i`, `--index=<file>` -- generate an index with links to HTML files or use `<file>` as index.
47
48
  * `-l`, `--local` -- generate offline-ready documentation.
49
+ * `-i`, `--index` -- generate index.html with links (TOC) to all generated HTML files.
50
+ * `-i <file>`, `--index=<file>` -- use `<file>` as index.html.
48
51
  * `-o`, `--output=<dir>` -- directory where generated HTML files are written.
52
+ * `-s`, `--stylesheet=<url>` -- CSS stylesheet to use instead of default one.
49
53
 
50
- ###Rake task
54
+ ### Rake task
51
55
 
52
56
  Usage:
53
57
 
@@ -56,6 +60,7 @@ Usage:
56
60
  Available options:
57
61
 
58
62
  * `:local` -- generate offline-ready documentation.
59
- * `:index` -- if value is a file name, then it will be used as an index. If value is `true` then
60
- an index file with table of contents will be generated.
63
+ * `:index => true` -- generate index.html with links (TOC) to all generated HTML files.
64
+ * `:index => <file>` -- use `<file>` as index.html.
65
+ * `:stylesheet` -- CSS stylesheet to use instead of default one.
61
66
 
data/Rakefile CHANGED
@@ -1,4 +1,10 @@
1
1
  $:.unshift(File.expand_path('lib'))
2
2
  require 'rokko/task'
3
+ require 'rake/testtask'
3
4
 
4
- Rokko::Task.new(:rokko, 'docs', ['lib/**/*.rb', 'README.md'], {:index => true, :local => true})
5
+ Rokko::Task.new(:rokko, 'docs', ['lib/**/*.rb', 'README.md'], {:index => true, :local => true})
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.test_files = ['test/tests.rb']
9
+ t.verbose = true
10
+ end
data/bin/rokko CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- #/ Usage: rokko [-i [INDEX_FILE]][-o <dir>] <file>...
3
+ #/ Usage: rokko [-i [INDEX_FILE]] [-o <dir>] [-s <stylesheet>] <file>...
4
4
  #/ Generate literate-programming-style documentation for Ruby source <file>s.
5
5
  #/
6
6
  #/ Options:
@@ -8,6 +8,7 @@
8
8
  #/ index
9
9
  #/ -l, --local Generate offline-ready documentation
10
10
  #/ -o, --output=<dir> Directory where generated HTML files are written
11
+ #/ -s, --stylesheet=<url> CSS stylesheet to use instead of default one
11
12
  #/ --help Show this help message
12
13
 
13
14
  require 'optparse'
@@ -37,6 +38,7 @@ options = {}
37
38
  ARGV.options { |o|
38
39
  o.program_name = File.basename($0)
39
40
  o.on("-o", "--output=DIR") {|dir| output_dir = dir}
41
+ o.on("-s", "--stylesheet=STYLESHEET") {|stylesheet| options[:stylesheet] = stylesheet}
40
42
  o.on("-i", "--index [FILE]") {|index| index ? options[:index] = index : options[:generate_index] = true}
41
43
  o.on("-l", "--local") {options[:local] = true}
42
44
  o.on_tail("-h", "--help") {usage($stdout, 0)}
@@ -75,7 +77,7 @@ if options[:generate_index]
75
77
  end
76
78
 
77
79
  # Generate and use specified file as index.
78
- if options[:index] && source_index = sources.delete(options[:index])
80
+ if options[:index] && source_index = sources.find{|s| s == options[:index]}
79
81
  rokko = Rokko::Rokko.new(source_index, sources, options.merge(:preserve_urls => true))
80
82
  dest = File.join(output_dir, 'index.html')
81
83
  puts "rokko: #{source_index} -> index.html"
@@ -27,7 +27,7 @@ h1, h2, h3, h4, h5, h6 {
27
27
  #background {
28
28
  position: fixed;
29
29
  top: 0; left: 525px; right: 0; bottom: 0;
30
- background: #f5f5ff;
30
+ background: #f8f8ff;
31
31
  border-left: 1px solid #e5e5ee;
32
32
  z-index: -1;
33
33
  }
@@ -110,7 +110,7 @@ table td {
110
110
  padding: 14px 15px 16px 25px;
111
111
  width: 100%;
112
112
  vertical-align: top;
113
- background: #f5f5ff;
113
+ background: #f8f8ff;
114
114
  border-left: 1px solid #e5e5ee;
115
115
  }
116
116
  pre, tt, code {
@@ -4,72 +4,42 @@ github.com style (c) Vasily Polovnyov <vast@whiteants.net>
4
4
 
5
5
  */
6
6
 
7
- pre code {
8
- display: block;
9
- color: #000
10
- }
11
-
12
- pre .comment,
13
- pre .template_comment,
14
- pre .diff .header,
15
- pre .javadoc {
7
+ pre .comment {
16
8
  color: #998;
17
9
  font-style: italic
18
10
  }
19
11
 
20
12
  pre .keyword,
21
- pre .css .rule .keyword,
22
- pre .winutils,
23
- pre .javascript .title,
24
- pre .lisp .title,
25
13
  pre .subst {
26
- color: #000;
14
+ color: #333;
27
15
  font-weight: bold
28
16
  }
29
17
 
30
18
  pre .number,
31
- pre .hexcolor {
32
- color: #40a070
19
+ pre .ruby .constant {
20
+ color: #099;
33
21
  }
34
22
 
35
- pre .string,
36
- pre .tag .value,
37
- pre .phpdoc,
38
- pre .tex .formula {
23
+ pre .string {
39
24
  color: #d14
40
25
  }
41
26
 
42
- pre .title,
43
- pre .id {
27
+ pre .title {
44
28
  color: #900;
45
29
  font-weight: bold
46
30
  }
47
31
 
48
- pre .javascript .title,
49
- pre .lisp .title,
50
32
  pre .subst {
51
33
  font-weight: normal
52
34
  }
53
35
 
54
- pre .class .title,
55
- pre .haskell .label,
56
- pre .tex .command {
36
+ pre .class .title {
57
37
  color: #458;
58
38
  font-weight: bold
59
39
  }
60
40
 
61
- pre .tag,
62
- pre .tag .title,
63
- pre .rules .property,
64
- pre .django .tag .keyword {
65
- color: #000080;
66
- font-weight: normal
67
- }
68
-
69
41
  pre .attribute,
70
- pre .variable,
71
- pre .instancevar,
72
- pre .lisp .body {
42
+ pre .variable {
73
43
  color: #008080
74
44
  }
75
45
 
@@ -83,46 +53,11 @@ pre .class {
83
53
  }
84
54
 
85
55
  pre .symbol,
86
- pre .ruby .symbol .string,
87
- pre .ruby .symbol .keyword,
88
- pre .ruby .symbol .keymethods,
89
- pre .lisp .keyword,
90
- pre .tex .special,
91
- pre .input_number {
56
+ pre .ruby .symbol .string {
92
57
  color: #990073
93
58
  }
94
59
 
95
- pre .builtin,
96
- pre .built_in,
97
- pre .lisp .title {
98
- color: #0086b3
99
- }
100
-
101
- pre .preprocessor,
102
- pre .pi,
103
- pre .doctype,
104
- pre .shebang,
105
- pre .cdata {
60
+ pre .shebang {
106
61
  color: #999;
107
62
  font-weight: bold
108
63
  }
109
-
110
- pre .deletion {
111
- background: #fdd
112
- }
113
-
114
- pre .addition {
115
- background: #dfd
116
- }
117
-
118
- pre .diff .change {
119
- background: #0086b3
120
- }
121
-
122
- pre .chunk {
123
- color: #aaa
124
- }
125
-
126
- pre .tex .formula {
127
- opacity: 0.5;
128
- }
@@ -1 +1 @@
1
- var hljs=new function(){function m(p){return p.replace(/&/gm,"&amp;").replace(/</gm,"&lt;")}function c(r,q,p){return RegExp(q,"m"+(r.cI?"i":"")+(p?"g":""))}function j(r){for(var p=0;p<r.childNodes.length;p++){var q=r.childNodes[p];if(q.nodeName=="CODE"){return q}if(!(q.nodeType==3&&q.nodeValue.match(/\s+/))){break}}}function g(t,s){var r="";for(var q=0;q<t.childNodes.length;q++){if(t.childNodes[q].nodeType==3){var p=t.childNodes[q].nodeValue;if(s){p=p.replace(/\n/g,"")}r+=p}else{if(t.childNodes[q].nodeName=="BR"){r+="\n"}else{r+=g(t.childNodes[q])}}}if(/MSIE [678]/.test(navigator.userAgent)){r=r.replace(/\r/g,"\n")}return r}function a(s){var q=s.className.split(/\s+/);q=q.concat(s.parentNode.className.split(/\s+/));for(var p=0;p<q.length;p++){var r=q[p].replace(/^language-/,"");if(d[r]||r=="no-highlight"){return r}}}function b(p){var q=[];(function(s,t){for(var r=0;r<s.childNodes.length;r++){if(s.childNodes[r].nodeType==3){t+=s.childNodes[r].nodeValue.length}else{if(s.childNodes[r].nodeName=="BR"){t+=1}else{if(s.childNodes[r].nodeType==1){q.push({event:"start",offset:t,node:s.childNodes[r]});t=arguments.callee(s.childNodes[r],t);q.push({event:"stop",offset:t,node:s.childNodes[r]})}}}}return t})(p,0);return q}function l(y,z,x){var r=0;var w="";var t=[];function u(){if(y.length&&z.length){if(y[0].offset!=z[0].offset){return(y[0].offset<z[0].offset)?y:z}else{return z[0].event=="start"?y:z}}else{return y.length?y:z}}function s(C){var D="<"+C.nodeName.toLowerCase();for(var A=0;A<C.attributes.length;A++){var B=C.attributes[A];D+=" "+B.nodeName.toLowerCase();if(B.value!==undefined&&B.value!==false&&B.value!==null){D+='="'+m(B.value)+'"'}}return D+">"}while(y.length||z.length){var v=u().splice(0,1)[0];w+=m(x.substr(r,v.offset-r));r=v.offset;if(v.event=="start"){w+=s(v.node);t.push(v.node)}else{if(v.event=="stop"){var p,q=t.length;do{q--;p=t[q];w+=("</"+p.nodeName.toLowerCase()+">")}while(p!=v.node);t.splice(q,1);while(q<t.length){w+=s(t[q]);q++}}}}return w+m(x.substr(r))}function i(){function p(w,u,x){if(w.compiled){return}var t;if(!x){w.bR=c(u,w.b?w.b:"\\B|\\b");if(!w.e&&!w.eW){w.e="\\B|\\b"}if(w.e){w.eR=c(u,w.e)}}if(w.i){w.iR=c(u,w.i)}if(w.r===undefined){w.r=1}if(w.k){w.lR=c(u,w.l||hljs.IR,true);for(var v in w.k){if(!w.k.hasOwnProperty(v)){continue}if(w.k[v] instanceof Object){t=w.k[v]}else{t=w.k;v="keyword"}for(var s in t){if(!t.hasOwnProperty(s)){continue}w.k[s]=[v,t[s]]}}}if(!w.c){w.c=[]}w.compiled=true;for(var r=0;r<w.c.length;r++){if(w.c[r]=="self"){w.c[r]=w}p(w.c[r],u,false)}if(w.starts){p(w.starts,u,false)}}for(var q in d){if(!d.hasOwnProperty(q)){continue}p(d[q].dM,d[q],true)}}function e(J,D){if(!i.called){i();i.called=true}function z(r,M){for(var L=0;L<M.c.length;L++){if(M.c[L].bR.test(r)){return M.c[L]}}}function w(L,r){if(C[L].e&&C[L].eR.test(r)){return 1}if(C[L].eW){var M=w(L-1,r);return M?M+1:0}return 0}function x(r,L){return L.i&&L.iR.test(r)}function A(O,N){var M=[];for(var L=0;L<O.c.length;L++){M.push(O.c[L].b)}var r=C.length-1;do{if(C[r].e){M.push(C[r].e)}r--}while(C[r+1].eW);if(O.i){M.push(O.i)}return c(N,"("+M.join("|")+")",true)}function s(M,L){var N=C[C.length-1];if(!N.t){N.t=A(N,H)}N.t.lastIndex=L;var r=N.t.exec(M);if(r){return[M.substr(L,r.index-L),r[0],false]}else{return[M.substr(L),"",true]}}function p(N,r){var L=H.cI?r[0].toLowerCase():r[0];var M=N.k[L];if(M&&M instanceof Array){return M}return false}function F(M,O){M=m(M);if(!O.k){return M}var N="";var P=0;O.lR.lastIndex=0;var L=O.lR.exec(M);while(L){N+=M.substr(P,L.index-P);var r=p(O,L);if(r){t+=r[1];N+='<span class="'+r[0]+'">'+L[0]+"</span>"}else{N+=L[0]}P=O.lR.lastIndex;L=O.lR.exec(M)}return N+M.substr(P,M.length-P)}function K(r,M){if(M.sL&&d[M.sL]){var L=e(M.sL,r);t+=L.keyword_count;return L.value}else{return F(r,M)}}function I(M,r){var L=M.cN?'<span class="'+M.cN+'">':"";if(M.rB){q+=L;M.buffer=""}else{if(M.eB){q+=m(r)+L;M.buffer=""}else{q+=L;M.buffer=r}}C.push(M);B+=M.r}function E(O,L,Q){var R=C[C.length-1];if(Q){q+=K(R.buffer+O,R);return false}var M=z(L,R);if(M){q+=K(R.buffer+O,R);I(M,L);return M.rB}var r=w(C.length-1,L);if(r){var N=R.cN?"</span>":"";if(R.rE){q+=K(R.buffer+O,R)+N}else{if(R.eE){q+=K(R.buffer+O,R)+N+m(L)}else{q+=K(R.buffer+O+L,R)+N}}while(r>1){N=C[C.length-2].cN?"</span>":"";q+=N;r--;C.length--}var P=C[C.length-1];C.length--;C[C.length-1].buffer="";if(P.starts){I(P.starts,"")}return R.rE}if(x(L,R)){throw"Illegal"}}var H=d[J];var C=[H.dM];var B=0;var t=0;var q="";try{var y,v=0;H.dM.buffer="";do{y=s(D,v);var u=E(y[0],y[1],y[2]);v+=y[0].length;if(!u){v+=y[1].length}}while(!y[2]);if(C.length>1){throw"Illegal"}return{r:B,keyword_count:t,value:q}}catch(G){if(G=="Illegal"){return{r:0,keyword_count:0,value:m(D)}}else{throw G}}}function f(t){var r={keyword_count:0,r:0,value:m(t)};var q=r;for(var p in d){if(!d.hasOwnProperty(p)){continue}var s=e(p,t);s.language=p;if(s.keyword_count+s.r>q.keyword_count+q.r){q=s}if(s.keyword_count+s.r>r.keyword_count+r.r){q=r;r=s}}if(q.language){r.second_best=q}return r}function h(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"<br>")}return r}function o(u,x,q){var y=g(u,q);var s=a(u);var w,r;if(s=="no-highlight"){return}if(s){w=e(s,y)}else{w=f(y);s=w.language}var p=b(u);if(p.length){r=document.createElement("pre");r.innerHTML=w.value;w.value=l(p,b(r),y)}w.value=h(w.value,x,q);var t=u.className;if(!t.match("(\\s|^)(language-)?"+s+"(\\s|$)")){t=t?(t+" "+s):s}if(/MSIE [678]/.test(navigator.userAgent)&&u.tagName=="CODE"&&u.parentNode.tagName=="PRE"){r=u.parentNode;var v=document.createElement("div");v.innerHTML="<pre><code>"+w.value+"</code></pre>";u=v.firstChild.firstChild;v.firstChild.cN=r.cN;r.parentNode.replaceChild(v.firstChild,r)}else{u.innerHTML=w.value}u.className=t;u.result={language:s,kw:w.keyword_count,re:w.r};if(w.second_best){u.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function k(){if(k.called){return}k.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p<r.length;p++){var q=j(r[p]);if(q){o(q,hljs.tabReplace)}}}function n(){if(window.addEventListener){window.addEventListener("DOMContentLoaded",k,false);window.addEventListener("load",k,false)}else{if(window.attachEvent){window.attachEvent("onload",k)}else{window.onload=k}}}var d={};this.LANGUAGES=d;this.highlight=e;this.highlightAuto=f;this.fixMarkup=h;this.highlightBlock=o;this.initHighlighting=k;this.initHighlightingOnLoad=n;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="\\b(0[xX][a-fA-F0-9]+|(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BINARY_NUMBER_RE="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BINARY_NUMBER_MODE={cN:"number",b:this.BINARY_NUMBER_RE,r:0};this.inherit=function(p,s){var r={};for(var q in p){r[q]=p[q]}if(s){for(var q in s){r[q]=s[q]}}return r}}();hljs.LANGUAGES.ruby=function(){var c="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var i="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var a={keyword:{and:1,"false":1,then:1,defined:1,module:1,"in":1,"return":1,redo:1,"if":1,BEGIN:1,retry:1,end:1,"for":1,"true":1,self:1,when:1,next:1,until:1,"do":1,begin:1,unless:1,END:1,rescue:1,nil:1,"else":1,"break":1,undef:1,not:1,"super":1,"class":1,"case":1,require:1,yield:1,alias:1,"while":1,ensure:1,elsif:1,or:1,def:1},keymethods:{__id__:1,__send__:1,abort:1,abs:1,"all?":1,allocate:1,ancestors:1,"any?":1,arity:1,assoc:1,at:1,at_exit:1,autoload:1,"autoload?":1,"between?":1,binding:1,binmode:1,"block_given?":1,call:1,callcc:1,caller:1,capitalize:1,"capitalize!":1,casecmp:1,"catch":1,ceil:1,center:1,chomp:1,"chomp!":1,chop:1,"chop!":1,chr:1,"class":1,class_eval:1,"class_variable_defined?":1,class_variables:1,clear:1,clone:1,close:1,close_read:1,close_write:1,"closed?":1,coerce:1,collect:1,"collect!":1,compact:1,"compact!":1,concat:1,"const_defined?":1,const_get:1,const_missing:1,const_set:1,constants:1,count:1,crypt:1,"default":1,default_proc:1,"delete":1,"delete!":1,delete_at:1,delete_if:1,detect:1,display:1,div:1,divmod:1,downcase:1,"downcase!":1,downto:1,dump:1,dup:1,each:1,each_byte:1,each_index:1,each_key:1,each_line:1,each_pair:1,each_value:1,each_with_index:1,"empty?":1,entries:1,eof:1,"eof?":1,"eql?":1,"equal?":1,"eval":1,exec:1,exit:1,"exit!":1,extend:1,fail:1,fcntl:1,fetch:1,fileno:1,fill:1,find:1,find_all:1,first:1,flatten:1,"flatten!":1,floor:1,flush:1,for_fd:1,foreach:1,fork:1,format:1,freeze:1,"frozen?":1,fsync:1,getc:1,gets:1,global_variables:1,grep:1,gsub:1,"gsub!":1,"has_key?":1,"has_value?":1,hash:1,hex:1,id:1,include:1,"include?":1,included_modules:1,index:1,indexes:1,indices:1,induced_from:1,inject:1,insert:1,inspect:1,instance_eval:1,instance_method:1,instance_methods:1,"instance_of?":1,"instance_variable_defined?":1,instance_variable_get:1,instance_variable_set:1,instance_variables:1,"integer?":1,intern:1,invert:1,ioctl:1,"is_a?":1,isatty:1,"iterator?":1,join:1,"key?":1,keys:1,"kind_of?":1,lambda:1,last:1,length:1,lineno:1,ljust:1,load:1,local_variables:1,loop:1,lstrip:1,"lstrip!":1,map:1,"map!":1,match:1,max:1,"member?":1,merge:1,"merge!":1,method:1,"method_defined?":1,method_missing:1,methods:1,min:1,module_eval:1,modulo:1,name:1,nesting:1,"new":1,next:1,"next!":1,"nil?":1,nitems:1,"nonzero?":1,object_id:1,oct:1,open:1,pack:1,partition:1,pid:1,pipe:1,pop:1,popen:1,pos:1,prec:1,prec_f:1,prec_i:1,print:1,printf:1,private_class_method:1,private_instance_methods:1,"private_method_defined?":1,private_methods:1,proc:1,protected_instance_methods:1,"protected_method_defined?":1,protected_methods:1,public_class_method:1,public_instance_methods:1,"public_method_defined?":1,public_methods:1,push:1,putc:1,puts:1,quo:1,raise:1,rand:1,rassoc:1,read:1,read_nonblock:1,readchar:1,readline:1,readlines:1,readpartial:1,rehash:1,reject:1,"reject!":1,remainder:1,reopen:1,replace:1,require:1,"respond_to?":1,reverse:1,"reverse!":1,reverse_each:1,rewind:1,rindex:1,rjust:1,round:1,rstrip:1,"rstrip!":1,scan:1,seek:1,select:1,send:1,set_trace_func:1,shift:1,singleton_method_added:1,singleton_methods:1,size:1,sleep:1,slice:1,"slice!":1,sort:1,"sort!":1,sort_by:1,split:1,sprintf:1,squeeze:1,"squeeze!":1,srand:1,stat:1,step:1,store:1,strip:1,"strip!":1,sub:1,"sub!":1,succ:1,"succ!":1,sum:1,superclass:1,swapcase:1,"swapcase!":1,sync:1,syscall:1,sysopen:1,sysread:1,sysseek:1,system:1,syswrite:1,taint:1,"tainted?":1,tell:1,test:1,"throw":1,times:1,to_a:1,to_ary:1,to_f:1,to_hash:1,to_i:1,to_int:1,to_io:1,to_proc:1,to_s:1,to_str:1,to_sym:1,tr:1,"tr!":1,tr_s:1,"tr_s!":1,trace_var:1,transpose:1,trap:1,truncate:1,"tty?":1,type:1,ungetc:1,uniq:1,"uniq!":1,unpack:1,unshift:1,untaint:1,untrace_var:1,upcase:1,"upcase!":1,update:1,upto:1,"value?":1,values:1,values_at:1,warn:1,write:1,write_nonblock:1,"zero?":1,zip:1}};var d={cN:"yardoctag",b:"@[A-Za-z]+"};var k=[{cN:"comment",b:"#",e:"$",c:[d]},{cN:"comment",b:"^\\=begin",e:"^\\=end",c:[d],r:10},{cN:"comment",b:"^__END__",e:"\\n$"}];var e={cN:"subst",b:"#\\{",e:"}",l:c,k:a};var g=[hljs.BE,e];var f=[{cN:"string",b:"'",e:"'",c:g,r:0},{cN:"string",b:'"',e:'"',c:g,r:0},{cN:"string",b:"%[qw]?\\(",e:"\\)",c:g,r:10},{cN:"string",b:"%[qw]?\\[",e:"\\]",c:g,r:10},{cN:"string",b:"%[qw]?{",e:"}",c:g,r:10},{cN:"string",b:"%[qw]?<",e:">",c:g,r:10},{cN:"string",b:"%[qw]?/",e:"/",c:g,r:10},{cN:"string",b:"%[qw]?%",e:"%",c:g,r:10},{cN:"string",b:"%[qw]?-",e:"-",c:g,r:10},{cN:"string",b:"%[qw]?\\|",e:"\\|",c:g,r:10}];var h={cN:"function",b:"\\bdef\\s+",e:" |$|;",l:c,k:a,c:[{cN:"title",b:i,l:c,k:a},{cN:"params",b:"\\(",e:"\\)",l:c,k:a}].concat(k)};var j={cN:"identifier",b:c,l:c,k:a,r:0};var b=k.concat(f.concat([{cN:"class",b:"\\b(class|module)\\b",e:"$|;",k:{"class":1,module:1},c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+hljs.IR+"::)?"+hljs.IR}]}].concat(k)},h,{cN:"constant",b:"(::)?([A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:f.concat([j]),r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},j,{b:"("+hljs.RSR+")\\s*",c:k.concat([{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[hljs.BE]}]),r:0}]));e.c=b;h.c[1].c=b;return{dM:{l:c,k:a,c:b}}}();
1
+ var hljs=new function(){function l(o){return o.replace(/&/gm,"&amp;").replace(/</gm,"&lt;")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(C,D){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=E.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function F(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():F()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function G(K,r){w+=K;if(r===undefined){x+=J();return}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE}if(t(r,A)){throw"Illegal"}}var E=e[C];f(E);var A=E;var w="";var B=0;var v=0;var x="";try{var u,q=0;while(true){A.t.lastIndex=q;u=A.t.exec(D);if(!u){break}var p=G(D.substr(q,u.index-q),u[0]);q=u.index+(p?0:u[0].length)}G(D.substr(q),undefined);return{r:B,keyword_count:v,value:x,language:C}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(D)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.ruby=function(e){var a="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var j="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var g={keyword:"and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include"};var c={cN:"yardoctag",b:"@[A-Za-z]+"};var k=[{cN:"comment",b:"#",e:"$",c:[c]},{cN:"comment",b:"^\\=begin",e:"^\\=end",c:[c],r:10},{cN:"comment",b:"^__END__",e:"\\n$"}];var d={cN:"subst",b:"#\\{",e:"}",l:a,k:g};var i=[e.BE,d];var b=[{cN:"string",b:"'",e:"'",c:i,r:0},{cN:"string",b:'"',e:'"',c:i,r:0},{cN:"string",b:"%[qw]?\\(",e:"\\)",c:i},{cN:"string",b:"%[qw]?\\[",e:"\\]",c:i},{cN:"string",b:"%[qw]?{",e:"}",c:i},{cN:"string",b:"%[qw]?<",e:">",c:i,r:10},{cN:"string",b:"%[qw]?/",e:"/",c:i,r:10},{cN:"string",b:"%[qw]?%",e:"%",c:i,r:10},{cN:"string",b:"%[qw]?-",e:"-",c:i,r:10},{cN:"string",b:"%[qw]?\\|",e:"\\|",c:i,r:10}];var h={cN:"function",bWK:true,e:" |$|;",k:"def",c:[{cN:"title",b:j,l:a,k:g},{cN:"params",b:"\\(",e:"\\)",l:a,k:g}].concat(k)};var f=k.concat(b.concat([{cN:"class",bWK:true,e:"$|;",k:"class module",c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+e.IR+"::)?"+e.IR}]}].concat(k)},h,{cN:"constant",b:"(::)?(\\b[A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:b.concat([{b:j}]),r:0},{cN:"symbol",b:a+":",r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{b:"("+e.RSR+")\\s*",c:k.concat([{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[e.BE,d]}]),r:0}]));d.c=f;h.c[1].c=f;return{l:a,k:g,c:f}}(hljs);
@@ -1,3 +1,5 @@
1
+ # Layout containing README file and "Table of Contents" with links
2
+ # to all generated HTML files
1
3
  class Rokko::IndexLayout < Rokko::Layout
2
4
  self.template_file = File.join(File.dirname(__FILE__), 'index_layout.mustache')
3
5
 
data/lib/rokko/layout.rb CHANGED
@@ -20,7 +20,8 @@ module Rokko
20
20
 
21
21
  "<style type=\"text/css\" media=\"screen, projection\">#{docco}\n#{highlight}</style>"
22
22
  else
23
- "<link rel=\"stylesheet\" href=\"http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/docco.css\" />
23
+ stylesheet_link = @options[:stylesheet] || "http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/docco.css"
24
+ "<link rel=\"stylesheet\" href=\"#{stylesheet_link}\" />
24
25
  <link rel=\"stylesheet\" href=\"http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/highlight.css\" />"
25
26
  end
26
27
  end
@@ -62,6 +63,8 @@ module Rokko
62
63
  if @doc.options[:index] || @doc.options[:generate_index]
63
64
  sources.unshift({:path => 'index.html', :basename => 'index', :url => relative_url('index.html')})
64
65
  end
66
+
67
+ sources
65
68
  end
66
69
 
67
70
  private
data/lib/rokko/task.rb CHANGED
@@ -1,17 +1,25 @@
1
+ # ### Rokko Rake task
2
+ #
1
3
  # Usage:
2
4
  #
3
- # Rokko::Task.new(:task_name, output_dir, filelist, opts)
4
- #
5
- # Example:
6
- # Rokko::Task.new(:rokko, 'docs',
5
+ # require 'rokko/task'
6
+ #
7
+ # Rokko::Task.new(:rokko, 'docs', # task name, output dir
7
8
  # ['lib/**/*.rb', 'README.md'],
8
9
  # {:index => true, :local => true})
9
10
  #
11
+ # And run with:
12
+ # rake rokko
13
+ #
10
14
  # Available options:
11
15
  #
12
16
  # * `:local` -- generate offline-ready documentation.
13
- # * `:index` -- if value is a file name, then it will be used as an index. If value is `true` then
14
- # an index file with table of contents will be generated.
17
+ # * `:index => true` -- generate index.html with links (TOC) to all generated HTML files.
18
+ # * `:index => <file>` -- use `<file>` as index.html.
19
+ # * `:stylesheet` -- CSS stylesheet to use instead of default one.
20
+
21
+ # `Rokko::Task.new` takes a task name, the destination directory,
22
+ # a source file pattern or file list
15
23
  require 'rokko'
16
24
 
17
25
  module Rokko
@@ -30,6 +38,7 @@ module Rokko
30
38
  define
31
39
  end
32
40
 
41
+ # Actually setup the task
33
42
  def define
34
43
  desc "Generate rokko documentation"
35
44
  task @name do
@@ -57,7 +66,7 @@ module Rokko
57
66
  end
58
67
 
59
68
  # Run specified file through rokko and use it as index
60
- if @options[:index] && source_index = @sources.delete(@options[:index])
69
+ if @options[:index] && source_index = @sources.find{|s| s == @options[:index]}
61
70
  rokko = Rokko.new(source_index, @sources, @options.merge(:preserve_urls => true))
62
71
  out_dest = File.join(@dest, 'index.html')
63
72
  puts "rokko: #{source_index} -> index.html"
data/lib/rokko/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rokko
2
- VERSION = "0.1.3"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/rokko.rb CHANGED
@@ -1,14 +1,40 @@
1
- # ##Rokko -- fat-free [Rocco](http://rtomayko.github.com/rocco/)
1
+ # ## Rokko -- fat-free [Rocco](http://rtomayko.github.com/rocco/)
2
+ # Rokko is an else one Ruby port of [Docco](http://jashkenas.github.com/docco/),
3
+ # the quick-and-dirty, hundred-line-long, literate-programming-style documentation generator.
4
+ #
5
+ # Rokko reads Ruby source files and produces annotated source documentation in HTML format.
6
+ # Comments are formatted with Markdown and presented alongside syntax highlighted code so as
7
+ # to give an annotation effect.
8
+ #
9
+ # ### Why Rokko?
10
+ #
11
+ # * Rokko supports only Ruby source files (consider using [Rocco](http://rtomayko.github.com/rocco/)
12
+ # if you need more languages).
13
+ # * Rokko uses awesome [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) library
14
+ # for syntax highlighting.
15
+ # * Rokko can generate offline-ready documentation (all assets are bundled).
16
+ # * Rokko can generate an index file with links to everything (like Table of Contents).
17
+
18
+ # We'll definitely need RDiscount (Markdown library)
19
+ # and Mustache (templating engine)
2
20
  require 'rdiscount'
3
- require 'rokko/version'
21
+ require 'mustache'
22
+ require File.expand_path('../rokko/version', __FILE__)
4
23
 
24
+ # ### Public interface
25
+ # `Rokko.new` takes a filename, an optional list of source filenames
26
+ # for other documentation sources, an options hash, and an optional block.
27
+ #
28
+ # When `block` is given, it must return a string with file contents.
29
+ # With no `block`, the file is read to retrieve data.
5
30
  module Rokko
6
31
  class Rokko
7
32
  attr_reader :file
8
33
  attr_reader :sections
9
34
  attr_reader :sources
10
35
  attr_reader :options
11
-
36
+
37
+ # Comment patterns
12
38
  @@comment_pattern = /^\s*#(?!\{)\s?/
13
39
  @@block_comment_start = /^\s*=begin\s*$/
14
40
  @@block_comment_end = /^\s*=end\s*$/
@@ -26,7 +52,10 @@ module Rokko
26
52
 
27
53
  @sections = prettify(split(parse(@data)))
28
54
  end
29
-
55
+
56
+ # Parse the raw file data into a list of two-tuples. Each tuple has the form
57
+ # `[docs, code]` where both elements are arrays containing the raw lines
58
+ # parsed from the input file, comment characters stripped.
30
59
  def parse(data)
31
60
  sections = []
32
61
  docs, code = [], []
@@ -117,8 +146,7 @@ module Rokko
117
146
 
118
147
 
119
148
  def to_html
120
- require 'mustache'
121
- require 'rokko/layout'
149
+ require File.expand_path('../rokko/layout', __FILE__)
122
150
 
123
151
  ::Rokko::Layout.new(self).render
124
152
  end
@@ -0,0 +1,7 @@
1
+ =begin
2
+ ruby block comment
3
+ =end
4
+
5
+ def hello
6
+ "world"
7
+ end
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ puts "hello"
@@ -0,0 +1,5 @@
1
+ # filename.rb perfecto!
2
+
3
+ def perfecto
4
+ true
5
+ end
@@ -0,0 +1,6 @@
1
+ # Hurrah!
2
+ class Post
3
+ # save it
4
+ def save111111
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/env ruby
2
+ # test shebangs
3
+ puts "bang! bang!"
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ def rokkoize(contents, options = {})
2
+ options = {:filename => 'filename.rb'}.merge(options)
3
+ Rokko::Rokko.new(options[:filename], [options[:filename]], options) do
4
+ contents
5
+ end
6
+ end
7
+
8
+ def fixture(filename)
9
+ File.read(File.expand_path("../fixtures/#{filename}.rb", __FILE__))
10
+ end
@@ -0,0 +1,39 @@
1
+ class TestRokkoAssets < Test::Unit::TestCase
2
+ ROKKO_FIXTURE = fixture('filename')
3
+
4
+ def setup
5
+ @html = rokkoize(ROKKO_FIXTURE).to_html
6
+ end
7
+
8
+ def test_default_stylesheet_links
9
+ assert @html.include?("<link rel=\"stylesheet\" href=\"http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/docco.css\" />")
10
+ assert @html.include?("<link rel=\"stylesheet\" href=\"http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/highlight.css\" />")
11
+ end
12
+
13
+ def test_highlightjs_initialization
14
+ assert @html.include?("<script>hljs.initHighlightingOnLoad();</script>")
15
+ end
16
+
17
+ def test_default_scripts
18
+ assert @html.include?("<script src=\"http://vast.github.com/rokko/assets/v#{::Rokko::VERSION}/highlight.pack.js\"></script>")
19
+ end
20
+
21
+ def test_assets_embedding
22
+ contents = rokkoize(ROKKO_FIXTURE, :local => true).to_html
23
+
24
+ assert contents.include?(asset_contents('docco.css'))
25
+ assert contents.include?(asset_contents('highlight.css'))
26
+ assert contents.include?(asset_contents('highlight.pack.js'))
27
+ end
28
+
29
+ def test_custom_stylesheet
30
+ contents = rokkoize(ROKKO_FIXTURE, :stylesheet => 'http://ya.ru/base.css').to_html
31
+
32
+ assert contents.include?('<link rel="stylesheet" href="http://ya.ru/base.css" />')
33
+ end
34
+
35
+ private
36
+ def asset_contents(filename)
37
+ File.read(File.expand_path("../../lib/rokko/assets/#{filename}",__FILE__))
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ class RokkoBasicTests < Test::Unit::TestCase
2
+ ROKKO_FIXTURE = fixture('filename')
3
+
4
+ def test_rokko_exists_and_is_instancable
5
+ assert_nothing_raised do
6
+ r = rokkoize(ROKKO_FIXTURE)
7
+ end
8
+ end
9
+
10
+ def test_filename
11
+ assert_equal "filename.rb", rokkoize(ROKKO_FIXTURE).file
12
+ end
13
+
14
+ def test_sources
15
+ assert_equal ["filename.rb"], rokkoize(ROKKO_FIXTURE).sources
16
+ end
17
+
18
+ def test_sections
19
+ r = rokkoize(ROKKO_FIXTURE)
20
+ assert_equal 1, r.sections.length
21
+ assert_equal 2, r.sections[0].length # docs + code
22
+ assert_equal "<p>filename.rb perfecto!</p>\n", r.sections[0][0] # docs
23
+ assert_equal "\ndef perfecto\n true\nend", r.sections[0][1] # code
24
+ end
25
+
26
+ def test_to_html
27
+ r = rokkoize(ROKKO_FIXTURE)
28
+ assert_nothing_raised do
29
+ html = r.to_html
30
+ end
31
+ end
32
+
33
+ def test_to_html_generates_proper_html
34
+ html = rokkoize(ROKKO_FIXTURE).to_html
35
+ assert html.include?('<h1>filename.rb</h1>')
36
+ assert html.include?('<p>filename.rb perfecto!</p>')
37
+ assert html.include?('def perfecto')
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ class RokkoParsingTest < Test::Unit::TestCase
2
+ def test_shebang_first_line
3
+ html = rokkoize(fixture('shebang')).to_html
4
+ assert !html.include?('env ruby')
5
+ end
6
+
7
+ def test_block_comments
8
+ sections = rokkoize(fixture('block_comments')).sections
9
+ assert_equal "<p>ruby block comment</p>\n", sections[0][0]
10
+ end
11
+
12
+ def test_ruby_encoding
13
+ html = rokkoize(fixture('encoding')).to_html
14
+ assert !html.include?('encoding')
15
+ end
16
+
17
+ def test_normalizing
18
+ r = Rokko::Rokko.new('test.rb', ['test.rb']) {""}
19
+ sections = r.parse(fixture('normalizing'))
20
+ assert_equal "save it", sections[1][0][0]
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ class RokkoSourcesTest < Test::Unit::TestCase
2
+ def test_flat_source_list
3
+ r = Rokko::Rokko.new('filename.rb', ['a.rb', 'b.rb']) do
4
+ "# comment\n puts 'code'"
5
+ end
6
+ html = r.to_html
7
+
8
+ assert html.include?('<a class="source" href="./a.html">a.rb</a>')
9
+ assert html.include?('<a class="source" href="./b.html">b.rb</a>')
10
+ end
11
+
12
+ def test_heiarachical_sourcelist
13
+ r = Rokko::Rokko.new('filename.rb', ['a/a.rb', 'c/b.rb', '../d.rb']) do
14
+ "# comment\n puts 'code'"
15
+ end
16
+ html = r.to_html
17
+
18
+ assert html.include?('<a class="source" href="a/a.html">a.rb</a>')
19
+ assert html.include?('<a class="source" href="c/b.html">b.rb</a>')
20
+ assert html.include?('<a class="source" href="../d.html">d.rb</a>')
21
+ end
22
+ end
data/test/tests.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'test/unit'
2
+ require File.expand_path('../helper', __FILE__)
3
+ require File.expand_path('../../lib/rokko', __FILE__)
4
+
5
+ Dir[File.expand_path('../test_*.rb', __FILE__)].each {|f| require f}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rokko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.5.0
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: 2012-05-17 00:00:00.000000000Z
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mustache
16
- requirement: &2157000060 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157000060
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rdiscount
27
- requirement: &2156999640 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2156999640
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: fat-free [rocco](http://rtomayko.github.com/rocco/)
37
47
  email:
38
48
  - vasily@polovnyov.ru
@@ -46,7 +56,6 @@ files:
46
56
  - LICENSE
47
57
  - README.md
48
58
  - Rakefile
49
- - TODO
50
59
  - bin/rokko
51
60
  - lib/rokko.rb
52
61
  - lib/rokko/assets/docco.css
@@ -59,6 +68,17 @@ files:
59
68
  - lib/rokko/task.rb
60
69
  - lib/rokko/version.rb
61
70
  - rokko.gemspec
71
+ - test/fixtures/block_comments.rb
72
+ - test/fixtures/encoding.rb
73
+ - test/fixtures/filename.rb
74
+ - test/fixtures/normalizing.rb
75
+ - test/fixtures/shebang.rb
76
+ - test/helper.rb
77
+ - test/test_assets.rb
78
+ - test/test_basics.rb
79
+ - test/test_parsing.rb
80
+ - test/test_sources.rb
81
+ - test/tests.rb
62
82
  homepage: http://vast.github.com/rokko/
63
83
  licenses: []
64
84
  post_install_message:
@@ -79,8 +99,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
99
  version: '0'
80
100
  requirements: []
81
101
  rubyforge_project: rokko
82
- rubygems_version: 1.8.15
102
+ rubygems_version: 1.8.23
83
103
  signing_key:
84
104
  specification_version: 3
85
105
  summary: Else one ruby port of [Docco](http://jashkenas.github.com/docco/)
86
- test_files: []
106
+ test_files:
107
+ - test/fixtures/block_comments.rb
108
+ - test/fixtures/encoding.rb
109
+ - test/fixtures/filename.rb
110
+ - test/fixtures/normalizing.rb
111
+ - test/fixtures/shebang.rb
112
+ - test/helper.rb
113
+ - test/test_assets.rb
114
+ - test/test_basics.rb
115
+ - test/test_parsing.rb
116
+ - test/test_sources.rb
117
+ - test/tests.rb
data/TODO DELETED
@@ -1,6 +0,0 @@
1
- [ ] documentation
2
- [x] option for offline/online ready documentation
3
- [x] rake task
4
- [ ] tests
5
- [x] explain key differences
6
- [x] README and LICENSE