From cda737ceec8992a1af0307b7f80278a1d6af7125 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Fri, 26 Apr 2019 20:04:13 +1000 Subject: [PATCH 01/10] basic scrapping working --- .gitignore | 1 + lib/docs/filters/trio/clean_html.rb | 21 +++++++++ lib/docs/filters/trio/entries.rb | 21 +++++++++ lib/docs/scrapers/trio.rb | 24 ++++++++++ public/docs/docs.json | 70 ++++++++++++++++++++++++++++- 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 lib/docs/filters/trio/clean_html.rb create mode 100644 lib/docs/filters/trio/entries.rb create mode 100644 lib/docs/scrapers/trio.rb diff --git a/.gitignore b/.gitignore index 1060fcf0..27f04dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ public/fonts public/docs/**/* docs/**/* !docs/*.md +vendor diff --git a/lib/docs/filters/trio/clean_html.rb b/lib/docs/filters/trio/clean_html.rb new file mode 100644 index 00000000..5c2ef228 --- /dev/null +++ b/lib/docs/filters/trio/clean_html.rb @@ -0,0 +1,21 @@ +module Docs + class Trio + class CleanHtmlFilter < Filter + def call + @doc = at_css('div[role="main"]') + css('.section, [itemprop=articleBody]').each do |node| + node.replace node.children + end + + css('.headerlink').remove + + css('dt').each do |node| + new_node = doc.document.create_element "h3" + new_node.content = node.inner_text[0...-1] + node.replace new_node + end + doc + end + end + end +end diff --git a/lib/docs/filters/trio/entries.rb b/lib/docs/filters/trio/entries.rb new file mode 100644 index 00000000..64387d6e --- /dev/null +++ b/lib/docs/filters/trio/entries.rb @@ -0,0 +1,21 @@ +module Docs + class Trio + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').text[0...-1] + end + + def get_type + at_css('h1').text[0...-1] + end + + def additional_entries + css('.descname').each_with_object [] do |node, entries| + name = node.previous.text + node.text + id = node.parent['id'] + entries << [name, id] + end + end + end + end +end diff --git a/lib/docs/scrapers/trio.rb b/lib/docs/scrapers/trio.rb new file mode 100644 index 00000000..cf90f77d --- /dev/null +++ b/lib/docs/scrapers/trio.rb @@ -0,0 +1,24 @@ +module Docs + class Trio < UrlScraper + self.type = 'simple' + self.release = '0.11' + self.base_url = 'https://trio.readthedocs.io/en/latest/' + self.root_path = 'index.html' + self.links = { + home: 'https://trio.readthedocs.io/', + code: 'https://github.com/python-trio/trio' + } + + html_filters.push 'trio/entries', 'trio/clean_html' + + options[:attribution] = <<-HTML + HTML + options[:only_patterns] = [ + /reference-core/, + /reference-io/, + /reference-testing/, + /reference-hazmat/, + ] + + end +end diff --git a/public/docs/docs.json b/public/docs/docs.json index 0637a088..eff8727c 100644 --- a/public/docs/docs.json +++ b/public/docs/docs.json @@ -1 +1,69 @@ -[] \ No newline at end of file +[ + { + "name": "Chef", + "slug": "chef~12", + "type": "sphinx_simple", + "links": { + "home": "https://www.chef.io/", + "code": "https://github.com/chef/chef" + }, + "version": "12", + "release": "12.13", + "mtime": 1556264506, + "db_size": 7170006 + }, + { + "name": "CSS", + "slug": "css", + "type": "mdn", + "mtime": 1543099045, + "db_size": 12415944 + }, + { + "name": "DOM", + "slug": "dom", + "type": "mdn", + "mtime": 1543157862, + "db_size": 33998524 + }, + { + "name": "DOM Events", + "slug": "dom_events", + "type": "mdn", + "mtime": 1543099589, + "db_size": 1752500 + }, + { + "name": "HTML", + "slug": "html", + "type": "mdn", + "mtime": 1543097764, + "db_size": 4141596 + }, + { + "name": "HTTP", + "slug": "http", + "type": "mdn", + "mtime": 1543099392, + "db_size": 4731727 + }, + { + "name": "JavaScript", + "slug": "javascript", + "type": "mdn", + "mtime": 1543098529, + "db_size": 6462141 + }, + { + "name": "Trio", + "slug": "trio", + "type": "simple", + "links": { + "home": "https://trio.readthedocs.io/", + "code": "https://github.com/python-trio/trio" + }, + "release": "0.11", + "mtime": 1556272773, + "db_size": 736670 + } +] \ No newline at end of file From 09e47c49f1c9c3b67d2a93c90a8c7ef28208e319 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Fri, 26 Apr 2019 20:43:31 +1000 Subject: [PATCH 02/10] improve titles and pre --- Gemfile | 2 +- lib/docs/filters/trio/clean_html.rb | 18 ++++++++++++++++-- lib/docs/filters/trio/entries.rb | 23 ++++++++++++++++++++++- public/docs/docs.json | 4 ++-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 31b57064..da6e8ba0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.6.0' +ruby '2.6.2' gem 'rake' gem 'thor' diff --git a/lib/docs/filters/trio/clean_html.rb b/lib/docs/filters/trio/clean_html.rb index 5c2ef228..3d3517c2 100644 --- a/lib/docs/filters/trio/clean_html.rb +++ b/lib/docs/filters/trio/clean_html.rb @@ -10,10 +10,24 @@ module Docs css('.headerlink').remove css('dt').each do |node| - new_node = doc.document.create_element "h3" - new_node.content = node.inner_text[0...-1] + if node.parent.classes.include? 'class' + new_node = doc.document.create_element 'h2' + else + new_node = doc.document.create_element "h3" + end + new_node['id'] = node['id'] + new_node.content = node.inner_text node.replace new_node end + + css('pre').each do |node| + classes = node.parent.parent.classes + if classes.include? 'highlight-python3' + node['class'] = 'language-python' + node['data-language'] = 'python' + end + node.parent.parent.replace(node) + end doc end end diff --git a/lib/docs/filters/trio/entries.rb b/lib/docs/filters/trio/entries.rb index 64387d6e..7bd7e124 100644 --- a/lib/docs/filters/trio/entries.rb +++ b/lib/docs/filters/trio/entries.rb @@ -11,7 +11,28 @@ module Docs def additional_entries css('.descname').each_with_object [] do |node, entries| - name = node.previous.text + node.text + + name = node.text + if node.previous.classes.include? 'descclassname' + name = node.previous.text + name + end + name.strip! + + dl = node.parent.parent + + if dl.classes.include?('attribute') or dl.classes.include?('method') + parent = dl.parent.previous_element + cls = '' + if n = parent.at_css('.descname') + if n.text == "The nursery interface" + cls += "Nursery." + else + cls += n.text + '.' + end + end + name = cls + name + end + id = node.parent['id'] entries << [name, id] end diff --git a/public/docs/docs.json b/public/docs/docs.json index eff8727c..ce43dbf3 100644 --- a/public/docs/docs.json +++ b/public/docs/docs.json @@ -63,7 +63,7 @@ "code": "https://github.com/python-trio/trio" }, "release": "0.11", - "mtime": 1556272773, - "db_size": 736670 + "mtime": 1556275385, + "db_size": 746040 } ] \ No newline at end of file From 94b50f3cc303c2c3d1da72bd4c13e875f1347783 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Fri, 26 Apr 2019 21:56:05 +1000 Subject: [PATCH 03/10] improve entries and display of parameters --- lib/docs/filters/trio/clean_html.rb | 31 +++++++++++++++++++++++------ lib/docs/filters/trio/entries.rb | 7 ++++++- public/docs/docs.json | 4 ++-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/docs/filters/trio/clean_html.rb b/lib/docs/filters/trio/clean_html.rb index 3d3517c2..17542601 100644 --- a/lib/docs/filters/trio/clean_html.rb +++ b/lib/docs/filters/trio/clean_html.rb @@ -10,14 +10,24 @@ module Docs css('.headerlink').remove css('dt').each do |node| - if node.parent.classes.include? 'class' - new_node = doc.document.create_element 'h2' + node.name = 'h3' + if node.parent.classes.include? 'field-list' + node.name = 'h4' + node['style'] = 'margin: 0' + if node.text == 'Parameters' or node.text == 'Raises' + node.next_element.css('strong').each do |n| + n.name = 'code' + end + end else - new_node = doc.document.create_element "h3" + code = doc.document.create_element 'code' + if em = node.at_css('.property') + code.inner_html = "#{em.text.strip} " + em.remove + end + code.inner_html += node.inner_text.strip + node.inner_html = code end - new_node['id'] = node['id'] - new_node.content = node.inner_text - node.replace new_node end css('pre').each do |node| @@ -28,6 +38,15 @@ module Docs end node.parent.parent.replace(node) end + + css('.admonition').each do |node| + node.name = 'blockquote' + node.at_css('.admonition-title').name = 'h4' + # new_node = node.document.create_element 'blockquote' + # new_node.inner_html = node.inner_html + # node.replace new_node + end + doc end end diff --git a/lib/docs/filters/trio/entries.rb b/lib/docs/filters/trio/entries.rb index 7bd7e124..bb5207f0 100644 --- a/lib/docs/filters/trio/entries.rb +++ b/lib/docs/filters/trio/entries.rb @@ -20,9 +20,14 @@ module Docs dl = node.parent.parent - if dl.classes.include?('attribute') or dl.classes.include?('method') + if dl.classes.include?('attribute') \ + or dl.classes.include?('method') \ + or dl.classes.include?('data') parent = dl.parent.previous_element cls = '' + if n = parent.at_css('.descclassname') + cls += n.text + end if n = parent.at_css('.descname') if n.text == "The nursery interface" cls += "Nursery." diff --git a/public/docs/docs.json b/public/docs/docs.json index ce43dbf3..df09fc48 100644 --- a/public/docs/docs.json +++ b/public/docs/docs.json @@ -63,7 +63,7 @@ "code": "https://github.com/python-trio/trio" }, "release": "0.11", - "mtime": 1556275385, - "db_size": 746040 + "mtime": 1556279513, + "db_size": 757201 } ] \ No newline at end of file From 65c222011551e4fb0e35d8b966934c80e48255c8 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sat, 27 Apr 2019 10:56:43 +1000 Subject: [PATCH 04/10] clean up entries.rb --- lib/docs/filters/trio/entries.rb | 3 +-- public/docs/docs.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/docs/filters/trio/entries.rb b/lib/docs/filters/trio/entries.rb index bb5207f0..4ee6aab1 100644 --- a/lib/docs/filters/trio/entries.rb +++ b/lib/docs/filters/trio/entries.rb @@ -38,8 +38,7 @@ module Docs name = cls + name end - id = node.parent['id'] - entries << [name, id] + entries << [name, node.parent['id']] end end end diff --git a/public/docs/docs.json b/public/docs/docs.json index df09fc48..e27f82ee 100644 --- a/public/docs/docs.json +++ b/public/docs/docs.json @@ -63,7 +63,7 @@ "code": "https://github.com/python-trio/trio" }, "release": "0.11", - "mtime": 1556279513, + "mtime": 1556326478, "db_size": 757201 } ] \ No newline at end of file From 409f2c2332d73647ad7bb5f8ca6b19ea080267eb Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 28 Apr 2019 08:05:52 +1000 Subject: [PATCH 05/10] add attributions for trio --- lib/docs/scrapers/trio.rb | 7 +++++-- public/docs/docs.json | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/docs/scrapers/trio.rb b/lib/docs/scrapers/trio.rb index cf90f77d..041d6564 100644 --- a/lib/docs/scrapers/trio.rb +++ b/lib/docs/scrapers/trio.rb @@ -11,8 +11,6 @@ module Docs html_filters.push 'trio/entries', 'trio/clean_html' - options[:attribution] = <<-HTML - HTML options[:only_patterns] = [ /reference-core/, /reference-io/, @@ -20,5 +18,10 @@ module Docs /reference-hazmat/, ] + options[:attribution] = <<-HTML + © 2017-2019 Nathaniel Smith
+ Licensed under MIT and Apache2. + HTML + end end diff --git a/public/docs/docs.json b/public/docs/docs.json index e27f82ee..039aa7c2 100644 --- a/public/docs/docs.json +++ b/public/docs/docs.json @@ -63,7 +63,7 @@ "code": "https://github.com/python-trio/trio" }, "release": "0.11", - "mtime": 1556326478, - "db_size": 757201 + "mtime": 1556402796, + "db_size": 757536 } ] \ No newline at end of file From 383459c8b4519fcb67a9cbaaf613e38436cfc418 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 28 Apr 2019 09:10:01 +1000 Subject: [PATCH 06/10] add trio icons --- public/icons/docs/trio/16.png | Bin 0 -> 794 bytes public/icons/docs/trio/16@2.png | Bin 0 -> 1805 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/icons/docs/trio/16.png create mode 100644 public/icons/docs/trio/16@2.png diff --git a/public/icons/docs/trio/16.png b/public/icons/docs/trio/16.png new file mode 100644 index 0000000000000000000000000000000000000000..f1fbc1faa4bc52af5a5d8070453a3bc2a4422224 GIT binary patch literal 794 zcmV+#1LgdQP)Alu;1J|1;H~LE*5k%ilVn(qV0xJW=e^H5u^}CNJY@aLhG&2hrsUHrt5w)(}Qk>XajSe ze*Zah=FFe)pIBB|yN1{mv2%TnTubZ84NU;qzYL8gj_kS;ah~^>**RhcGs7`G2xQF0 zw$p`Q(;SahfS~hL)u{?pB~Voyk2NhBpV9kd#j)EH)0{V4xOmUCGb*wz5V=4m?_oBJ z3`ruiA9=WXwt{>KSt!lBf5p*#*Eg8i88h|GG^&A|19J|592lmn(0$Wj-J??_JtIGX zPz*De0Yk@*vFtB5l~z@Onid-PW%NMZ(vb@o<`0h8ej1?yz?Yw?M6UG*t3<3?MIa(! z3xbx#`)=d|0IxXKm=`;Et9#l0`b}oY9_pa(#o2A=VOFY&na?hkrJhge+Nvs@rUF$R zN2XN(;AQczHEVNU|ETZG-PtER%>aPxDFCEc+cSaCg7SEY_8_c~Fl=ZO)FuG{_h~4v z`Q5zi0dbSf%!e6Ns3X5TzS38B<=MII4~)2%lp<#KNmbseNUcID0DzMz)}F+Ksj3tn z9D|u!e}9;{uE8qV^DlXxpKzX6%`+6wN)XpTAQC`CI(1;6 zA5060sG1zVA<$|N6%a8K5&kBh^@3k|l|$HXu-St@DYw}3sxSy`A^rn{h(3czh$x$g z0dRrOY@n42@y$w$fX@eGy`j literal 0 HcmV?d00001 diff --git a/public/icons/docs/trio/16@2.png b/public/icons/docs/trio/16@2.png new file mode 100644 index 0000000000000000000000000000000000000000..afc8808184c47bde5366ae395d4e5a56bcff8056 GIT binary patch literal 1805 zcmV+o2lDudP)RFRt&*-pi=$xNRLuOt7M-{VSdg_Y{DUqT0R|Il z`DlC3`|OYV(O*mHfU%Q%?=SZ~=e*DJex2WYi2q@fMLQyX;OOnL;3h|&jyQI|S6}hP zrRd=0g3np;%DtppPjWIykOb-A$o+J9`KzNRn)WtV5B^^W6hF1OlyIFS1CmG)a7iKr zoI6P1hdb*kc8{gYT@C^B_6x}Z$sidZK@w!4ueX~e`^&u5uRnCf2>_U)B&dWWk+AFs zQ}_J4`R=y#j9_3x*_v%nTu}modPV|D>XXcpWTsqw2LQPM{s!<%K&5NmU!=@PZ1Aj4&m{%H z-3*{}r2b$m@Umz}M15!f4B-JuS&(u8TVO&SfIk47pIn>B=6nD-fEpnFYrukA0h|S} zF36bpo6kF2?UFpu-*3x4I&R`WXLL1GmjSFvES#0xvbVYV__=Fx7s+f#%KGqO z1-sQ-X3Kd5N~7CvoVR*gPw6vTKPp|dr8uEDf5_PhPY{ir(P#_+_HA7D0-&7$ZwxE! zj#dt&r}chMvQI}#PRJ@so_clOFanVneqL?z!!U)tB;3)4!l@> z0KkTk1ZFO4N|SWYu$Pk!k%8=*+O2sW{-!PEzt1|=pN0F{mqNk>027cf91vjY z83|PQSVMU_BRw-7YkW??G(rNH<)NvN^5f?tLAbaR4FCZTew-rU)6>4;&1W_4E5*rk znUX+=lORhar~rWcEM#GU4{Vdbf>uD$nbv=!Mnx;SAd?#TGAy)`!ykzMF z4+-ud6?<#;@b95ASWh8}y(1K)V1;BJgI{#^vQB z!xA2M{B+YTW~d-|7m06z_&UKaMYQBj!0OKEkIzLcz%luhqm#}nNVzZW0`GGDe(Tkn z04Bx7+&&uU%wOdf8-# z&>`Wo*eRtE%sGZ-$^9oB0PI}* zz;3~!A?#2Ip~aDtL!09Le;6o5C=L*xqj%1|OS(_!m`{f19O!s7E&JL%sapSV?f2^l zs{-_ogy<}!hLh@h9CX>_`9N`xoG0@n+dx-GxLjkqYGlAUQCLgd}aLg zN77HXw^w=qxZ`InWdu5saZM#+@)?io0La(GV6CIoL9ED58$9C`qz_so5~>0K{L=^N z-S;CJwTr$P71gxX5UdA~$>B+L0N}P5BF(#>t2{ENc1wu^KMb7ucT~QVarE>!JpA^O z5V(8wM4DgP9jzPyE}|_@j*r(pw617XYikg5vmiG~(qW1{yPjV%>@pgmD-Z#ZY5R^% ziXA_bBRZD`@i4%Z@7Leo1~8Rimwh?C(3rbw>r{~YNk%{oWCYsPZ^27BC$qM{v;Lm` vk?XHG0RULA=Jn~4zX}oU>5NwPjkWeaRYIemAL3r700000NkvXXu0mjf?}1uy literal 0 HcmV?d00001 From 46f7a32522fc2d0c4ebf3a63fef106841abf453b Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 28 Apr 2019 09:16:14 +1000 Subject: [PATCH 07/10] add trio SOURCE icon --- public/icons/docs/trio/SOURCE | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/icons/docs/trio/SOURCE diff --git a/public/icons/docs/trio/SOURCE b/public/icons/docs/trio/SOURCE new file mode 100644 index 00000000..52a2abea --- /dev/null +++ b/public/icons/docs/trio/SOURCE @@ -0,0 +1 @@ +https://github.com/python-trio/trio/blob/37de153f858e29df3a19db9fffcd0fb3f2308951/logo/logo-transparent-no-text.svg From 32a83f3e447648cbe84cc9fb074ef39a9edb226b Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 28 Apr 2019 09:26:23 +1000 Subject: [PATCH 08/10] fix attribution --- lib/docs/scrapers/trio.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docs/scrapers/trio.rb b/lib/docs/scrapers/trio.rb index 041d6564..8eb7cd26 100644 --- a/lib/docs/scrapers/trio.rb +++ b/lib/docs/scrapers/trio.rb @@ -19,7 +19,7 @@ module Docs ] options[:attribution] = <<-HTML - © 2017-2019 Nathaniel Smith
+ © 2017-2019 Nathaniel J. Smith
Licensed under MIT and Apache2. HTML From 737369cf09592e94a850bfc13b44a4810f7a3d16 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 28 Apr 2019 16:46:10 +1000 Subject: [PATCH 09/10] fix gemfile i changed it manually earlier because I have 2.6.2 install on my machine --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index da6e8ba0..31b57064 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.6.2' +ruby '2.6.0' gem 'rake' gem 'thor' From 3a6a158f14501a41e9cee613f31ef65be0cde44c Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Sat, 17 Aug 2019 15:16:57 +0200 Subject: [PATCH 10/10] trio: finish scraper and filters --- .gitignore | 1 - .../javascripts/templates/pages/about_tmpl.coffee | 5 +++++ lib/docs/filters/trio/clean_html.rb | 12 ++++++++---- lib/docs/filters/trio/entries.rb | 4 +++- lib/docs/scrapers/trio.rb | 12 ++++++++---- public/icons/docs/trio/{16@2.png => 16@2x.png} | Bin 6 files changed, 24 insertions(+), 10 deletions(-) rename public/icons/docs/trio/{16@2.png => 16@2x.png} (100%) diff --git a/.gitignore b/.gitignore index 53bbb745..f89ecb61 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ public/fonts public/docs/**/* docs/**/* !docs/*.md -vendor diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index c3c0fdec..5fc27d3c 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -721,6 +721,11 @@ credits = [ '2018 HashiCorp', 'MPL', 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md' + ], [ + 'Trio', + '2017 Nathaniel J. Smith', + 'MIT', + 'https://raw.githubusercontent.com/python-trio/trio/master/LICENSE.MIT' ], [ 'Twig', '2009-2018 The Twig Team', diff --git a/lib/docs/filters/trio/clean_html.rb b/lib/docs/filters/trio/clean_html.rb index 17542601..00919535 100644 --- a/lib/docs/filters/trio/clean_html.rb +++ b/lib/docs/filters/trio/clean_html.rb @@ -3,6 +3,7 @@ module Docs class CleanHtmlFilter < Filter def call @doc = at_css('div[role="main"]') + css('.section, [itemprop=articleBody]').each do |node| node.replace node.children end @@ -11,9 +12,11 @@ module Docs css('dt').each do |node| node.name = 'h3' + if node.parent.classes.include? 'field-list' node.name = 'h4' node['style'] = 'margin: 0' + if node.text == 'Parameters' or node.text == 'Raises' node.next_element.css('strong').each do |n| n.name = 'code' @@ -21,30 +24,31 @@ module Docs end else code = doc.document.create_element 'code' + if em = node.at_css('.property') code.inner_html = "#{em.text.strip} " em.remove end + code.inner_html += node.inner_text.strip node.inner_html = code end end css('pre').each do |node| + node.content = node.content.strip + classes = node.parent.parent.classes if classes.include? 'highlight-python3' - node['class'] = 'language-python' node['data-language'] = 'python' end + node.parent.parent.replace(node) end css('.admonition').each do |node| node.name = 'blockquote' node.at_css('.admonition-title').name = 'h4' - # new_node = node.document.create_element 'blockquote' - # new_node.inner_html = node.inner_html - # node.replace new_node end doc diff --git a/lib/docs/filters/trio/entries.rb b/lib/docs/filters/trio/entries.rb index 4ee6aab1..7c6aa76b 100644 --- a/lib/docs/filters/trio/entries.rb +++ b/lib/docs/filters/trio/entries.rb @@ -11,7 +11,6 @@ module Docs def additional_entries css('.descname').each_with_object [] do |node, entries| - name = node.text if node.previous.classes.include? 'descclassname' name = node.previous.text + name @@ -25,9 +24,11 @@ module Docs or dl.classes.include?('data') parent = dl.parent.previous_element cls = '' + if n = parent.at_css('.descclassname') cls += n.text end + if n = parent.at_css('.descname') if n.text == "The nursery interface" cls += "Nursery." @@ -35,6 +36,7 @@ module Docs cls += n.text + '.' end end + name = cls + name end diff --git a/lib/docs/scrapers/trio.rb b/lib/docs/scrapers/trio.rb index 8eb7cd26..b8719bea 100644 --- a/lib/docs/scrapers/trio.rb +++ b/lib/docs/scrapers/trio.rb @@ -1,8 +1,8 @@ module Docs class Trio < UrlScraper self.type = 'simple' - self.release = '0.11' - self.base_url = 'https://trio.readthedocs.io/en/latest/' + self.release = '0.12.1' + self.base_url = 'https://trio.readthedocs.io/en/v0.12.1/' self.root_path = 'index.html' self.links = { home: 'https://trio.readthedocs.io/', @@ -19,9 +19,13 @@ module Docs ] options[:attribution] = <<-HTML - © 2017-2019 Nathaniel J. Smith
- Licensed under MIT and Apache2. + © 2017 Nathaniel J. Smith
+ Licensed under the MIT License. HTML + def get_latest_version(opts) + doc = fetch_doc('https://trio.readthedocs.io/en/stable/', opts) + doc.at_css('.rst-other-versions a[href^="/en/v"]').content[1..-1] + end end end diff --git a/public/icons/docs/trio/16@2.png b/public/icons/docs/trio/16@2x.png similarity index 100% rename from public/icons/docs/trio/16@2.png rename to public/icons/docs/trio/16@2x.png