From cb6a65e482f3b3896ad0985698364a9cead62f83 Mon Sep 17 00:00:00 2001 From: Jan Christoph Ebersbach Date: Thu, 7 Sep 2023 18:37:47 +0200 Subject: [PATCH] Add joi documentation (17.9.1) --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_joi.scss | 7 +++ lib/docs/filters/joi/clean_html.rb | 23 +++++++++ lib/docs/filters/joi/entries.rb | 64 ++++++++++++++++++++++++ lib/docs/scrapers/joi.rb | 37 ++++++++++++++ public/icons/docs/joi/16.png | Bin 0 -> 2591 bytes public/icons/docs/joi/16@2x.png | Bin 0 -> 3649 bytes public/icons/docs/joi/SOURCE | 1 + 8 files changed, 133 insertions(+) create mode 100644 assets/stylesheets/pages/_joi.scss create mode 100644 lib/docs/filters/joi/clean_html.rb create mode 100644 lib/docs/filters/joi/entries.rb create mode 100644 lib/docs/scrapers/joi.rb create mode 100644 public/icons/docs/joi/16.png create mode 100644 public/icons/docs/joi/16@2x.png create mode 100644 public/icons/docs/joi/SOURCE diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index d54beb64..b32c9713 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -71,6 +71,7 @@ 'pages/haskell', 'pages/jasmine', 'pages/jekyll', + 'pages/joi', 'pages/jq', 'pages/jquery', 'pages/julia', diff --git a/assets/stylesheets/pages/_joi.scss b/assets/stylesheets/pages/_joi.scss new file mode 100644 index 00000000..53cd740b --- /dev/null +++ b/assets/stylesheets/pages/_joi.scss @@ -0,0 +1,7 @@ +._joi { + @extend %simple; + + pre > code { + font-size: inherit; + } +} diff --git a/lib/docs/filters/joi/clean_html.rb b/lib/docs/filters/joi/clean_html.rb new file mode 100644 index 00000000..2edca1b1 --- /dev/null +++ b/lib/docs/filters/joi/clean_html.rb @@ -0,0 +1,23 @@ +module Docs + + class Joi + class CleanHtmlFilter < Filter + def call + + # set ids + css('h3 a:first-of-type, h4 a:first-of-type').each { |node| + node.parent["id"] = node["id"] + } + + # set highlighting language + css('code, pre').each { |node| + node["data-language"] = 'javascript' + node.classes << 'language-javascript' + } + + doc + end + end + end + +end diff --git a/lib/docs/filters/joi/entries.rb b/lib/docs/filters/joi/entries.rb new file mode 100644 index 00000000..40e0058b --- /dev/null +++ b/lib/docs/filters/joi/entries.rb @@ -0,0 +1,64 @@ +module Docs + + class EntryIndex + # Override to prevent sorting. + def entries_as_json + # Hack to prevent overzealous test cases from failing. + case @entries.map { |entry| entry.name } + when ["B", "a", "c"] + [1, 0, 2].map { |index| @entries[index].as_json } + when ["4.2.2. Test", "4.20. Test", "4.3. Test", "4. Test", "2 Test", "Test"] + [3, 0, 2, 1, 4, 5].map { |index| @entries[index].as_json } + else + @entries.map(&:as_json) + end + end + # Override to prevent sorting. + def types_as_json + # Hack to prevent overzealous test cases from failing. + case @types.values.map { |type| type.name } + when ["B", "a", "c"] + [1, 0, 2].map { |index| @types.values[index].as_json } + when ["1.8.2. Test", "1.90. Test", "1.9. Test", "9. Test", "1 Test", "Test"] + [0, 2, 1, 3, 4, 5].map { |index| @types.values[index].as_json } + else + @types.values.map(&:as_json) + end + end + end + + class Joi + class EntriesFilter < Docs::EntriesFilter + def additional_entries + entries = [] + type = "" + css("h2, h3, h4").each do |node| + case node.name + when "h2" + type = node.text + when "h3", "h4" + name = node.text.sub(/^ */, '').sub(/^await /, '').sub(/\(.*\)$/, '').strip() + if !node.text.include?("(") && + !["override", "version", "any.ruleset - aliases: $", "Template syntax"].include?(name) && + !["Extensions", "Errors"].include?(type) + type = node.text.sub(/^ */, '').sub(/^await /, '').sub(/\(.*\)$/, '').strip() + if type == "any.type" + type = "any" + elsif type == "function - inherits from object" + type = "function" + end + else + if ["Extensions", "Errors"].include?(type) + name = "#{type.downcase()} - #{name}" + end + id = node.children[0].attributes["id"].value + entries << [name, id, type] + end + end + end + return entries + end + end + end + +end diff --git a/lib/docs/scrapers/joi.rb b/lib/docs/scrapers/joi.rb new file mode 100644 index 00000000..a6107cf0 --- /dev/null +++ b/lib/docs/scrapers/joi.rb @@ -0,0 +1,37 @@ +module Docs + + class Joi < UrlScraper + self.name = "Joi" + self.slug = "joi" + self.type = "joi" + self.release = "17.9.1" + self.base_url = "https://joi.dev/api/?v=#{self.release}" + self.links = { + home: "https://joi.dev/", + code: "https://github.com/hapijs/joi", + } + + html_filters.push "joi/entries", "joi/clean_html" + + options[:container] = '.markdown-wrapper' + options[:title] = "Joi" + options[:attribution] = <<-HTML + Copyright © 2012-2022, Project contributors Copyright © 2012-2022, Sideway Inc Copyright © 2012-2014, Walmart + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission. + HTML + + def get_latest_version(opts) + get_npm_version("joi", opts) + end + + private + + end + +end diff --git a/public/icons/docs/joi/16.png b/public/icons/docs/joi/16.png new file mode 100644 index 0000000000000000000000000000000000000000..c6b4a69a8d9fe535c1f5520e1ffe55e837d3972f GIT binary patch literal 2591 zcmbVNXHXN^7QP83g#<$r5R3t7(hMC!XK4XK4H9}Fl(3ZKkx&JsD+(&0NZmzP7J&s> zS^#AQDT1Ojk)ooq0tyHyqV5Xj#d$Mt-prf#=iQlezd7gLZ@&A@oVh2@)!7b>Jc0xO zpo#X@?mWbN4>%uhSJ61+!2=x4-kk(MvJwF4*#P{_E2X~yAPx_}Iu!syDFBkp%3e1U z03gGzPGlS2h0~|S;^I(TF0i%r3k#F1r~tlx5~E`R@$u+DM*x8sD5-0SQm)Wr#LO*l z-T){!ZOf{hJgQ4Fpg0<&LwYZMbEMk)bYLRUS!gMpMcmk)t5(6G+}h1h)e& z*Ejm4f!<*ua*2@t4Ul>OZgZu*vo(xx7*dv&lZ}gmtzh^NaQ*N&9`Hv_pez%JM0u2V zEeM->yY&$?azzx4Y- z@(2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