[devdocsgjs/main: 1/69] add Sanctuary




commit 6510b06a363c8b6badc930521da8d0d9ffaf72b1
Author: David Chambers <dc davidchambers me>
Date:   Sun Jul 3 18:15:00 2022 +0200

    add Sanctuary

 .../javascripts/templates/pages/about_tmpl.coffee  |   5 ++
 assets/stylesheets/application.css.scss            |   1 +
 assets/stylesheets/pages/_sanctuary.scss           |  77 ++++++++++++++++++
 lib/docs/filters/sanctuary/clean_html.rb           |  86 +++++++++++++++++++++
 lib/docs/filters/sanctuary/entries.rb              |  33 ++++++++
 lib/docs/scrapers/sanctuary.rb                     |  25 ++++++
 public/icons/docs/sanctuary/16.png                 | Bin 0 -> 564 bytes
 public/icons/docs/sanctuary/16 2x png              | Bin 0 -> 1213 bytes
 public/icons/docs/sanctuary/SOURCE                 |   1 +
 9 files changed, 228 insertions(+)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index ebadb1b3..ad87b37b 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -801,6 +801,11 @@ credits = [
     '2021 SaltStack',
     'Apache',
     'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'
+  ], [
+    'Sanctuary',
+    '2020 Sanctuary; 2016 Plaid Technologies, Inc.',
+    'MIT',
+    'https://raw.githubusercontent.com/sanctuary-js/sanctuary/v3.1.0/LICENSE'
   ], [
     'Sass',
     '2006-2020 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss
index b9f99a5f..66569d69 100644
--- a/assets/stylesheets/application.css.scss
+++ b/assets/stylesheets/application.css.scss
@@ -112,6 +112,7 @@
         'pages/rubydoc',
         'pages/rust',
         'pages/rxjs',
+        'pages/sanctuary',
         'pages/scala',
         'pages/sinon',
         'pages/socketio',
diff --git a/assets/stylesheets/pages/_sanctuary.scss b/assets/stylesheets/pages/_sanctuary.scss
new file mode 100644
index 00000000..a290499a
--- /dev/null
+++ b/assets/stylesheets/pages/_sanctuary.scss
@@ -0,0 +1,77 @@
+._sanctuary {
+  @extend %simple;
+
+  --base-font-size: 14px;
+
+  --h2-padding-top: 0.5em;
+  --h2-line-height: 1.25rem;
+  --h2-padding-bottom: 0.5em;
+  --h2-border-bottom-width: 1px;
+  --h2-margin-bottom: 1em;
+
+  --h3-padding-top: 1px;
+  --h3-line-height: 1.375rem;
+  --h3-padding-bottom: 2px;
+  --h3-border-bottom-width: 1px;
+  --h3-margin-bottom: 1em;
+
+  --h4-padding-top: 0px;
+  --h4-line-height: calc(1.3 * var(--base-font-size));
+  --h4-padding-bottom: 0px;
+  --h4-margin-bottom: 1em;
+
+  padding-left: 32px;
+
+  .pilcrow {
+    position: absolute;
+    display: block;
+    width: 24px;
+    text-align: center;
+    text-decoration: none;
+    font-weight: var(--bolderFontWeight);
+    color: #eee;
+  }
+
+  .pilcrow:hover {
+    color: var(--linkColor);
+  }
+
+  .pilcrow.h2 {
+    margin-left: -40px;
+    margin-top: calc(0px - (var(--h2-padding-top) +
+                            var(--h2-line-height) +
+                            var(--h2-padding-bottom) +
+                            var(--h2-border-bottom-width) +
+                            var(--h2-margin-bottom)));
+    padding: var(--h2-padding-top) 0 var(--h2-padding-bottom);
+    font-size: 1rem;
+    line-height: var(--h2-line-height);
+  }
+
+  .pilcrow.h3 {
+    margin-left: -40px;
+    margin-top: calc(0px - (var(--h3-padding-top) +
+                            var(--h3-line-height) +
+                            var(--h3-padding-bottom) +
+                            var(--h3-border-bottom-width) +
+                            var(--h3-margin-bottom)));
+    padding: var(--h3-padding-top) 0 var(--h3-padding-bottom);
+    font-size: inherit;
+    line-height: var(--h3-line-height);
+  }
+
+  .pilcrow.h4 {
+    margin-left: -24px;
+    margin-top: calc(0px - (var(--h4-padding-top) +
+                            var(--h4-line-height) +
+                            var(--h4-padding-bottom) +
+                            var(--h4-margin-bottom)));
+    padding: var(--h4-padding-top) 0 var(--h4-padding-bottom);
+    font-size: inherit;
+    line-height: var(--h4-line-height);
+  }
+
+  pre > code {
+    font-size: inherit;
+  }
+}
diff --git a/lib/docs/filters/sanctuary/clean_html.rb b/lib/docs/filters/sanctuary/clean_html.rb
new file mode 100644
index 00000000..c76ea1c0
--- /dev/null
+++ b/lib/docs/filters/sanctuary/clean_html.rb
@@ -0,0 +1,86 @@
+def repeat(n, s)
+  Array.new(n, s).join("")
+end
+
+def _(n)
+  repeat(n, " ")
+end
+
+module Docs
+
+  class Sanctuary
+    class CleanHtmlFilter < Filter
+      def call
+        # Remove header containing GitHub, Gitter, and Stack Overflow links.
+        doc.at("#css-header").unlink()
+
+        # Remove redundant section links from table of contents.
+        doc.at("a[href='#section:api']").next_element.unlink()
+
+        # Swap headings and accompanying pilcrows to aid positioning via CSS.
+        doc.css(".pilcrow").each { |node| node.next_element.after(node) }
+
+        # Insert Fink link in place of logo.
+        doc.at("[id='section:sponsors'] ~ ul > li > p").prepend_child(
+          doc.document.create_element("a", "Fink", {"href" => "https://www.fink.no/"})
+        )
+
+        # Convert code blocks to the correct structure for syntax highlighting.
+        doc.css("code[class^='language-']").each { |node|
+          node.parent.replace(
+            doc.document.create_element(
+              "pre",
+              node.content,
+              {"data-language" => node.attributes["class"].value.delete_prefix("language-")}
+            )
+          )
+        }
+
+        # Convert interactive examples to straightforward code blocks.
+        doc.css(".examples").each { |node|
+          node.replace(
+            doc.document.create_element(
+              "pre",
+              node
+                .css("input")
+                .map { |node| "> " + node.attributes["value"].value }
+                .zip(node.css(".output").map { |node|
+                  if node.content.start_with?("! Invalid value")
+                    # XXX: Reinstate newlines and consecutive spaces.
+                    content = node.content.dup()
+                    content[ 15] = "\n\n"
+                    content[ 68] = "\n" + _("add :: FiniteNumber -> ".size)
+                    content[104] = "\n" + _("add :: FiniteNumber -> ".size + ("FiniteNumber".size - 1) / 2)
+                    content[134] = "\n\n"
+                    content[138] = _(2)
+                    content[155] = "\n\n"
+                    content[215] = "\n\n"
+                    content[337] = "\n"
+                    content
+                  else
+                    node.content
+                  end
+                })
+                .map { |pair| pair.join("\n") }
+                .join("\n\n"),
+              {"data-language" => "javascript"}
+            )
+          )
+        }
+
+        # Remove example that requires interactivity.
+        pre = doc.at("[id='section:overview'] ~ pre")
+        p = pre.previous_element
+        if p.content == "Try changing words to [] in the REPL below. Hit return to re-evaluate."
+          p.unlink()
+          pre.unlink()
+        else
+          raise "Failed to find interactive example within overview section"
+        end
+
+        doc
+      end
+    end
+  end
+
+end
diff --git a/lib/docs/filters/sanctuary/entries.rb b/lib/docs/filters/sanctuary/entries.rb
new file mode 100644
index 00000000..28985bb7
--- /dev/null
+++ b/lib/docs/filters/sanctuary/entries.rb
@@ -0,0 +1,33 @@
+module Docs
+
+  class EntryIndex
+    # Override to prevent sorting.
+    def entries_as_json
+      @entries.map(&:as_json)
+    end
+    # Override to prevent sorting.
+    def types_as_json
+      @types.values.map(&:as_json)
+    end
+  end
+
+  class Sanctuary
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        entries = []
+        type = ""
+        css("h3, h4").each do |node|
+          case node.name
+          when "h3"
+            type = node.text
+          when "h4"
+            name = id = node.attributes["id"].value
+            entries << [name, id, type]
+          end
+        end
+        return entries
+      end
+    end
+  end
+
+end
diff --git a/lib/docs/scrapers/sanctuary.rb b/lib/docs/scrapers/sanctuary.rb
new file mode 100644
index 00000000..1f2a41dc
--- /dev/null
+++ b/lib/docs/scrapers/sanctuary.rb
@@ -0,0 +1,25 @@
+module Docs
+
+  class Sanctuary < UrlScraper
+    self.name = "Sanctuary"
+    self.slug = "sanctuary"
+    self.type = "sanctuary"
+    self.release = "3.1.0"
+    self.base_url = "https://sanctuary.js.org/";
+    self.links = {
+      home: "https://sanctuary.js.org/";,
+      code: "https://github.com/sanctuary-js/sanctuary";,
+    }
+
+    html_filters.push("sanctuary/entries")
+    html_filters.push("sanctuary/clean_html")
+
+    options[:title] = "Sanctuary"
+    options[:attribution] = "Licensed under the MIT License."
+
+    def get_latest_version(opts)
+      get_npm_version("sanctuary", opts)
+    end
+  end
+
+end
diff --git a/public/icons/docs/sanctuary/16.png b/public/icons/docs/sanctuary/16.png
new file mode 100644
index 00000000..df0bbd4f
Binary files /dev/null and b/public/icons/docs/sanctuary/16.png differ
diff --git a/public/icons/docs/sanctuary/16 2x png b/public/icons/docs/sanctuary/16 2x png
new file mode 100644
index 00000000..0bf2b9f3
Binary files /dev/null and b/public/icons/docs/sanctuary/16 2x png differ
diff --git a/public/icons/docs/sanctuary/SOURCE b/public/icons/docs/sanctuary/SOURCE
new file mode 100644
index 00000000..4aba6a0d
--- /dev/null
+++ b/public/icons/docs/sanctuary/SOURCE
@@ -0,0 +1 @@
+https://github.com/sanctuary-js/sanctuary-logo/tree/v1.1.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]