From 8b9c62d7915172eea9904afa3400b64842851d17 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Thu, 2 Aug 2018 20:03:49 +0200 Subject: [PATCH] Add Handlebars.js documentation --- .../templates/pages/about_tmpl.coffee | 5 ++ assets/stylesheets/pages/_simple.scss | 1 + lib/docs/filters/handlebars/clean_html.rb | 44 ++++++++++++++++++ lib/docs/filters/handlebars/entries.rb | 19 ++++++++ lib/docs/scrapers/handlebars.rb | 23 +++++++++ public/icons/docs/handlebars/16.png | Bin 0 -> 1129 bytes public/icons/docs/handlebars/16@2x.png | Bin 0 -> 4217 bytes public/icons/docs/handlebars/SOURCE | 1 + 8 files changed, 93 insertions(+) create mode 100644 lib/docs/filters/handlebars/clean_html.rb create mode 100644 lib/docs/filters/handlebars/entries.rb create mode 100644 lib/docs/scrapers/handlebars.rb create mode 100644 public/icons/docs/handlebars/16.png create mode 100644 public/icons/docs/handlebars/16@2x.png create mode 100644 public/icons/docs/handlebars/SOURCE diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 753c0058..26ca8e7e 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -310,6 +310,11 @@ credits = [ 'GruntJS Team', 'MIT', 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10' + ], [ + 'Handlebars', + '2011-2017 Yehuda Katz', + 'MIT', + 'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE' ], [ 'Haskell', 'The University of Glasgow', diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index fe36579d..078a5055 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -27,6 +27,7 @@ ._flow, ._gnu, ._grunt, +._handlebars, ._haxe, ._immutable, ._influxdata, diff --git a/lib/docs/filters/handlebars/clean_html.rb b/lib/docs/filters/handlebars/clean_html.rb new file mode 100644 index 00000000..f99aa1df --- /dev/null +++ b/lib/docs/filters/handlebars/clean_html.rb @@ -0,0 +1,44 @@ +module Docs + class Handlebars + class CleanHtmlFilter < Filter + def call + # Remove the t-shirt shop advertisement + css('#callout').remove + + # The title filter is used to add titles to pages without one, remove original headers + css('h1').remove + + # Remove the link to the issue tracker + css('.issue-tracker').remove + + css('pre').each do |node| + # Remove nested nodes inside pre tags + node.content = node.content + + # Add syntax highlighting + node['data-language'] = 'html' + end + + # Transform 'Learn More' links to headers in the "Getting Started" part of the homepage + # If this step is skipped, that section looks cluttered with 4 sub-sections without any dividers + css('#getting-started + .contents a.more-info').each do |node| + clone = node.clone + + # Move it to the top of the sub-section + node.parent.prepend_child(clone) + + # Turn it into a header + clone.name = 'h3' + + # Remove the "Learn More: " part + clone.content = clone.content[12..-1] + end + + # Remove class attributes from div elements to reduce file size + css('div').remove_attr('class') + + doc + end + end + end +end diff --git a/lib/docs/filters/handlebars/entries.rb b/lib/docs/filters/handlebars/entries.rb new file mode 100644 index 00000000..24d46c6c --- /dev/null +++ b/lib/docs/filters/handlebars/entries.rb @@ -0,0 +1,19 @@ +module Docs + class Handlebars + class EntriesFilter < Docs::EntriesFilter + def get_name + subpath[0..-6].titleize + end + + def get_type + name + end + + def additional_entries + css('h2, h3').to_a.map do |node| + [node.content.strip, node['id'], root_page? ? 'Manual' : nil] + end + end + end + end +end diff --git a/lib/docs/scrapers/handlebars.rb b/lib/docs/scrapers/handlebars.rb new file mode 100644 index 00000000..b7712f6f --- /dev/null +++ b/lib/docs/scrapers/handlebars.rb @@ -0,0 +1,23 @@ +module Docs + class Handlebars < UrlScraper + self.name = 'Handlebars.js' + self.slug = 'handlebars' + self.type = 'handlebars' + self.release = '4.0.11' + self.base_url = 'https://handlebarsjs.com/' + self.links = { + home: 'https://handlebarsjs.com/', + code: 'https://github.com/wycats/handlebars.js/' + } + + html_filters.push 'handlebars/entries', 'handlebars/clean_html', 'title' + + options[:container] = '#contents' + options[:root_title] = 'Handlebars.js' + + options[:attribution] = <<-HTML + © 2011-2017 by Yehuda Katz
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/handlebars/16.png b/public/icons/docs/handlebars/16.png new file mode 100644 index 0000000000000000000000000000000000000000..1b87778333abf219a29a41698acb79a140cea24d GIT binary patch literal 1129 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wk0|Se+ zr;B5Vg&?B<%lqFzHA5XRhK4dQzkaB0=y2-hxdsM?|Bfc=iHr>Y(-?sS!{7g{{}>rw zGcq#v0zJyY$iOgR@0nXGf$aazW-69KU)j$xI-01pGX7`KWMTT7|K}fbEdwJ%DpII` z0_iUhb0CQ=X8HBE;L}Gd=O}>B2?i!px7KQ|H$v(K7agv zXx|QDAU_!>Cj`W?f7qA|fi&BH28L%$zy2|G09|_k=!#E3CvIhAU`+YW`b}p4ncL-h zh9=KUEFJFbJ#({+`~MeNpr?SY`@e>P0caH?!^J;;|20A_#7^zryfJm_`t`xsWg((W z_$2=ULl2)kNDi+7jEulIAOP?hKtL~8ngy>SpdVNn8UEo@gVzO&OpMR}{{R0Tp8>-_ Y&etR5{?3IP_&{FqboFyt=akR{03fq>-v9sr literal 0 HcmV?d00001 diff --git a/public/icons/docs/handlebars/16@2x.png b/public/icons/docs/handlebars/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..426288c71d81861fc958c541870af5b44802cbc2 GIT binary patch literal 4217 zcmeHIO-NKx6h7y^H`AzCWLS(2s?hIkhoKC4~tSEf*3kA`5?}W}JIE*IW$al*(N?2kv|K{NC?=_q_YA94g-* zADbKt0P${@vx47tHEdRX);Bgz^DE|ztGXT_Zi5;Kckd+uBxJdrg-4FXpgrO9B*#Q0 z%D^gT0GG3WM}Ah4kbydm-315|2;U0`+8Hwfqkc35f84ZBc#JVl4&^H0HBq&XRLbkDQQ<(oZ zB3w?ik6dbLfuQm^9Cn*AZ9Pi}i4rVVJ@33<(V3UJPNF%+{9?g|VSYvx55yVb+DqAb@4hkvzYtgG*>BIvJwYy`=kiZ zz}P4wYEb$=lGIP-77CH^s&AyUdtkV|DMGBWDIdoiP_g_q+~m9|9+8CEhjX5{!{dAu zf5n-Xxl;;R14P@IUO@yS?CBz(<&DSdRUj5gCM0I$Bvk3fU{ z`Bd#A(Cs2^0K}rhf;Ir1#Z|5*03yEgwLU{rX9s)-HU}mC(5Vs4jWQ5rpizF`a@?I> PqnL0PmpfaF>Mr~N8w3F- literal 0 HcmV?d00001 diff --git a/public/icons/docs/handlebars/SOURCE b/public/icons/docs/handlebars/SOURCE new file mode 100644 index 00000000..aa446ef6 --- /dev/null +++ b/public/icons/docs/handlebars/SOURCE @@ -0,0 +1 @@ +https://github.com/yahoo/formatjs-site/tree/master/public/img