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