Add Crystal documentation

pull/447/merge
Faustino Aguilar 9 years ago committed by Thibaut Courouble
parent 96d50431bf
commit 0324bdca48

@ -0,0 +1,6 @@
#= require views/pages/base
class app.views.CrystalPage extends app.views.BasePage
prepare: ->
@highlightCode @findAllByTag('pre'), 'ruby'
return

@ -0,0 +1,7 @@
._crystal {
@extend %simple;
blockquote {
@extend %note;
}
}

@ -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 <h1> instead of an empty <a>
css("h1").each do |node|
node["id"] = node.at_css("a")["id"]
end
doc
end
end
end
end

@ -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

@ -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
<a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

@ -0,0 +1 @@
https://crystal-lang.org/images/favico.ico
Loading…
Cancel
Save