From 38b16ed87a4220b202c6523ed88dd00868dbfb40 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 28 Dec 2014 18:33:07 -0500 Subject: [PATCH] Update and improve Ruby documentation (2.2.0) --- lib/docs/filters/ruby/entries.rb | 31 ++++++++++++++++ lib/docs/scrapers/rdoc/ruby.rb | 62 ++++++++++++++++---------------- 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/lib/docs/filters/ruby/entries.rb b/lib/docs/filters/ruby/entries.rb index 575330bb..23ea7765 100644 --- a/lib/docs/filters/ruby/entries.rb +++ b/lib/docs/filters/ruby/entries.rb @@ -17,6 +17,8 @@ module Docs 'Profiler__' => 'Profiler', 'Psych' => 'YAML', 'Rinda' => 'DRb', + 'SimpleDelegator' => 'Delegator', + 'SingleForwardable' => 'Forwardable', 'SortedSet' => 'Set', 'TCPServer' => 'Socket', 'TempIO' => 'Tempfile', @@ -35,6 +37,9 @@ module Docs 'Socket' => 'Socket' } def get_type + return 'Language' if guide? + return $1 if name =~ /\A(Net\:\:(?:FTP|HTTP|IMAP|SMTP))/ + type = super REPLACE_TYPE_STARTS_WITH.each_pair do |key, value| @@ -47,6 +52,32 @@ module Docs REPLACE_TYPE[type] || type end + + def additional_entries + return super unless guide? + + if slug == 'syntax/control_expressions_rdoc' || slug == 'syntax/miscellaneous_rdoc' + css('h2 > code').each_with_object([]) do |node, entries| + name = node.content.strip + entries << [name, node.parent['id'], 'Syntax'] unless entries.any? { |e| e[0] == name } + end + elsif slug == 'globals_rdoc' + css('dt').map do |node| + name = node['id'] = node.content.strip + [name, name, 'Globals'] + end + else + [] + end + end + + def include_default_entry? + guide? || super + end + + def guide? + slug =~ /[^\/]+_rdoc/ + end end end end diff --git a/lib/docs/scrapers/rdoc/ruby.rb b/lib/docs/scrapers/rdoc/ruby.rb index fb6d840c..64357d6e 100644 --- a/lib/docs/scrapers/rdoc/ruby.rb +++ b/lib/docs/scrapers/rdoc/ruby.rb @@ -1,59 +1,56 @@ module Docs class Ruby < Rdoc # Generated with: - # find \ - # *.c \ - # lib \ - # ext/bigdecimal \ - # ext/date \ - # ext/digest \ - # ext/json \ - # ext/pathname \ - # ext/psych \ - # ext/readline \ - # ext/ripper \ - # ext/socket \ - # ext/stringio \ - # ext/zlib \ - # \( -name '*.c' -or -name '*.rb' \) \ - # -not -wholename '*sample/*' \ - # | xargs \ - # rdoc --format=darkfish --no-line-numbers --op=rdoc --visibility=public + # rdoc \ + # --root . \ + # --page-dir doc \ + # --encoding=UTF-8 \ + # --visibility=public \ + # --format=darkfish \ + # --no-line-numbers \ + # --op html . - self.version = '2.1.3' + self.version = '2.2.0' self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby' html_filters.replace 'rdoc/entries', 'ruby/entries' options[:root_title] = 'Ruby Programming Language' + options[:title] = ->(filter) { filter.slug == 'globals_rdoc' ? 'Globals' : false } options[:skip] += %w( - fatal.html - CompositePublisher.html + contributing_rdoc.html + contributors_rdoc.html + dtrace_probes_rdoc.html + maintainers_rdoc.html + regexp_rdoc.html + standard_library_rdoc.html + syntax_rdoc.html Data.html - E2MM.html English.html - GServer.html - MakeMakefile.html - ParallelEach.html - SshDirPublisher.html - SshFilePublisher.html - SshFreshDirPublisher.html - YAML/DBM.html) + Fcntl.html + Kconv.html + NKF.html + OLEProperty.html + OptParse.html + UnicodeNormalize.html) - options[:skip_patterns] = [ - /\AComplex/, + options[:skip_patterns] += [ + /\Alib\//, + /\ADEBUGGER__/, /\AException2MessageMapper/, /\AJSON\/Ext/, /\AGem/, /\AHTTP/i, /\AIRB/, + /\AMakeMakefile/i, /\AMiniTest/i, - /\ANet\/(?!HTTP)/, /\ANQXML/, /\AOpenSSL/, /\AOptionParser\//, + /\APrettyPrint/, /\APride/, + /\AProfiler__/, /\APsych\//, /\ARacc/, /\ARake/, @@ -65,6 +62,7 @@ module Docs /\ASocket\//, /\ATest/, /\AWEBrick/, + /win32/i, /\AXML/, /\AXMP/]