From b51d4e50d66d922075587c9c0fc07aae7c2f3019 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Fri, 13 Jul 2018 22:57:43 +0200 Subject: [PATCH] Better headers --- lib/docs/filters/dart/clean_html.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/docs/filters/dart/clean_html.rb b/lib/docs/filters/dart/clean_html.rb index 6032a994..ce1733af 100644 --- a/lib/docs/filters/dart/clean_html.rb +++ b/lib/docs/filters/dart/clean_html.rb @@ -10,6 +10,25 @@ module Docs at_css('.main-content').prepend_child("

#{name} #{kind}

") end + # Add a title to the homepage of the v2 docs + if subpath == 'index.html' && at_css('.main-content > h1').nil? + at_css('.main-content').prepend_child('

Dart SDK

') + end + + # Add the library to the main content (it is not always visible in the menu entry) + breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a') + if breadcrumbs.length > 1 + library = breadcrumbs[1].content + + # Generate the link to the homepage of the library + with_hypens = library.gsub(/:/, '-') + location = "#{'../' * subpath.count('/')}#{with_hypens}/#{with_hypens}-library" + link = "#{library}" + + # Add the link to the main title, just like how the "Homepage" and "Source code" links appear + at_css('.main-content').prepend_child("

#{link}

") + end + # Extract the actual content # We can't use options[:container] here because the entries filter uses the breadcrumbs node @doc = at_css('.main-content')