Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move rails from FileScraper to URLscraper [initial steps]
  • Loading branch information
MasterEnoc committed Jun 19, 2021
commit 6d6805972b34b28a2c2ff595b75d9362cfc1add7
2 changes: 1 addition & 1 deletion assets/javascripts/templates/pages/about_tmpl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ credits = [
'https://www.ruby-lang.org/en/about/license.txt'
], [
'Ruby on Rails',
'2004-2020 David Heinemeier Hansson<br>Rails, Ruby on Rails, and the Rails logo are trademarks of David Heinemeier Hansson.',
'2004-2021 David Heinemeier Hansson<br>Rails, Ruby on Rails, and the Rails logo are trademarks of David Heinemeier Hansson.',
'MIT',
'https://raw.githubusercontent.com/rails/rails/master/activerecord/MIT-LICENSE'
], [
Expand Down
2 changes: 1 addition & 1 deletion lib/docs/filters/rails/clean_html_guides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Docs
class Rails
class CleanHtmlGuidesFilter < Filter
def call
return doc unless slug.start_with?('guides')
return doc unless root_url.to_s.match?('guides')

at_css('#mainCol').prepend_child at_css('#feature .wrapper').children
@doc = at_css('#mainCol')
Expand Down
8 changes: 4 additions & 4 deletions lib/docs/filters/rails/entries.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Docs
class Rails
class EntriesFilter < Docs::Rdoc::EntriesFilter
class EntriesFilter < Docs::EntriesFilter# Docs::Rdoc::EntriesFilter
TYPE_BY_NAME_MATCHES = {
/Assertions|::Test|Fixture/ => 'Testing',
/\AActiveRecord.+mysql/i => 'ActiveRecord/MySQL',
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_name
end

def get_type
return 'Guides' if slug.start_with?('guides')
return 'Guides' if root_url.to_s.match?('guides')

parent = at_css('.meta-parent').try(:content).to_s

Expand All @@ -69,13 +69,13 @@ def get_type
end

def include_default_entry?
return true if slug.start_with?('guides')
return true if root_url.to_s.match?('guides')

super && !skip?
end

def additional_entries
return [] if slug.start_with?('guides')
return [] if root_url.to_s.match?('guides')

skip? ? [] : super
end
Expand Down
128 changes: 128 additions & 0 deletions lib/docs/scrapers/rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
module Docs
class Rails < UrlScraper
# include FixInternalUrlsBehavior
include MultipleBaseUrls

self.name = 'Ruby on Rails'
self.type = 'rdoc'
self.slug = 'rails'

self.links = {
home: 'http://rubyonrails.org/',
code: 'https://github.com/rails/rails'
}

# html_filters.replace 'container', 'rails/container'
html_filters.push 'rails/entries', 'rdoc/clean_html', 'rails/clean_html_guides'

options[:skip_rdoc_filters?] = ->(filter) { filter.root_url.to_s.match?('guides/') }

options[:root_title] = 'Ruby on Rails'

options[:skip] = [
'links.html',
'index.html',
'credits.html',
'ruby_on_rails_guides_guidelines.html',
'contributing_to_ruby_on_rails.html',
'development_dependencies_install.html',
'api_documentation_guidelines.html',
'ActionController/Instrumentation.html',
'ActionController/Rendering.html',
'ActionDispatch/DebugExceptions.html',
'ActionDispatch/Journey/Parser.html',
'ActionDispatch/Reloader.html',
'ActionDispatch/Routing/HtmlTableFormatter.html',
'ActionDispatch/ShowExceptions.html',
'ActionView/FixtureResolver.html',
'ActionView/LogSubscriber.html',
'ActionView/TestCase/Behavior/RenderedViewsCollection.html',
'ActiveRecord/Tasks/DatabaseTasks.html',
'ActiveSupport/Dependencies/WatchStack.html',
'ActiveSupport/Notifications/Fanout.html',
'ActionDispatch/www.example.com',
'ActionDispatch/Http/www.rubyonrails.org',
'ActionDispatch/Http/www.rubyonrails.co.uk',
'\'TZ\'',
'active_record_migrations.html',
'association_basics.html'
]

options[:skip_patterns] = [
/history/i,
/rakefile/i,
/changelog/i,
/readme/i,
/news/i,
/license/i,
/release_notes/,
/\AActionController\/Testing/,
/\AActionView\/LookupContext/,
/\AActionView\/Resolver/,
/\AActiveSupport\/Multibyte\/Unicode\//,
/\AActiveSupport\/XML/i,
/\ASourceAnnotationExtractor/,
/\AI18n\/Railtie/,
/\AMinitest/,
/\ARails\/API/,
/\ARails\/AppBuilder/,
/\ARails\/PluginBuilder/,
/\ARails\/Generators\/Testing/
]

options[:attribution] = ->(filter) do
if filter.slug.start_with?('guides')
<<-HTML
&copy; 2004&ndash;2021 David Heinemeier Hansson<br>
Licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
HTML
else
<<-HTML
&copy; 2004&ndash;2021 David Heinemeier Hansson<br>
Licensed under the MIT License.
HTML
end
end

version '6.1' do
self.release = '6.1.3.2'

self.base_urls = [
'https://api.rubyonrails.org/',
'https://guides.rubyonrails.org/'
]

options[:skip_patterns] << /v.*\..*\//
end

version '6.0' do
self.release = '6.0.0'
end

version '5.2' do
self.release = '5.2.2'
end

version '5.1' do
self.release = '5.1.6'
end

version '5.0' do
self.release = '5.0.7'
end

version '4.2' do
self.release = '4.2.11'
end

version '4.1' do
self.release = '4.1.16'
end

def get_latest_version(opts)
doc = fetch_doc('https://rubyonrails.org/', opts)
doc.at_css('.version p a').content.scan(/\d\.\d*\.*\d*\.*\d*/)[0]
end

end
end
119 changes: 0 additions & 119 deletions lib/docs/scrapers/rdoc/rails.rb

This file was deleted.