diff --git a/assets/images/icons.png b/assets/images/icons.png index 9820d340..65e2a3de 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index c66c176a..cd7f1986 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 58eaf1cb..ccb433d3 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -138,6 +138,11 @@ credits = [ '1997-2013 The PHP Documentation Group', 'CC BY', 'http://creativecommons.org/licenses/by/3.0/' + ], [ + 'Ruby', + '1993-2013 Yukihiro Matsumoto', + 'Ruby', + 'https://www.ruby-lang.org/en/about/license.txt' ], [ 'Sass', '2006-2013 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein', diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee b/assets/javascripts/templates/pages/news_tmpl.coffee index 7a0f63c2..2a7a508b 100644 --- a/assets/javascripts/templates/pages/news_tmpl.coffee +++ b/assets/javascripts/templates/pages/news_tmpl.coffee @@ -24,7 +24,10 @@ newsItem = (date, news) -> result app.news = [ - [ 1382572800000, # October 24, 2013 + [ 1384560000000, # November 16, 2013 + """ New Ruby documentation """ + ], [ + 1382572800000, # October 24, 2013 """ DevDocs is now open source. """ ], [ 1381276800000, # October 9, 2013 diff --git a/assets/javascripts/views/pages/rdoc.coffee b/assets/javascripts/views/pages/rdoc.coffee new file mode 100644 index 00000000..55059d9e --- /dev/null +++ b/assets/javascripts/views/pages/rdoc.coffee @@ -0,0 +1,20 @@ +#= require views/pages/base + +class app.views.RdocPage extends app.views.BasePage + @events: + click: 'onClick' + + afterRender: -> + @highlightCode @findAll('pre.ruby'), 'ruby' + @highlightCode @findAll('pre.c'), 'clike' + return + + onClick: (event) -> + return unless event.target.classList.contains 'method-click-advice' + $.stopEvent(event) + + source = $ '.method-source-code', event.target.parentNode.parentNode + isShown = source.style.display is 'block' + + source.style.display = if isShown then 'none' else 'block' + event.target.textContent = if isShown then 'Show source' else 'Hide source' diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index ecc1e02c..f1c0641b 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -36,6 +36,7 @@ 'pages/mdn', 'pages/node', 'pages/php', + 'pages/rdoc', 'pages/rfc', 'pages/underscore', 'pages/yard'; diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index b2417253..fb6b50e5 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -39,3 +39,4 @@ ._icon-jquerymobile:before { background-position: 0 -5rem; } ._icon-lodash:before { background-position: -1rem -5rem; } ._icon-php:before { background-position: -2rem -5rem; } +._icon-ruby:before { background-position: -3rem -5rem; } diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss new file mode 100644 index 00000000..572a28dc --- /dev/null +++ b/assets/stylesheets/pages/_rdoc.scss @@ -0,0 +1,46 @@ +._rdoc { + > .description, > .documentation-section { padding-left: 1rem; } + > .description > h2, .section-header { @extend %block-heading; } + > .description > h2, .section-header, .method-heading { margin-left: -1rem; } + .description > h1 { font-size: 1rem; } + .method-description > h2, h3, h4 { font-size: 1em; } + + .method-heading { + font-weight: bold; + @extend %block-label, %label-blue; + + + .method-heading { margin-top: -.5em; } + } + + > .meta { + @extend %note, %note-blue; + + > dd { margin: 0; } + > dd + dt { margin-top: .5em; } + } + + a.method-click-advice { + float: right; + font-size: .75rem; + color: $linkColor; + cursor: pointer; + @extend %user-select-none; + + &:hover { text-decoration: underline; } + } + + .method-description { position: relative; } + + .method-source-code { + display: none; + position: absolute; + z-index: 1; + top: 0; + left: -1em; + right: 0; + background: rgba(white, .95); + box-shadow: 0 1em 1em 1em white; + + > pre { margin: 0; } + } +} diff --git a/lib/docs/filters/rdoc/clean_html.rb b/lib/docs/filters/rdoc/clean_html.rb new file mode 100644 index 00000000..9928d31b --- /dev/null +++ b/lib/docs/filters/rdoc/clean_html.rb @@ -0,0 +1,49 @@ +module Docs + class Rdoc + class CleanHtmlFilter < Filter + def call + root_page? ? root : other + doc + end + + def root + at_css('.section-header').remove + + # Remove skipped items + css('li > span').each do |node| + node.parent.remove + end + end + + def other + css('hr').remove + + # Remove paragraph/up links + css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span').remove + + # Move id attributes to headings + css('.method-detail').each do |node| + next unless heading = node.at_css('.method-heading') + heading['id'] = node['id'] + node.remove_attribute 'id' + end + + # Convert "click to toggle source" into a link + css('.method-click-advice').each do |node| + node.name = 'a' + node.content = 'Show source' + end + + # Add class to differentiate Ruby code from C code + css('.method-source-code > pre').each do |node| + node['class'] = node.at_css('.ruby-keyword') ? 'ruby' : 'c' + end + + # Remove code highlighting + css('pre').each do |node| + node.content = node.content + end + end + end + end +end diff --git a/lib/docs/filters/rdoc/container.rb b/lib/docs/filters/rdoc/container.rb new file mode 100644 index 00000000..be7816fe --- /dev/null +++ b/lib/docs/filters/rdoc/container.rb @@ -0,0 +1,26 @@ +module Docs + class Rdoc + class ContainerFilter < Filter + def call + if root_page? + at_css '#classindex-section' + else + container = at_css '#documentation' + + # Add
mentioning parent class and included modules + meta = Nokogiri::XML::Node.new 'dl', doc + meta['class'] = 'meta' + if parent = at_css('#parent-class-section') + meta << %(
Parent:
#{parent.at_css('.link').inner_html}
) + end + if includes = at_css('#includes-section') + meta << %(
Included modules:
#{includes.css('a').map(&:to_html).join(', ')}
) + end + container.at_css('h1').after(meta) + + container + end + end + end + end +end diff --git a/lib/docs/filters/rdoc/entries.rb b/lib/docs/filters/rdoc/entries.rb new file mode 100644 index 00000000..9ba187df --- /dev/null +++ b/lib/docs/filters/rdoc/entries.rb @@ -0,0 +1,38 @@ +module Docs + class Rdoc + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content.strip + name.sub! 'class ', '' + name.sub! 'module ', '' + name + end + + def get_type + type = name.dup + + unless type.sub! %r{::.*\z}, '' + parent = at_css('.meta-parent').try(:content).to_s.strip + return 'Errors' if type.end_with?('Error') || parent.end_with?('Error') || parent.end_with?('Exception') + end + + type + end + + def additional_entries + return [] if root_page? + require 'cgi' + + css('.method-detail').map do |node| + name = node['id'].dup + name.sub! %r{\A\w+?\-.}, '' + name.sub! %r{\A-(?!\d)}, '' + name.gsub! '-', '%' + name = CGI.unescape(name) + name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#') + [name, node['id']] + end + end + end + end +end diff --git a/lib/docs/filters/ruby/entries.rb b/lib/docs/filters/ruby/entries.rb new file mode 100644 index 00000000..575330bb --- /dev/null +++ b/lib/docs/filters/ruby/entries.rb @@ -0,0 +1,52 @@ +module Docs + class Ruby + class EntriesFilter < Docs::Rdoc::EntriesFilter + REPLACE_TYPE = { + 'ACL' => 'DRb', + 'Addrinfo' => 'Socket', + 'BigMath' => 'BigDecimal', + 'CMath' => 'Math', + 'ConditionVariable' => 'Mutex', + 'DEBUGGER__' => 'Debug', + 'Errno' => 'Errors', + 'FileTest' => 'File', + 'Jacobian' => 'BigDecimal', + 'LUSolve' => 'BigDecimal', + 'Newton' => 'BigDecimal', + 'PP' => 'PrettyPrint', + 'Profiler__' => 'Profiler', + 'Psych' => 'YAML', + 'Rinda' => 'DRb', + 'SortedSet' => 'Set', + 'TCPServer' => 'Socket', + 'TempIO' => 'Tempfile', + 'ThWait' => 'Thread', + 'UNIXServer' => 'Socket' } + + REPLACE_TYPE_STARTS_WITH = { + 'Monitor' => 'Monitor', + 'Mutex' => 'Mutex', + 'Shell' => 'Shell', + 'Sync' => 'Sync', + 'Thread' => 'Thread' } + + REPLACE_TYPE_ENDS_WITH = { + 'Queue' => 'Queue', + 'Socket' => 'Socket' } + + def get_type + type = super + + REPLACE_TYPE_STARTS_WITH.each_pair do |key, value| + return value if type.start_with?(key) + end + + REPLACE_TYPE_ENDS_WITH.each_pair do |key, value| + return value if type.end_with?(key) + end + + REPLACE_TYPE[type] || type + end + end + end +end diff --git a/lib/docs/scrapers/rdoc/rdoc.rb b/lib/docs/scrapers/rdoc/rdoc.rb new file mode 100644 index 00000000..d653180b --- /dev/null +++ b/lib/docs/scrapers/rdoc/rdoc.rb @@ -0,0 +1,13 @@ +module Docs + class Rdoc < FileScraper + self.abstract = true + self.type = 'rdoc' + self.root_path = 'index.html' + + html_filters.replace 'container', 'rdoc/container' + html_filters.push 'rdoc/entries', 'rdoc/clean_html', 'title' + + options[:title] = false + options[:skip] = %w(table_of_contents.html) + end +end diff --git a/lib/docs/scrapers/rdoc/ruby.rb b/lib/docs/scrapers/rdoc/ruby.rb new file mode 100644 index 00000000..94cb1aad --- /dev/null +++ b/lib/docs/scrapers/rdoc/ruby.rb @@ -0,0 +1,85 @@ +module Docs + class Ruby < Rdoc + # Generated with: + # rdoc \ + # --format=darkfish \ + # --no-line-numbers \ + # --op=rdoc \ + # --visibility=public \ + # *.c \ + # lib/**/*.rb \ + # lib/*.rb \ + # ext/bigdecimal/*.c \ + # ext/bigdecimal/lib/*.rb \ + # ext/bigdecimal/lib/**/*.rb \ + # ext/date/*.c \ + # ext/date/lib/*.rb \ + # ext/date/lib/**/*.rb \ + # ext/digest/*.c \ + # ext/digest/**/*.c \ + # ext/digest/**/*.rb \ + # ext/json/lib/**/*.rb \ + # ext/pathname/*.c \ + # ext/pathname/lib/*.rb \ + # ext/psych/*.c \ + # ext/psych/lib/*.rb \ + # ext/psych/lib/**/*.rb \ + # ext/readline/*.c \ + # ext/ripper/*.c \ + # ext/ripper/lib/*.rb \ + # ext/ripper/lib/**/*.rb \ + # ext/socket/*.c \ + # ext/socket/lib/*.rb \ + # ext/socket/lib/**/*.rb \ + # ext/stringio/*.c \ + # ext/zlib/*.c + + self.version = '2.0.0' + self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby' + + html_filters.replace 'rdoc/entries', 'ruby/entries' + + options[:root_title] = 'Ruby Programming Language' + + options[:skip] += %w( + fatal.html + unknown.html + Data.html + E2MM.html + English.html + Exception2MessageMapper.html + GServer.html + MakeMakefile.html + ParallelEach.html + Requirement.html + YAML/DBM.html) + + options[:skip_patterns] = [ + /\AComplex/, + /\AGem/, + /\AHttpServer/, + /\AIRB/, + /\AMiniTest/i, + /\ANQXML/, + /\AOpenSSL/, + /\APride/, + /\ARacc/, + /\ARake/, + /\ARbConfig/, + /\ARDoc/, + /\AREXML/, + /\ARSS/, + /\ATest/, + /\AWEBrick/, + /\AXML/, + /\AXMP/ + ] + + options[:attribution] = <<-HTML + Ruby Core © 1993–2013 Yukihiro Matsumoto
+ Licensed under the Ruby License.
+ Ruby Standard Library © contributors
+ Licensed under their own licenses. + HTML + end +end diff --git a/public/icons/docs/ruby/16.png b/public/icons/docs/ruby/16.png new file mode 100644 index 00000000..ec47283a Binary files /dev/null and b/public/icons/docs/ruby/16.png differ diff --git a/public/icons/docs/ruby/16@2x.png b/public/icons/docs/ruby/16@2x.png new file mode 100644 index 00000000..ab1e4945 Binary files /dev/null and b/public/icons/docs/ruby/16@2x.png differ diff --git a/public/icons/docs/ruby/SOURCE b/public/icons/docs/ruby/SOURCE new file mode 100644 index 00000000..d1822cdc --- /dev/null +++ b/public/icons/docs/ruby/SOURCE @@ -0,0 +1 @@ +http://commons.wikimedia.org/wiki/File:Ruby_logo.svg