From dcbe81cd99a87b2cd5dc10871703c5100be09dba Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Wed, 28 Aug 2019 23:56:17 +0200 Subject: [PATCH] reactivex: process review comments --- assets/stylesheets/pages/_reactivex.scss | 40 ++++++++++++++++++++++++ lib/docs/filters/reactivex/clean_html.rb | 35 +++++++++++++++++++-- lib/docs/filters/reactivex/entries.rb | 9 +++++- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/assets/stylesheets/pages/_reactivex.scss b/assets/stylesheets/pages/_reactivex.scss index f544865d..2192a254 100644 --- a/assets/stylesheets/pages/_reactivex.scss +++ b/assets/stylesheets/pages/_reactivex.scss @@ -8,4 +8,44 @@ figure { margin: 0; } + + dfn { + cursor: text; + font-style: italic; + text-decoration: none; + border-bottom: none; + } + + #tree { + dt, dd { + font-weight: normal; + } + + dt { + float: left; + clear: left; + + margin-top: 0; + + &:before { + content: "…"; + } + } + + dd:not(.sub) { + float: left; + + margin: 0 0 0 5px; + padding: 0; + } + + dl#outer > dt { + font-weight: bold; + margin-top: 5px; + + & + dd { + margin-top: 5px; + } + } + } } diff --git a/lib/docs/filters/reactivex/clean_html.rb b/lib/docs/filters/reactivex/clean_html.rb index 2338bb5c..e8a209af 100644 --- a/lib/docs/filters/reactivex/clean_html.rb +++ b/lib/docs/filters/reactivex/clean_html.rb @@ -8,6 +8,36 @@ module Docs # Remove breadcrumbs css('.breadcrumb').remove + # Titleize title on Backpressure Operators page + if subpath == 'documentation/operators/backpressure.html' + title = at_css('h1') + title.content = title.content.titleize + end + + # Lower all h1 headers except the first one + css('* + h1').each do |node| + node.name = 'h2' + end + + # Pull code blocks in links out of their parent (if possible) + css('a > strong > code').each do |node| + # Skip if the parent had multiple code nodes and node.parent.replace already ran for one + next unless node.parent.name == 'strong' + + node.parent.replace node.parent.children + end + + # Pull header out of trees + tree = at_css('#tree') + unless tree.nil? + title = tree.at_css('h1') + title.name = 'h2' + tree.before(title) + end + + # Beautify operator descriptions + at_css('h3').name = 'blockquote' if subpath.include?('operators/') + # Replace interactive demo's with links to them css('rx-marbles').each do |node| node.name = 'a' @@ -37,8 +67,9 @@ module Docs # Make language specific implementation titles prettier css('.panel-title').each do |node| - # Remove the link, keep the text - node.content = node.content + # Remove the link, keep the children + link = node.at_css('a') + link.replace(link.children) unless link.nil? # Transform it into a header for better styling node.name = 'h3' diff --git a/lib/docs/filters/reactivex/entries.rb b/lib/docs/filters/reactivex/entries.rb index d238ffb4..4a6b08e9 100644 --- a/lib/docs/filters/reactivex/entries.rb +++ b/lib/docs/filters/reactivex/entries.rb @@ -2,13 +2,20 @@ module Docs class Reactivex class EntriesFilter < Docs::EntriesFilter def get_name - at_css('h1').content + title = at_css('h1').content + title = title.titleize if is_backpressure_operators? + title end def get_type + return 'Manual' if is_backpressure_operators? links = css('.breadcrumb > li:nth-child(2) > a') links.size > 0 ? links.first.content : 'Manual' end + + def is_backpressure_operators? + subpath == 'documentation/operators/backpressure.html' + end end end end