History

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

Simon Legner committed 4 years ago

Commit 01d03191 parent 93e50e84 files · +44 −51Browse files

Unified · Split

4 files
  1. assets/javascripts/news.json +4 −0
  2. lib/docs/filters/http/clean_html.rb +2 −0
  3. lib/docs/filters/http/entries.rb +31 −41
  4. lib/docs/scrapers/http.rb +7 −10
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
1[1[
2 [
3 "2022-09-21",
4 "Added HTTP/3 to <a href=\"/http/\">HTTP</a>"
5 ],
2 [6 [
3 "2022-09-06",7 "2022-09-06",
4 "New documentation: <a href=\"/date_fns/\">date-fns</a>"8 "New documentation: <a href=\"/date_fns/\">date-fns</a>"
lib/docs/filters/http/clean_html.rb+2−0
@@ -25,6 +25,8 @@ module Docs · 24 unmodified lines
25 end25 end
26 26
27 def ietf27 def ietf
28 raise "#{slug} is obsolete!" if at_css('.meta-info *:contains("Obsoleted by")')
29 @doc = at_css('.draftcontent')
28 doc.child.remove while doc.child.name != 'pre'30 doc.child.remove while doc.child.name != 'pre'
29 31
30 css('span.grey', '.invisible', '.noprint', 'a[href^="#page-"]').remove32 css('span.grey', '.invisible', '.noprint', 'a[href^="#page-"]').remove
lib/docs/filters/http/entries.rb+31−41
@@ -44,76 +44,62 @@ module Docs · 43 unmodified lines
44 end44 end
45 45
46 SECTIONS = {46 SECTIONS = {
47 'rfc2616' => [
48 [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15],
49 [14],
50 []
51 ],
52 'rfc4918' => [47 'rfc4918' => [
53 [],48 [],
54 [11],49 [11],
55 []50 [], []
56 ],51 ],
57 'rfc7230' => [52 'rfc9110' => [
58 (2..9).to_a,53 (3..18).to_a,
59 [],54 (3..17).to_a,
55 (7..15).to_a,
60 []56 []
61 ],57 ],
62 'rfc7231' => [58 'rfc9111' => [
63 [3, 8, 9],59 (3..8).to_a,
60 (3..10).to_a,
64 [],61 [],
65 [4, 5, 6, 7]62 [5]
66 ],63 ],
67 'rfc7232' => [64 'rfc9112' => [
68 [5, 6, 7, 8],65 (2..12).to_a,
69 [2, 3, 4],66 (2..11).to_a,
70 []67 [], []
71 ],
72 'rfc7233' => [
73 [5, 6],
74 [2, 3, 4],
75 []
76 ],
77 'rfc7234' => [
78 [3, 6, 7, 8],
79 [4, 5],
80 []
81 ],68 ],
82 'rfc7235' => [69 'rfc9113' => [
83 [2, 5, 6],70 (3..11).to_a,
84 [3, 4],71 (3..10).to_a,
85 []72 [], []
86 ],73 ],
87 'rfc7540' => [74 'rfc9114' => [
88 (3..11).to_a,75 (3..11).to_a,
89 [],76 (3..10).to_a,
90 []77 [7], []
91 ],78 ],
92 'rfc5023' => [79 'rfc5023' => [
93 [],80 [], [], [], []
94 [],
95 []
96 ]81 ]
97 }82 }
98 83
99 LEVEL_1 = /\A(\d+)\z/84 LEVEL_1 = /\A(\d+)\z/
100 LEVEL_2 = /\A(\d+)\.\d+\z/85 LEVEL_2 = /\A(\d+)\.\d+\z/
101 LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/86 LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/
87 LEVEL_4 = /\A(\d+)\.\d+\.\d+\.\d+\z/
102 88
103 def additional_entries89 def additional_entries
104 return [] unless current_url.host == 'datatracker.ietf.org'90 return [] unless current_url.host == 'datatracker.ietf.org'
105 type = nil91 type = nil
106 92
107 css('a[href^="#section-"]').each_with_object([]) do |node, entries|93 css('*[id^="section-"]').each_with_object([]) do |node, entries|
108 id = node['href'].remove('#')94 id = node['id']
109 break entries if entries.any? { |e| e[1] == id }95 break entries if entries.any? { |e| e[1] == id }
110 96
111 content = node.next.content.strip97 content = node.content.strip
112 content.remove! %r{\s*\.+\d*\z}98 content.remove! %r{\s*\.+\d*\z}
113 content.remove! %r{\A[\.\s]+}99 content.remove! %r{\A[\.\s]+}
114 100
115 name = "#{content} (#{rfc})"101 name = "#{content} (#{rfc})"
116 number = node.content.strip102 number = id.remove('section-')
117 103
118 if number =~ LEVEL_1104 if number =~ LEVEL_1
119 if SECTIONS[slug][0].include?($1.to_i)105 if SECTIONS[slug][0].include?($1.to_i)
@@ -131,7 +117,11 @@ module Docs · 11 unmodified lines
131 type = self.name117 type = self.name
132 end118 end
133 elsif (number =~ LEVEL_2 && SECTIONS[slug][1].include?($1.to_i)) ||119 elsif (number =~ LEVEL_2 && SECTIONS[slug][1].include?($1.to_i)) ||
134 (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i))120 (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i)) ||
121 (number =~ LEVEL_4 && SECTIONS[slug][3].include?($1.to_i))
122 if type != self.name
123 name.remove! %r{\A(\d+\.)* }
124 end
135 entries << [name, id, (name =~ /\A\d\d\d/ ? 'Status' : type )]125 entries << [name, id, (name =~ /\A\d\d\d/ ? 'Status' : type )]
136 end126 end
137 end127 end
lib/docs/scrapers/http.rb+7−10
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
2 class Http < Mdn2 class Http < Mdn
3 include MultipleBaseUrls3 include MultipleBaseUrls
4 4
5 # release = '2022-09-20'5 # release = '2022-09-21'
6 self.name = 'HTTP'6 self.name = 'HTTP'
7 self.base_urls = [7 self.base_urls = [
8 'https://developer.mozilla.org/en-US/docs/Web/HTTP',8 'https://developer.mozilla.org/en-US/docs/Web/HTTP',
@@ -16,7 +16,7 @@ module Docs · 7 unmodified lines
16 filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title16 filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title
17 end17 end
18 options[:container] = ->(filter) do18 options[:container] = ->(filter) do
19 filter.current_url.host == 'datatracker.ietf.org' ? '.content .draftcontent' : Docs::Mdn.options[:container]19 filter.current_url.host == 'datatracker.ietf.org' ? '.content' : Docs::Mdn.options[:container]
20 end20 end
21 options[:skip_links] = ->(filter) do21 options[:skip_links] = ->(filter) do
22 filter.current_url.host == 'datatracker.ietf.org' ? true : false22 filter.current_url.host == 'datatracker.ietf.org' ? true : false
@@ -37,15 +37,12 @@ module Docs · 14 unmodified lines
37 37
38 def initial_urls38 def initial_urls
39 %w(https://developer.mozilla.org/en-US/docs/Web/HTTP39 %w(https://developer.mozilla.org/en-US/docs/Web/HTTP
40 https://datatracker.ietf.org/doc/html/rfc2616
41 https://datatracker.ietf.org/doc/html/rfc491840 https://datatracker.ietf.org/doc/html/rfc4918
42 https://datatracker.ietf.org/doc/html/rfc723041 https://datatracker.ietf.org/doc/html/rfc9110
43 https://datatracker.ietf.org/doc/html/rfc723142 https://datatracker.ietf.org/doc/html/rfc9111
44 https://datatracker.ietf.org/doc/html/rfc723243 https://datatracker.ietf.org/doc/html/rfc9112
45 https://datatracker.ietf.org/doc/html/rfc723344 https://datatracker.ietf.org/doc/html/rfc9113
46 https://datatracker.ietf.org/doc/html/rfc723445 https://datatracker.ietf.org/doc/html/rfc9114
47 https://datatracker.ietf.org/doc/html/rfc7235
48 https://datatracker.ietf.org/doc/html/rfc7540
49 https://datatracker.ietf.org/doc/html/rfc5023)46 https://datatracker.ietf.org/doc/html/rfc5023)
50 end47 end
51 end48 end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t