From 2bd96af5c00eb8575ac29c28531d3156ec76e9fe Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sat, 28 Oct 2017 11:27:42 -0400 Subject: [PATCH] Add the Jekyll docs --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_jekyll.scss | 35 +++++++++++++++ lib/docs/filters/jekyll/clean_html.rb | 55 ++++++++++++++++++++++++ lib/docs/filters/jekyll/entries.rb | 29 +++++++++++++ lib/docs/scrapers/jekyll.rb | 34 +++++++++++++++ public/icons/docs/jekyll/16.png | Bin 0 -> 357 bytes public/icons/docs/jekyll/16@2x.png | Bin 0 -> 809 bytes public/icons/docs/jekyll/SOURCE | 1 + 8 files changed, 155 insertions(+) create mode 100644 assets/stylesheets/pages/_jekyll.scss create mode 100644 lib/docs/filters/jekyll/clean_html.rb create mode 100644 lib/docs/filters/jekyll/entries.rb create mode 100644 lib/docs/scrapers/jekyll.rb create mode 100644 public/icons/docs/jekyll/16.png create mode 100644 public/icons/docs/jekyll/16@2x.png create mode 100644 public/icons/docs/jekyll/SOURCE diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index e4314a0f..26e0b885 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -55,6 +55,7 @@ 'pages/github', 'pages/go', 'pages/haskell', + 'pages/jekyll', 'pages/jquery', 'pages/julia', 'pages/knockout', diff --git a/assets/stylesheets/pages/_jekyll.scss b/assets/stylesheets/pages/_jekyll.scss new file mode 100644 index 00000000..2a30051f --- /dev/null +++ b/assets/stylesheets/pages/_jekyll.scss @@ -0,0 +1,35 @@ +._jekyll { + h2, h3 { @extend %block-heading; } + + .note { + @extend %note; + + h5 { + margin-top: 0.25em; + } + + position: relative; + &::after { + content: attr(data-type); + opacity: 0.5; + text-transform: uppercase; + position: absolute; + top: 0.25em; + right: 0.5em; + font-size: 0.8em; + pointer-events: none; + } + + // Other note types currently unstyled: + // plain + // tip + // feature + &.note-info { @extend %note-blue; } + &.note-warning { @extend %note-red; } + &.note-unreleased { @extend %note-orange; } + } + + pre { + font-size: inherit; + } +} diff --git a/lib/docs/filters/jekyll/clean_html.rb b/lib/docs/filters/jekyll/clean_html.rb new file mode 100644 index 00000000..d27d0ea4 --- /dev/null +++ b/lib/docs/filters/jekyll/clean_html.rb @@ -0,0 +1,55 @@ +module Docs + class Jekyll + class CleanHtmlFilter < Filter + def call + css('.improve, .section-nav').each(&:remove) + + css('div.highlighter-rouge').each do |node| + pre = node.at_css('pre') + + # copy over the highlighting metadata + match = /language-(\w+)/.match(node['class']) + # HACK: Prism shell highlighting highlights `|`, + # which makes the tree on this page look terrible + if match && !(slug == /structure/ && match[1] == 'sh') + lang = match[1] + if lang == 'sh' + lang = 'bash' + elsif lang == 'liquid' + lang = 'django' # Close enough. + end + pre['class'] = nil + pre['data-language'] = lang + end + + # Remove the server-rendered syntax highlighting + code = pre.at_css('code') + code.content = code.text + + # Remove the div.highlighter-rouge and div.highlight wrapping the
+          node.add_next_sibling pre
+          node.remove
+        end
+
+        css('code').each do |node|
+          node['class'] = ''
+        end
+
+        css('.note').each do |node|
+          node_type = /note ?(\w+)?/.match(node['class'])[1] || 'tip'
+
+          # 
...
...
->
...
+ (node > 'br').each(&:remove) + #
...

...

...

...
-> + #
...

...
...

...
+ node.css('br + br').each(&:remove) + + node['class'] = "note note-#{node_type}" + node['data-type'] = node_type + end + + doc + end + end + end +end diff --git a/lib/docs/filters/jekyll/entries.rb b/lib/docs/filters/jekyll/entries.rb new file mode 100644 index 00000000..cf6b34b2 --- /dev/null +++ b/lib/docs/filters/jekyll/entries.rb @@ -0,0 +1,29 @@ +module Docs + class Jekyll + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('h1').content + end + + def get_type + if /continuous-integration/.match(slug) + 'Deployment' + else + nav_link = doc.document # document + .at_css('aside li.current') # item in navbar + + if nav_link + nav_link + .parent #