Showing the changes to lib/docs (6 of 17 files). Show all
Unified · Split
| @@ -0,0 +1,49 @@ | ||
| 1 | +module Docs | |
| 2 | + class Rdoc | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + root_page? ? root : other | |
| 6 | + doc | |
| 7 | + end | |
| 8 | + | |
| 9 | + def root | |
| 10 | + at_css('.section-header').remove | |
| 11 | + | |
| 12 | + # Remove skipped items | |
| 13 | + css('li > span').each do |node| | |
| 14 | + node.parent.remove | |
| 15 | + end | |
| 16 | + end | |
| 17 | + | |
| 18 | + def other | |
| 19 | + css('hr').remove | |
| 20 | + | |
| 21 | + # Remove paragraph/up links | |
| 22 | + css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span').remove | |
| 23 | + | |
| 24 | + # Move id attributes to headings | |
| 25 | + css('.method-detail').each do |node| | |
| 26 | + next unless heading = node.at_css('.method-heading') | |
| 27 | + heading['id'] = node['id'] | |
| 28 | + node.remove_attribute 'id' | |
| 29 | + end | |
| 30 | + | |
| 31 | + # Convert "click to toggle source" into a link | |
| 32 | + css('.method-click-advice').each do |node| | |
| 33 | + node.name = 'a' | |
| 34 | + node.content = 'Show source' | |
| 35 | + end | |
| 36 | + | |
| 37 | + # Add class to differentiate Ruby code from C code | |
| 38 | + css('.method-source-code > pre').each do |node| | |
| 39 | + node['class'] = node.at_css('.ruby-keyword') ? 'ruby' : 'c' | |
| 40 | + end | |
| 41 | + | |
| 42 | + # Remove code highlighting | |
| 43 | + css('pre').each do |node| | |
| 44 | + node.content = node.content | |
| 45 | + end | |
| 46 | + end | |
| 47 | + end | |
| 48 | + end | |
| 49 | +end | |
| @@ -0,0 +1,26 @@ | ||
| 1 | +module Docs | |
| 2 | + class Rdoc | |
| 3 | + class ContainerFilter < Filter | |
| 4 | + def call | |
| 5 | + if root_page? | |
| 6 | + at_css '#classindex-section' | |
| 7 | + else | |
| 8 | + container = at_css '#documentation' | |
| 9 | + | |
| 10 | + # Add <dl> mentioning parent class and included modules | |
| 11 | + meta = Nokogiri::XML::Node.new 'dl', doc | |
| 12 | + meta['class'] = 'meta' | |
| 13 | + if parent = at_css('#parent-class-section') | |
| 14 | + meta << %(<dt>Parent:</dt><dd class="meta-parent">#{parent.at_css('.link').inner_html}</dd>) | |
| 15 | + end | |
| 16 | + if includes = at_css('#includes-section') | |
| 17 | + meta << %(<dt>Included modules:</dt><dd class="meta-includes">#{includes.css('a').map(&:to_html).join(', ')}</dd>) | |
| 18 | + end | |
| 19 | + container.at_css('h1').after(meta) | |
| 20 | + | |
| 21 | + container | |
| 22 | + end | |
| 23 | + end | |
| 24 | + end | |
| 25 | + end | |
| 26 | +end | |
| @@ -0,0 +1,38 @@ | ||
| 1 | +module Docs | |
| 2 | + class Rdoc | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('h1').content.strip | |
| 6 | + name.sub! 'class ', '' | |
| 7 | + name.sub! 'module ', '' | |
| 8 | + name | |
| 9 | + end | |
| 10 | + | |
| 11 | + def get_type | |
| 12 | + type = name.dup | |
| 13 | + | |
| 14 | + unless type.sub! %r{::.*\z}, '' | |
| 15 | + parent = at_css('.meta-parent').try(:content).to_s.strip | |
| 16 | + return 'Errors' if type.end_with?('Error') || parent.end_with?('Error') || parent.end_with?('Exception') | |
| 17 | + end | |
| 18 | + | |
| 19 | + type | |
| 20 | + end | |
| 21 | + | |
| 22 | + def additional_entries | |
| 23 | + return [] if root_page? | |
| 24 | + require 'cgi' | |
| 25 | + | |
| 26 | + css('.method-detail').map do |node| | |
| 27 | + name = node['id'].dup | |
| 28 | + name.sub! %r{\A\w+?\-.}, '' | |
| 29 | + name.sub! %r{\A-(?!\d)}, '' | |
| 30 | + name.gsub! '-', '%' | |
| 31 | + name = CGI.unescape(name) | |
| 32 | + name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#') | |
| 33 | + [name, node['id']] | |
| 34 | + end | |
| 35 | + end | |
| 36 | + end | |
| 37 | + end | |
| 38 | +end | |
| @@ -0,0 +1,52 @@ | ||
| 1 | +module Docs | |
| 2 | + class Ruby | |
| 3 | + class EntriesFilter < Docs::Rdoc::EntriesFilter | |
| 4 | + REPLACE_TYPE = { | |
| 5 | + 'ACL' => 'DRb', | |
| 6 | + 'Addrinfo' => 'Socket', | |
| 7 | + 'BigMath' => 'BigDecimal', | |
| 8 | + 'CMath' => 'Math', | |
| 9 | + 'ConditionVariable' => 'Mutex', | |
| 10 | + 'DEBUGGER__' => 'Debug', | |
| 11 | + 'Errno' => 'Errors', | |
| 12 | + 'FileTest' => 'File', | |
| 13 | + 'Jacobian' => 'BigDecimal', | |
| 14 | + 'LUSolve' => 'BigDecimal', | |
| 15 | + 'Newton' => 'BigDecimal', | |
| 16 | + 'PP' => 'PrettyPrint', | |
| 17 | + 'Profiler__' => 'Profiler', | |
| 18 | + 'Psych' => 'YAML', | |
| 19 | + 'Rinda' => 'DRb', | |
| 20 | + 'SortedSet' => 'Set', | |
| 21 | + 'TCPServer' => 'Socket', | |
| 22 | + 'TempIO' => 'Tempfile', | |
| 23 | + 'ThWait' => 'Thread', | |
| 24 | + 'UNIXServer' => 'Socket' } | |
| 25 | + | |
| 26 | + REPLACE_TYPE_STARTS_WITH = { | |
| 27 | + 'Monitor' => 'Monitor', | |
| 28 | + 'Mutex' => 'Mutex', | |
| 29 | + 'Shell' => 'Shell', | |
| 30 | + 'Sync' => 'Sync', | |
| 31 | + 'Thread' => 'Thread' } | |
| 32 | + | |
| 33 | + REPLACE_TYPE_ENDS_WITH = { | |
| 34 | + 'Queue' => 'Queue', | |
| 35 | + 'Socket' => 'Socket' } | |
| 36 | + | |
| 37 | + def get_type | |
| 38 | + type = super | |
| 39 | + | |
| 40 | + REPLACE_TYPE_STARTS_WITH.each_pair do |key, value| | |
| 41 | + return value if type.start_with?(key) | |
| 42 | + end | |
| 43 | + | |
| 44 | + REPLACE_TYPE_ENDS_WITH.each_pair do |key, value| | |
| 45 | + return value if type.end_with?(key) | |
| 46 | + end | |
| 47 | + | |
| 48 | + REPLACE_TYPE[type] || type | |
| 49 | + end | |
| 50 | + end | |
| 51 | + end | |
| 52 | +end | |
| @@ -0,0 +1,13 @@ | ||
| 1 | +module Docs | |
| 2 | + class Rdoc < FileScraper | |
| 3 | + self.abstract = true | |
| 4 | + self.type = 'rdoc' | |
| 5 | + self.root_path = 'index.html' | |
| 6 | + | |
| 7 | + html_filters.replace 'container', 'rdoc/container' | |
| 8 | + html_filters.push 'rdoc/entries', 'rdoc/clean_html', 'title' | |
| 9 | + | |
| 10 | + options[:title] = false | |
| 11 | + options[:skip] = %w(table_of_contents.html) | |
| 12 | + end | |
| 13 | +end | |
| @@ -0,0 +1,85 @@ | ||
| 1 | +module Docs | |
| 2 | + class Ruby < Rdoc | |
| 3 | + # Generated with: | |
| 4 | + # rdoc \ | |
| 5 | + # --format=darkfish \ | |
| 6 | + # --no-line-numbers \ | |
| 7 | + # --op=rdoc \ | |
| 8 | + # --visibility=public \ | |
| 9 | + # *.c \ | |
| 10 | + # lib/**/*.rb \ | |
| 11 | + # lib/*.rb \ | |
| 12 | + # ext/bigdecimal/*.c \ | |
| 13 | + # ext/bigdecimal/lib/*.rb \ | |
| 14 | + # ext/bigdecimal/lib/**/*.rb \ | |
| 15 | + # ext/date/*.c \ | |
| 16 | + # ext/date/lib/*.rb \ | |
| 17 | + # ext/date/lib/**/*.rb \ | |
| 18 | + # ext/digest/*.c \ | |
| 19 | + # ext/digest/**/*.c \ | |
| 20 | + # ext/digest/**/*.rb \ | |
| 21 | + # ext/json/lib/**/*.rb \ | |
| 22 | + # ext/pathname/*.c \ | |
| 23 | + # ext/pathname/lib/*.rb \ | |
| 24 | + # ext/psych/*.c \ | |
| 25 | + # ext/psych/lib/*.rb \ | |
| 26 | + # ext/psych/lib/**/*.rb \ | |
| 27 | + # ext/readline/*.c \ | |
| 28 | + # ext/ripper/*.c \ | |
| 29 | + # ext/ripper/lib/*.rb \ | |
| 30 | + # ext/ripper/lib/**/*.rb \ | |
| 31 | + # ext/socket/*.c \ | |
| 32 | + # ext/socket/lib/*.rb \ | |
| 33 | + # ext/socket/lib/**/*.rb \ | |
| 34 | + # ext/stringio/*.c \ | |
| 35 | + # ext/zlib/*.c | |
| 36 | + | |
| 37 | + self.version = '2.0.0' | |
| 38 | + self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby' | |
| 39 | + | |
| 40 | + html_filters.replace 'rdoc/entries', 'ruby/entries' | |
| 41 | + | |
| 42 | + options[:root_title] = 'Ruby Programming Language' | |
| 43 | + | |
| 44 | + options[:skip] += %w( | |
| 45 | + fatal.html | |
| 46 | + unknown.html | |
| 47 | + Data.html | |
| 48 | + E2MM.html | |
| 49 | + English.html | |
| 50 | + Exception2MessageMapper.html | |
| 51 | + GServer.html | |
| 52 | + MakeMakefile.html | |
| 53 | + ParallelEach.html | |
| 54 | + Requirement.html | |
| 55 | + YAML/DBM.html) | |
| 56 | + | |
| 57 | + options[:skip_patterns] = [ | |
| 58 | + /\AComplex/, | |
| 59 | + /\AGem/, | |
| 60 | + /\AHttpServer/, | |
| 61 | + /\AIRB/, | |
| 62 | + /\AMiniTest/i, | |
| 63 | + /\ANQXML/, | |
| 64 | + /\AOpenSSL/, | |
| 65 | + /\APride/, | |
| 66 | + /\ARacc/, | |
| 67 | + /\ARake/, | |
| 68 | + /\ARbConfig/, | |
| 69 | + /\ARDoc/, | |
| 70 | + /\AREXML/, | |
| 71 | + /\ARSS/, | |
| 72 | + /\ATest/, | |
| 73 | + /\AWEBrick/, | |
| 74 | + /\AXML/, | |
| 75 | + /\AXMP/ | |
| 76 | + ] | |
| 77 | + | |
| 78 | + options[:attribution] = <<-HTML | |
| 79 | + Ruby Core © 1993–2013 Yukihiro Matsumoto<br> | |
| 80 | + Licensed under the Ruby License.<br> | |
| 81 | + Ruby Standard Library © contributors<br> | |
| 82 | + Licensed under their own licenses. | |
| 83 | + HTML | |
| 84 | + end | |
| 85 | +end | |