[devdocsgjs/main: 102/239] Update Crystal documentation (1.3.0)
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 102/239] Update Crystal documentation (1.3.0)
- Date: Fri, 8 Apr 2022 07:47:36 +0000 (UTC)
commit 39a74e09ae5f19bd8dee5340caebf643664a680c
Author: Simon Legner <Simon Legner gmail com>
Date: Fri Jan 7 21:31:24 2022 +0100
Update Crystal documentation (1.3.0)
.../javascripts/templates/pages/about_tmpl.coffee | 2 +-
lib/docs/filters/crystal/clean_html.rb | 4 ++--
lib/docs/filters/crystal/entries.rb | 13 +++++-----
lib/docs/scrapers/crystal.rb | 28 ++++++++++------------
4 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee
b/assets/javascripts/templates/pages/about_tmpl.coffee
index f9925f53..4eaebe6c 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -204,7 +204,7 @@ credits = [
'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
], [
'Crystal',
- '2012-2021 Manas Technology Solutions',
+ '2012-2022 Manas Technology Solutions',
'Apache',
'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'
], [
diff --git a/lib/docs/filters/crystal/clean_html.rb b/lib/docs/filters/crystal/clean_html.rb
index 80284fc4..2d951f08 100644
--- a/lib/docs/filters/crystal/clean_html.rb
+++ b/lib/docs/filters/crystal/clean_html.rb
@@ -2,7 +2,7 @@ module Docs
class Crystal
class CleanHtmlFilter < Filter
def call
- slug.start_with?('reference') ? book : api
+ current_url.path.start_with?('/reference/') ? book : api
doc
end
@@ -21,7 +21,7 @@ module Docs
def api
@doc = at_css('.main-content')
- at_css('h1 + p').remove if root_page?
+ at_css('h1 + p').remove if current_url.path == "/api/#{release}/index.html"
css('.method-permalink', '.doc + br', 'hr', 'a > br', 'div + br').remove
diff --git a/lib/docs/filters/crystal/entries.rb b/lib/docs/filters/crystal/entries.rb
index f66ffa4a..3727bdf2 100644
--- a/lib/docs/filters/crystal/entries.rb
+++ b/lib/docs/filters/crystal/entries.rb
@@ -2,11 +2,11 @@ module Docs
class Crystal
class EntriesFilter < Docs::EntriesFilter
def get_name
- if slug.start_with?('reference/')
+ if current_url.path.start_with?('/reference/')
name = at_css('main h1').content.strip
name.remove! 'ΒΆ'
- if slug.start_with?('reference/syntax_and_semantics')
+ if current_url.path.start_with?('/reference/') && slug.match?('syntax_and_semantics')
name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3
elsif slug.split('/').length > 1
chapter = slug.split('/')[1].titleize.capitalize
@@ -15,6 +15,7 @@ module Docs
name
else
+ return at_css('h1').content.strip unless at_css('.type-name')
name = at_css('.type-name').children.last.content.strip
name.remove! %r{\(.*\)}
name
@@ -22,11 +23,11 @@ module Docs
end
def get_type
- return if root_page?
+ return if current_url.path == "/api/#{release}/index.html"
- if slug.start_with?('reference/syntax_and_semantics')
+ if current_url.path.start_with?('/reference/') && slug.match?('syntax_and_semantics')
'Book: Language'
- elsif slug.start_with?('reference/')
+ elsif current_url.path.start_with?('/reference/')
'Book'
else
hierarchy = at_css('.superclass-hierarchy')
@@ -44,7 +45,7 @@ module Docs
end
def additional_entries
- return [] unless slug.start_with?('api')
+ return [] unless current_url.path.start_with?('/api/')
entries = []
css('.entry-detail[id$="class-method"]').each do |node|
diff --git a/lib/docs/scrapers/crystal.rb b/lib/docs/scrapers/crystal.rb
index fa350b52..9efe5783 100644
--- a/lib/docs/scrapers/crystal.rb
+++ b/lib/docs/scrapers/crystal.rb
@@ -1,8 +1,17 @@
module Docs
class Crystal < UrlScraper
+ include MultipleBaseUrls
self.type = 'crystal'
- self.base_url = 'https://crystal-lang.org/'
- self.initial_paths = %w(reference/index.html)
+ self.release = '1.3.0'
+ self.base_urls = [
+ "https://crystal-lang.org/api/#{release}/",
+ "https://crystal-lang.org/reference/#{release[0..2]}/",
+ ]
+ def initial_urls
+ [ "https://crystal-lang.org/api/#{self.class.release}/index.html",
+ "https://crystal-lang.org/reference/#{self.class.release[0..2]}/index.html" ]
+ end
+
self.links = {
home: 'https://crystal-lang.org/',
code: 'https://github.com/crystal-lang/crystal'
@@ -11,7 +20,7 @@ module Docs
html_filters.push 'crystal/entries', 'crystal/clean_html'
options[:attribution] = ->(filter) {
- if filter.slug.start_with?('reference')
+ if filter.current_url.path.start_with?('/reference/')
<<-HTML
To the extent possible under law, the persons who contributed to this work
have waived<br>all copyright and related or neighboring rights to this work
@@ -19,23 +28,12 @@ module Docs
HTML
else
<<-HTML
- © 2012–2021 Manas Technology Solutions.<br>
+ © 2012–2022 Manas Technology Solutions.<br>
Licensed under the Apache License, Version 2.0.
HTML
end
}
- self.release = '1.2.1'
- self.root_path = "api/#{release}/index.html"
-
- options[:only_patterns] = [/\Aapi\/#{release}\//, /\Areference\//]
- options[:skip_patterns] = [/debug/i]
-
- options[:replace_paths] = {
- "api/#{release}/" => "api/#{release}/index.html",
- 'reference/' => 'reference/index.html'
- }
-
def get_latest_version(opts)
doc = fetch_doc('https://crystal-lang.org/', opts)
doc.at_css('.latest-release').content.scan(/([0-9.]+)/)[0][0]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]