Update and improve Rails documentation

pull/667/merge
Thibaut Courouble 7 years ago
parent 712c55cd8c
commit 4390a91573

@ -43,4 +43,9 @@
> pre { margin: 0; } > pre { margin: 0; }
} }
// Rails guides
.note { @extend %note; }
.info { @extend %note, %note-blue; }
.warning { @extend %note, %note-red; }
} }

@ -41,6 +41,7 @@
._nim, ._nim,
._redux, ._redux,
._requirejs, ._requirejs,
._simple,
._typescript, ._typescript,
._vagrant, ._vagrant,
._vulkan, ._vulkan,

@ -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

@ -38,7 +38,19 @@ module Docs
'Rails::Generators' => 'Rails/Generators', 'Rails::Generators' => 'Rails/Generators',
'Rails::Railtie' => 'Rails/Railtie' } '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 def get_type
return 'Guides' if slug.start_with?('guides')
parent = at_css('.meta-parent').try(:content).to_s parent = at_css('.meta-parent').try(:content).to_s
if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') } if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') }
@ -57,10 +69,14 @@ module Docs
end end
def include_default_entry? def include_default_entry?
return true if slug.start_with?('guides')
super && !skip? super && !skip?
end end
def additional_entries def additional_entries
return [] if slug.start_with?('guides')
skip? ? [] : super skip? ? [] : super
end end

@ -2,6 +2,8 @@ module Docs
class Rdoc class Rdoc
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
return doc if context[:skip_rdoc_filters?].try(:call, self)
root_page? ? root : other root_page? ? root : other
doc doc
end end

@ -2,6 +2,8 @@ module Docs
class Rdoc class Rdoc
class ContainerFilter < Filter class ContainerFilter < Filter
def call def call
return doc if context[:skip_rdoc_filters?].try(:call, self)
if root_page? if root_page?
at_css 'main' at_css 'main'
else else

@ -5,16 +5,25 @@ module Docs
self.name = 'Ruby on Rails' self.name = 'Ruby on Rails'
self.slug = 'rails' self.slug = 'rails'
self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Rails' self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Rails'
self.initial_paths = %w(guides/index.html)
self.links = { self.links = {
home: 'http://rubyonrails.org/', home: 'http://rubyonrails.org/',
code: 'https://github.com/rails/rails' code: 'https://github.com/rails/rails'
} }
html_filters.replace 'rdoc/entries', 'rails/entries' 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[:root_title] = 'Ruby on Rails'
options[:skip] += %w( 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/Instrumentation.html
ActionController/Rendering.html ActionController/Rendering.html
ActionDispatch/DebugExceptions.html ActionDispatch/DebugExceptions.html
@ -30,6 +39,7 @@ module Docs
ActiveSupport/Notifications/Fanout.html) ActiveSupport/Notifications/Fanout.html)
options[:skip_patterns] += [ options[:skip_patterns] += [
/release_notes/,
/\AActionController\/Testing/, /\AActionController\/Testing/,
/\AActionView\/LookupContext/, /\AActionView\/LookupContext/,
/\AActionView\/Resolver/, /\AActionView\/Resolver/,
@ -43,21 +53,30 @@ module Docs
/\ARails\/PluginBuilder/, /\ARails\/PluginBuilder/,
/\ARails\/Generators\/Testing/] /\ARails\/Generators\/Testing/]
options[:attribution] = <<-HTML options[:attribution] = ->(filter) do
&copy; 2004&ndash;2017 David Heinemeier Hansson<br> if filter.slug.start_with?('guides')
Licensed under the MIT License. <<-HTML
HTML &copy; 2004&ndash;2017 David Heinemeier Hansson<br>
Licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
HTML
else
<<-HTML
&copy; 2004&ndash;2017 David Heinemeier Hansson<br>
Licensed under the MIT License.
HTML
end
end
version '5.1' do version '5.1' do
self.release = '5.1.0' self.release = '5.1.4'
end end
version '5.0' do version '5.0' do
self.release = '5.0.2' self.release = '5.0.6'
end end
version '4.2' do version '4.2' do
self.release = '4.2.8' self.release = '4.2.10'
end end
version '4.1' do version '4.1' do

Loading…
Cancel
Save