فهرست منبع

Add Zig documentation (0.9.0)

Simon Legner 4 سال پیش
والد
کامیت
4ed22db333

+ 5 - 1
assets/javascripts/news.json

@@ -1,7 +1,11 @@
 [
+  [
+    "2021-12-27",
+    "New documentation: <a href=\"/zig/\">Zig</a>"
+  ],
   [
     "2021-12-26",
-    "New documentation: <a href=\"/gnu_make/\">Gnu Make</a>"
+    "New documentation: <a href=\"/gnu_make/\">GNU Make</a>"
   ],
   [
     "2021-12-07",

+ 4 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -918,5 +918,9 @@ credits = [
     'BSD',
     'https://raw.githubusercontent.com/yiisoft/yii/master/LICENSE'
   ], [
+    'Zig',
+    '2015–2021, Zig contributors',
+    'MIT',
+    'https://raw.githubusercontent.com/ziglang/zig/master/LICENSE'
   ]
 ]

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 521 - 372
assets/javascripts/vendor/prism.js


+ 19 - 0
lib/docs/filters/zig/clean_html.rb

@@ -0,0 +1,19 @@
+module Docs
+  class Zig
+    class CleanHtmlFilter < Filter
+      def call
+        at_css('main').prepend_child at_css('h1')
+        @doc = at_css('main')
+        css('a.hdr').remove
+        css('h1, h2, h3').each do |node|
+          node.content = node.content
+        end
+        css('pre > code').each do |node|
+          node.parent['data-language'] = 'zig'
+          node.parent.content = node.parent.content
+        end
+        doc
+      end
+    end
+  end
+end

+ 25 - 0
lib/docs/filters/zig/entries.rb

@@ -0,0 +1,25 @@
+module Docs
+  class Zig
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        entries = []
+        type = nil
+        subtype = nil
+
+        css('h2, h3').each do |node|
+          if node.name == 'h2' && node['id']
+            type = node.content.gsub(/ §/, '')
+            subtype = nil
+            entries << [type, node['id'], type]
+          elsif node.name == 'h3' && node['id']
+            subtype = node.content.gsub(/ §/, '')
+            name = "#{type}: #{subtype}"
+            entries << [name, node['id'], type]
+          end
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 24 - 0
lib/docs/scrapers/zig.rb

@@ -0,0 +1,24 @@
+module Docs
+  class Zig < UrlScraper
+    self.name = 'Zig'
+    self.type = 'simple'
+    self.release = '0.9.0'
+    self.base_url = 'https://ziglang.org/documentation/0.9.0/'
+    self.links = {
+      home: 'https://ziglang.org/',
+      code: 'https://github.com/ziglang/zig'
+    }
+
+    html_filters.push 'zig/entries', 'zig/clean_html'
+
+    options[:follow_links] = false
+    options[:attribution] = <<-HTML
+      &copy; 2015–2021, Zig contributors
+    HTML
+
+    def get_latest_version(opts)
+      tags = get_github_tags('ziglang', 'zig', opts)
+      tags[0]['name']
+    end
+  end
+end

BIN
public/icons/docs/zig/16.png


BIN
public/icons/docs/zig/16@2x.png


+ 2 - 0
public/icons/docs/zig/SOURCE

@@ -0,0 +1,2 @@
+https://github.com/ziglang/logo/blob/master/zig-favicon.png
+https://github.com/ziglang/logo/blob/master/zig-mark.svg

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است