diff options
author | 2007-11-11 21:20:04 +0000 | |
---|---|---|
committer | 2007-11-11 21:20:04 +0000 | |
commit | 23ac22983def7c89f81f89e8ed72765d2efaaf12 (patch) | |
tree | 00d044ca780a505a8b1257425d11d2d9f48c3451 | |
parent | 519877804ed78d43d3635f910b5bcb1fdc34312e (diff) | |
download | paludis-23ac22983def7c89f81f89e8ed72765d2efaaf12.tar.gz paludis-23ac22983def7c89f81f89e8ed72765d2efaaf12.tar.xz |
(ruby) Add syntax highlighted ruby examples.
-rw-r--r-- | doc/api/ruby/Makefile.am | 21 | ||||
-rw-r--r-- | doc/api/ruby/create_ruby_examples.rb | 40 | ||||
-rw-r--r-- | doc/api/ruby/example_about.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/example_action.rb | 5 | ||||
-rw-r--r-- | doc/api/ruby/example_command_line.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/example_contents.rb | 5 | ||||
-rw-r--r-- | doc/api/ruby/example_dep_spec.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/example_query.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/example_version_operator.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/example_version_spec.rb | 4 | ||||
-rw-r--r-- | doc/api/ruby/ruby_syntax.css | 33 |
11 files changed, 120 insertions, 8 deletions
diff --git a/doc/api/ruby/Makefile.am b/doc/api/ruby/Makefile.am index d5041d7..b2703ac 100644 --- a/doc/api/ruby/Makefile.am +++ b/doc/api/ruby/Makefile.am @@ -19,7 +19,8 @@ htmldocs-subdirs : htmldocs-local : $(paludisapirubyhtml_DATA) -dist_noinst_SCRIPTS = create_ruby_doc.rb +dist_noinst_SCRIPTS = create_ruby_doc.rb \ + create_ruby_examples.rb examples = \ example_command_line.rb \ @@ -31,20 +32,24 @@ examples = \ example_version_operator.rb \ example_version_spec.rb -EXTRA_DIST = $(examples) +EXTRA_DIST = $(examples) \ + ruby_syntax.css if ENABLE_RUBY -all-local : rdoc +all-local : ruby -rdoc : ruby +ruby : rdoc examples -ruby : create_ruby_doc.rb $(examples) - rm -fr ruby +examples : rdoc $(examples) + $(RUBY) $(srcdir)/create_ruby_examples.rb $(examples) + cp ruby_syntax.css ruby + +rdoc : create_ruby_doc.rb + rm -rf ruby env TOP_SRCDIR="$(top_srcdir)" $(RUBY) \ $(srcdir)/create_ruby_doc.rb -t "Paludis Ruby API" -m Paludis --op ruby \ - $(top_srcdir)/ruby/*.cc \ - $(srcdir)/example_*.rb + $(top_srcdir)/ruby/*.cc install-data-local : mkdir -p $(DESTDIR)$(htmldir)/api diff --git a/doc/api/ruby/create_ruby_examples.rb b/doc/api/ruby/create_ruby_examples.rb new file mode 100644 index 0000000..87e48c1 --- /dev/null +++ b/doc/api/ruby/create_ruby_examples.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +# vim: set sw=4 sts=4 et tw=80 : + +require 'syntax/convertors/html' + +convertor = Syntax::Convertors::HTML.for_syntax('ruby') + +topuri = '../../' +toplinks = File.read('../toplinks.html.part.in') +header = File.read('../../header.html.part.in') +footer = File.read('../../footer.html.part.in') +css = '<link rel="stylesheet" href="ruby_syntax.css" type="text/css" />' +header.gsub!('###TOPLINKS###', toplinks) +header.gsub!('###TOPURI###', topuri) +header.gsub!("</head>", "#{css}</head>") + +ARGV.each do |example_file| + html = convertor.convert(File.read(example_file), false) + File.open('ruby/' + example_file.gsub(/rb$/,'html'), 'w') do |output| + output.write header + output.write "<h1>#{example_file}</h1>" + + #Grab examples description + html.scan(/=begin description(.*?)=end/m) {|desc| output.puts "<p>#{desc}</p>"} + + #enclose each line of an =begin block in a comment span + html.gsub!(/=begin description.*?=end/m) do |match| + match.gsub("\n", "</span>\n<span class=\"comment\">") + end + output.write '<pre>'; + i = 0 + html.each_line do |line| + i += 1 + output.print '<span class="lineno">' + i.to_s.rjust(5,'0') + '</span> <span class="ruby_code">' + line + '</span>' + end + output.write '</pre>' + output.write footer + end +end + diff --git a/doc/api/ruby/example_about.rb b/doc/api/ruby/example_about.rb index 8cf0a72..98dfc53 100644 --- a/doc/api/ruby/example_about.rb +++ b/doc/api/ruby/example_about.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=80 : +=begin description +Simple example showing how to use Paludis version constants. +=end + require 'Paludis' print "Built using Paludis ", Paludis::VersionMajor, ".", Paludis::VersionMinor, diff --git a/doc/api/ruby/example_action.rb b/doc/api/ruby/example_action.rb index 742e34f..21197b4 100644 --- a/doc/api/ruby/example_action.rb +++ b/doc/api/ruby/example_action.rb @@ -1,6 +1,11 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstarates how to use actions. It uses FetchAction to fetch source +files for all versions of sys-apps/paludis that support fetching +=end + require 'Paludis' require 'example_command_line' diff --git a/doc/api/ruby/example_command_line.rb b/doc/api/ruby/example_command_line.rb index 7352e8c..27fa07d 100644 --- a/doc/api/ruby/example_command_line.rb +++ b/doc/api/ruby/example_command_line.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=80 : +=begin description +Basic command line handling for most examples. +=end + require 'getoptlong' require 'singleton' require 'Paludis' diff --git a/doc/api/ruby/example_contents.rb b/doc/api/ruby/example_contents.rb index 259ce0d..26f2f9e 100644 --- a/doc/api/ruby/example_contents.rb +++ b/doc/api/ruby/example_contents.rb @@ -1,6 +1,11 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstrates how to use contents. It displays details about +the files installed by 'sys-apps/paludis'. +=end + require 'Paludis' require 'example_command_line' diff --git a/doc/api/ruby/example_dep_spec.rb b/doc/api/ruby/example_dep_spec.rb index 6fa6ff6..787de9a 100644 --- a/doc/api/ruby/example_dep_spec.rb +++ b/doc/api/ruby/example_dep_spec.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstrates how to handle dependecy specs. +=end + require 'Paludis' require 'example_command_line' diff --git a/doc/api/ruby/example_query.rb b/doc/api/ruby/example_query.rb index e73c390..00cecbd 100644 --- a/doc/api/ruby/example_query.rb +++ b/doc/api/ruby/example_query.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstrates how use the standard Query classes. +=end + require 'Paludis' require 'example_command_line' diff --git a/doc/api/ruby/example_version_operator.rb b/doc/api/ruby/example_version_operator.rb index 1a4c3e8..98ee21a 100644 --- a/doc/api/ruby/example_version_operator.rb +++ b/doc/api/ruby/example_version_operator.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstrates how use Paludis::version_spec_comparator. +=end + require 'Paludis' require 'example_command_line' diff --git a/doc/api/ruby/example_version_spec.rb b/doc/api/ruby/example_version_spec.rb index 8a2669d..0cfa6ff 100644 --- a/doc/api/ruby/example_version_spec.rb +++ b/doc/api/ruby/example_version_spec.rb @@ -1,6 +1,10 @@ #!/usr/bin/env ruby # vim: set sw=4 sts=4 et tw=100 : +=begin description +This example demonstrates how use VersionSpec. +=end + require 'Paludis' include Paludis diff --git a/doc/api/ruby/ruby_syntax.css b/doc/api/ruby/ruby_syntax.css new file mode 100644 index 0000000..fd323a3 --- /dev/null +++ b/doc/api/ruby/ruby_syntax.css @@ -0,0 +1,33 @@ +pre { + background-color: #f1f1f3; + color: #112; + padding: 10px; + font-size: 10pt; + overflow: auto; + margin: 4px 0px; + width: 95%; + font-family: "courier new", monospace +} + + /*font-family: "bitstream vera sans mono", "courier new", "courier", monospace*/ + + +/* Syntax highlighting */ +pre .normal {} +pre .comment { color: #800000; } +pre .keyword { color: #E08000; } +pre .method { color: #077; } +pre .class { color: #074; } +pre .module { color: #050; } +pre .punct { color: #447; font-weight: bold; } +pre .symbol { color: #099; } +pre .string { color: #944; background: #FFF; } +pre .char { color: #F07; } +pre .ident { color: #004; } +pre .constant { color: #07F; } +pre .regex { color: #B66; background: #FEF; } +pre .number { color: #F99; } +pre .attribute { color: #5bb; } +pre .global { color: #7FB; } +pre .expr { color: #227; } +pre .escape { color: #277; } |