diff --git a/assets/javascripts/views/pages/crystal.coffee b/assets/javascripts/views/pages/crystal.coffee new file mode 100644 index 00000000..6c2b42bb --- /dev/null +++ b/assets/javascripts/views/pages/crystal.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.CrystalPage extends app.views.BasePage + prepare: -> + @highlightCode @findAllByTag('pre'), 'ruby' + return diff --git a/assets/stylesheets/pages/_crystal.scss b/assets/stylesheets/pages/_crystal.scss new file mode 100644 index 00000000..2518d1bb --- /dev/null +++ b/assets/stylesheets/pages/_crystal.scss @@ -0,0 +1,7 @@ +._crystal { + @extend %simple; + + blockquote { + @extend %note; + } +} diff --git a/lib/docs/filters/crystal/clean_html.rb b/lib/docs/filters/crystal/clean_html.rb new file mode 100644 index 00000000..f95aaef1 --- /dev/null +++ b/lib/docs/filters/crystal/clean_html.rb @@ -0,0 +1,20 @@ +module Docs + class Crystal + class CleanHtmlFilter < Filter + def call + + # Remove class attr from div and child nodes + css("div").each do |node| + node.xpath("//@class").remove + end + + # Set id attributes on

instead of an empty + css("h1").each do |node| + node["id"] = node.at_css("a")["id"] + end + + doc + end + end + end +end diff --git a/lib/docs/filters/crystal/entries.rb b/lib/docs/filters/crystal/entries.rb new file mode 100644 index 00000000..a0e36b0c --- /dev/null +++ b/lib/docs/filters/crystal/entries.rb @@ -0,0 +1,21 @@ +module Docs + class Crystal + class EntriesFilter < Docs::EntriesFilter + + # Set the name to h1 content + def get_name + node = at_css("h1") + node.content.strip + end + + # Crystal types from url slug + def get_type + slug["blob/master/"] = "" + object, method = *slug.split("/") + object = object.capitalize + method ? object : "Index" + end + + end + end +end diff --git a/lib/docs/scrapers/crystal.rb b/lib/docs/scrapers/crystal.rb new file mode 100644 index 00000000..b9093d77 --- /dev/null +++ b/lib/docs/scrapers/crystal.rb @@ -0,0 +1,22 @@ +module Docs + class Crystal < UrlScraper + self.name = "Crystal" + self.type = "crystal" + self.base_url = "https://github.com/crystal-lang/crystal-book" + self.initial_paths = %w(/blob/master/SUMMARY.md) + self.links = { + home: "https://crystal-lang.org/", + code: "https://github.com/crystal-lang/crystal" + } + + html_filters.push "crystal/clean_html", "crystal/entries" + + options[:container] = ".entry-content" + options[:only_patterns] = [/\/blob\/master\/.*\.md/] + options[:skip] = %w(/blob/master/README.md) + + options[:attribution] = <<-HTML + CC0 + HTML + end +end diff --git a/public/icons/docs/crystal/16.png b/public/icons/docs/crystal/16.png new file mode 100644 index 00000000..5064d31b Binary files /dev/null and b/public/icons/docs/crystal/16.png differ diff --git a/public/icons/docs/crystal/16@2x.png b/public/icons/docs/crystal/16@2x.png new file mode 100644 index 00000000..b62e6b03 Binary files /dev/null and b/public/icons/docs/crystal/16@2x.png differ diff --git a/public/icons/docs/crystal/SOURCE b/public/icons/docs/crystal/SOURCE new file mode 100644 index 00000000..aa9d98c4 --- /dev/null +++ b/public/icons/docs/crystal/SOURCE @@ -0,0 +1 @@ +https://crystal-lang.org/images/favico.ico