diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss index 46723d6b..7fc9adda 100644 --- a/assets/stylesheets/pages/_rdoc.scss +++ b/assets/stylesheets/pages/_rdoc.scss @@ -43,4 +43,9 @@ > pre { margin: 0; } } + + // Rails guides + .note { @extend %note; } + .info { @extend %note, %note-blue; } + .warning { @extend %note, %note-red; } } diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index f2b9b733..fe36579d 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -41,6 +41,7 @@ ._nim, ._redux, ._requirejs, +._simple, ._typescript, ._vagrant, ._vulkan, diff --git a/lib/docs/filters/rails/clean_html_guides.rb b/lib/docs/filters/rails/clean_html_guides.rb new file mode 100644 index 00000000..8463fe9d --- /dev/null +++ b/lib/docs/filters/rails/clean_html_guides.rb @@ -0,0 +1,36 @@ +module Docs + class Rails + class CleanHtmlGuidesFilter < Filter + def call + return doc unless slug.start_with?('guides') + + at_css('#mainCol').prepend_child at_css('#feature .wrapper').children + @doc = at_css('#mainCol') + + container = Nokogiri::XML::Node.new 'div', doc + container['class'] = '_simple' + container.children = doc.children + doc << container + + css('h2, h3, h4, h5, h6').each do |node| + node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } + end + + doc.prepend_child at_css('h1') + + css('#subCol', '.code_container').each do |node| + node.before(node.children).remove + end + + css('pre').each do |node| + language = node['class'][/brush: ?(\w+)/, 1] + node['data-language'] = language unless language == 'plain' + node.remove_attribute('class') + node.content = node.content.strip + end + + doc + end + end + end +end diff --git a/lib/docs/filters/rails/entries.rb b/lib/docs/filters/rails/entries.rb index fbb8a535..0b29a4af 100644 --- a/lib/docs/filters/rails/entries.rb +++ b/lib/docs/filters/rails/entries.rb @@ -38,7 +38,19 @@ module Docs 'Rails::Generators' => 'Rails/Generators', 'Rails::Railtie' => 'Rails/Railtie' } + def get_name + if slug.start_with?('guides') + name = at_css('#feature h2').content.strip + name.remove! %r{\s\(.+\)\z} + return name + end + + super + end + def get_type + return 'Guides' if slug.start_with?('guides') + parent = at_css('.meta-parent').try(:content).to_s if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') } @@ -57,10 +69,14 @@ module Docs end def include_default_entry? + return true if slug.start_with?('guides') + super && !skip? end def additional_entries + return [] if slug.start_with?('guides') + skip? ? [] : super end diff --git a/lib/docs/filters/rdoc/clean_html.rb b/lib/docs/filters/rdoc/clean_html.rb index 642aaf92..7c06f324 100644 --- a/lib/docs/filters/rdoc/clean_html.rb +++ b/lib/docs/filters/rdoc/clean_html.rb @@ -2,6 +2,8 @@ module Docs class Rdoc class CleanHtmlFilter < Filter def call + return doc if context[:skip_rdoc_filters?].try(:call, self) + root_page? ? root : other doc end diff --git a/lib/docs/filters/rdoc/container.rb b/lib/docs/filters/rdoc/container.rb index fb6d3d2e..e7211fc6 100644 --- a/lib/docs/filters/rdoc/container.rb +++ b/lib/docs/filters/rdoc/container.rb @@ -2,6 +2,8 @@ module Docs class Rdoc class ContainerFilter < Filter def call + return doc if context[:skip_rdoc_filters?].try(:call, self) + if root_page? at_css 'main' else diff --git a/lib/docs/scrapers/rdoc/rails.rb b/lib/docs/scrapers/rdoc/rails.rb index e707588f..b987f8b1 100644 --- a/lib/docs/scrapers/rdoc/rails.rb +++ b/lib/docs/scrapers/rdoc/rails.rb @@ -5,16 +5,25 @@ module Docs self.name = 'Ruby on Rails' self.slug = 'rails' self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Rails' + self.initial_paths = %w(guides/index.html) self.links = { home: 'http://rubyonrails.org/', code: 'https://github.com/rails/rails' } html_filters.replace 'rdoc/entries', 'rails/entries' + html_filters.push 'rails/clean_html_guides' + + options[:skip_rdoc_filters?] = ->(filter) { filter.slug.start_with?('guides/') } options[:root_title] = 'Ruby on Rails' options[:skip] += %w( + guides/credits.html + guides/ruby_on_rails_guides_guidelines.html + guides/contributing_to_ruby_on_rails.html + guides/development_dependencies_install.html + guides/api_documentation_guidelines.html ActionController/Instrumentation.html ActionController/Rendering.html ActionDispatch/DebugExceptions.html @@ -30,6 +39,7 @@ module Docs ActiveSupport/Notifications/Fanout.html) options[:skip_patterns] += [ + /release_notes/, /\AActionController\/Testing/, /\AActionView\/LookupContext/, /\AActionView\/Resolver/, @@ -43,21 +53,30 @@ module Docs /\ARails\/PluginBuilder/, /\ARails\/Generators\/Testing/] - options[:attribution] = <<-HTML - © 2004–2017 David Heinemeier Hansson
- Licensed under the MIT License. - HTML + options[:attribution] = ->(filter) do + if filter.slug.start_with?('guides') + <<-HTML + © 2004–2017 David Heinemeier Hansson
+ Licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. + HTML + else + <<-HTML + © 2004–2017 David Heinemeier Hansson
+ Licensed under the MIT License. + HTML + end + end version '5.1' do - self.release = '5.1.0' + self.release = '5.1.4' end version '5.0' do - self.release = '5.0.2' + self.release = '5.0.6' end version '4.2' do - self.release = '4.2.8' + self.release = '4.2.10' end version '4.1' do