Skip to content

Commit eb30617

Browse files
committed
crystal: /docs -> /reference
1 parent 457924b commit eb30617

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

lib/docs/filters/crystal/clean_html.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ module Docs
22
class Crystal
33
class CleanHtmlFilter < Filter
44
def call
5-
slug.start_with?('docs') ? book : api
5+
slug.start_with?('reference') ? book : api
66
doc
77
end
88

99
def book
10-
@doc = at_css('.page-inner section')
10+
@doc = at_css('main article')
11+
12+
css('.headerlink').remove
1113

1214
css('pre > code').each do |node|
15+
node.parent['data-language'] = 'crystal'
1316
node.parent['data-language'] = node['class'][/lang-(\w+)/, 1] if node['class']
1417
node.parent.content = node.parent.content
1518
end

lib/docs/filters/crystal/entries.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ module Docs
22
class Crystal
33
class EntriesFilter < Docs::EntriesFilter
44
def get_name
5-
if slug.start_with?('docs/')
6-
name = at_css('.page-inner h1').content.strip
5+
if slug.start_with?('reference/')
6+
name = at_css('main h1').content.strip
7+
name.remove! '¶'
78

8-
if slug.start_with?('docs/syntax_and_semantics')
9+
if slug.start_with?('reference/syntax_and_semantics')
910
name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3
1011
elsif slug.split('/').length > 1
1112
chapter = slug.split('/')[1].titleize.capitalize
@@ -23,9 +24,9 @@ def get_name
2324
def get_type
2425
return if root_page?
2526

26-
if slug.start_with?('docs/syntax_and_semantics')
27+
if slug.start_with?('reference/syntax_and_semantics')
2728
'Book: Language'
28-
elsif slug.start_with?('docs/')
29+
elsif slug.start_with?('reference/')
2930
'Book'
3031
else
3132
hierarchy = at_css('.superclass-hierarchy')

lib/docs/scrapers/crystal.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Docs
22
class Crystal < UrlScraper
33
self.type = 'crystal'
44
self.base_url = 'https://crystal-lang.org/'
5-
self.initial_paths = %w(docs/index.html)
5+
self.initial_paths = %w(reference/index.html)
66
self.links = {
77
home: 'https://crystal-lang.org/',
88
code: 'https://github.com/crystal-lang/crystal'
@@ -11,7 +11,7 @@ class Crystal < UrlScraper
1111
html_filters.push 'crystal/entries', 'crystal/clean_html'
1212

1313
options[:attribution] = ->(filter) {
14-
if filter.slug.start_with?('docs')
14+
if filter.slug.start_with?('reference')
1515
<<-HTML
1616
To the extent possible under law, the persons who contributed to this work
1717
have waived<br>all copyright and related or neighboring rights to this work
@@ -29,12 +29,12 @@ class Crystal < UrlScraper
2929
self.release = '0.36.1'
3030
self.root_path = "api/#{release}/index.html"
3131

32-
options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//]
32+
options[:only_patterns] = [/\Aapi\/#{release}\//, /\Areference\//]
3333
options[:skip_patterns] = [/debug/i]
3434

3535
options[:replace_paths] = {
3636
"api/#{release}/" => "api/#{release}/index.html",
37-
'docs/' => 'docs/index.html'
37+
'reference/' => 'reference/index.html'
3838
}
3939
end
4040

0 commit comments

Comments
 (0)