History

crystal: /docs -> /reference

Simon Legner committed 5 years ago

Commit eb306171 parent 457924b3 files · +15 −11Browse files

Unified · Split

3 files
  1. lib/docs/filters/crystal/clean_html.rb +5 −2
  2. lib/docs/filters/crystal/entries.rb +6 −5
  3. lib/docs/scrapers/crystal.rb +4 −4
lib/docs/filters/crystal/clean_html.rb+5−2
@@ -2,14 +2,17 @@ module Docs · 1 unmodified line
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+6−5
@@ -2,10 +2,11 @@ module Docs · 1 unmodified line
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 @@ module Docs · 11 unmodified lines
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+4−4
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
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 @@ module Docs · 2 unmodified lines
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 @@ module Docs · 11 unmodified lines
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