[devdocsgjs/main: 10/12] Update HTTP documentation: HTTP/3, RFC 9110–9114




commit 01d0319c379af6fde096908a98a8dba306fa6d11
Author: Simon Legner <Simon Legner gmail com>
Date:   Wed Sep 21 20:54:39 2022 +0200

    Update HTTP documentation: HTTP/3, RFC 9110–9114

 assets/javascripts/news.json        |  4 +++
 lib/docs/filters/http/clean_html.rb |  2 ++
 lib/docs/filters/http/entries.rb    | 72 ++++++++++++++++---------------------
 lib/docs/scrapers/http.rb           | 17 ++++-----
 4 files changed, 44 insertions(+), 51 deletions(-)
---
diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json
index 8af6192b..73d07cc1 100644
--- a/assets/javascripts/news.json
+++ b/assets/javascripts/news.json
@@ -1,4 +1,8 @@
 [
+  [
+    "2022-09-21",
+    "Added HTTP/3 to <a href=\"/http/\">HTTP</a>"
+  ],
   [
     "2022-09-06",
     "New documentation: <a href=\"/date_fns/\">date-fns</a>"
diff --git a/lib/docs/filters/http/clean_html.rb b/lib/docs/filters/http/clean_html.rb
index 6f93a7fc..9c5abe3e 100644
--- a/lib/docs/filters/http/clean_html.rb
+++ b/lib/docs/filters/http/clean_html.rb
@@ -25,6 +25,8 @@ module Docs
       end
 
       def ietf
+        raise "#{slug} is obsolete!" if at_css('.meta-info *:contains("Obsoleted by")')
+        @doc = at_css('.draftcontent')
         doc.child.remove while doc.child.name != 'pre'
 
         css('span.grey', '.invisible', '.noprint', 'a[href^="#page-"]').remove
diff --git a/lib/docs/filters/http/entries.rb b/lib/docs/filters/http/entries.rb
index 83106efa..0bc64538 100644
--- a/lib/docs/filters/http/entries.rb
+++ b/lib/docs/filters/http/entries.rb
@@ -44,76 +44,62 @@ module Docs
       end
 
       SECTIONS = {
-        'rfc2616' => [
-          [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15],
-          [14],
-          []
-        ],
         'rfc4918' => [
           [],
           [11],
-          []
+          [], []
         ],
-        'rfc7230' => [
-          (2..9).to_a,
-          [],
+        'rfc9110' => [
+          (3..18).to_a,
+          (3..17).to_a,
+          (7..15).to_a,
           []
         ],
-        'rfc7231' => [
-          [3, 8, 9],
+        'rfc9111' => [
+          (3..8).to_a,
+          (3..10).to_a,
           [],
-          [4, 5, 6, 7]
+          [5]
         ],
-        'rfc7232' => [
-          [5, 6, 7, 8],
-          [2, 3, 4],
-          []
-        ],
-        'rfc7233' => [
-          [5, 6],
-          [2, 3, 4],
-          []
-        ],
-        'rfc7234' => [
-          [3, 6, 7, 8],
-          [4, 5],
-          []
+        'rfc9112' => [
+          (2..12).to_a,
+          (2..11).to_a,
+          [], []
         ],
-        'rfc7235' => [
-          [2, 5, 6],
-          [3, 4],
-          []
+        'rfc9113' => [
+          (3..11).to_a,
+          (3..10).to_a,
+          [], []
         ],
-        'rfc7540' => [
+        'rfc9114' => [
           (3..11).to_a,
-          [],
-          []
+          (3..10).to_a,
+          [7], []
         ],
         'rfc5023' => [
-          [],
-          [],
-          []
+          [], [], [], []
         ]
       }
 
       LEVEL_1 = /\A(\d+)\z/
       LEVEL_2 = /\A(\d+)\.\d+\z/
       LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/
+      LEVEL_4 = /\A(\d+)\.\d+\.\d+\.\d+\z/
 
       def additional_entries
         return [] unless current_url.host == 'datatracker.ietf.org'
         type = nil
 
-        css('a[href^="#section-"]').each_with_object([]) do |node, entries|
-          id = node['href'].remove('#')
+        css('*[id^="section-"]').each_with_object([]) do |node, entries|
+          id = node['id']
           break entries if entries.any? { |e| e[1] == id }
 
-          content = node.next.content.strip
+          content = node.content.strip
           content.remove! %r{\s*\.+\d*\z}
           content.remove! %r{\A[\.\s]+}
 
           name = "#{content} (#{rfc})"
-          number = node.content.strip
+          number = id.remove('section-')
 
           if number =~ LEVEL_1
             if SECTIONS[slug][0].include?($1.to_i)
@@ -131,7 +117,11 @@ module Docs
               type = self.name
             end
           elsif (number =~ LEVEL_2 && SECTIONS[slug][1].include?($1.to_i)) ||
-                (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i))
+                (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i)) ||
+                (number =~ LEVEL_4 && SECTIONS[slug][3].include?($1.to_i))
+            if type != self.name
+              name.remove! %r{\A(\d+\.)* }
+            end
             entries << [name, id, (name =~ /\A\d\d\d/ ? 'Status' : type )]
           end
         end
diff --git a/lib/docs/scrapers/http.rb b/lib/docs/scrapers/http.rb
index d3dbabfb..f655de79 100644
--- a/lib/docs/scrapers/http.rb
+++ b/lib/docs/scrapers/http.rb
@@ -2,7 +2,7 @@ module Docs
   class Http < Mdn
     include MultipleBaseUrls
 
-    # release = '2022-09-20'
+    # release = '2022-09-21'
     self.name = 'HTTP'
     self.base_urls = [
       'https://developer.mozilla.org/en-US/docs/Web/HTTP',
@@ -16,7 +16,7 @@ module Docs
       filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title
     end
     options[:container] = ->(filter) do
-      filter.current_url.host == 'datatracker.ietf.org' ? '.content .draftcontent' : 
Docs::Mdn.options[:container]
+      filter.current_url.host == 'datatracker.ietf.org' ? '.content' : Docs::Mdn.options[:container]
     end
     options[:skip_links] = ->(filter) do
       filter.current_url.host == 'datatracker.ietf.org' ? true : false
@@ -37,15 +37,12 @@ module Docs
 
     def initial_urls
       %w(https://developer.mozilla.org/en-US/docs/Web/HTTP
-         https://datatracker.ietf.org/doc/html/rfc2616
          https://datatracker.ietf.org/doc/html/rfc4918
-         https://datatracker.ietf.org/doc/html/rfc7230
-         https://datatracker.ietf.org/doc/html/rfc7231
-         https://datatracker.ietf.org/doc/html/rfc7232
-         https://datatracker.ietf.org/doc/html/rfc7233
-         https://datatracker.ietf.org/doc/html/rfc7234
-         https://datatracker.ietf.org/doc/html/rfc7235
-         https://datatracker.ietf.org/doc/html/rfc7540
+         https://datatracker.ietf.org/doc/html/rfc9110
+         https://datatracker.ietf.org/doc/html/rfc9111
+         https://datatracker.ietf.org/doc/html/rfc9112
+         https://datatracker.ietf.org/doc/html/rfc9113
+         https://datatracker.ietf.org/doc/html/rfc9114
          https://datatracker.ietf.org/doc/html/rfc5023)
     end
   end


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