Add the trio documentation
Unified · Split
| @@ -721,6 +721,11 @@ credits = [ · 720 unmodified lines | |||
| 721 | '2018 HashiCorp', | 721 | '2018 HashiCorp', |
| 722 | 'MPL', | 722 | 'MPL', |
| 723 | 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md' | 723 | 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md' |
| 724 | ], [ | ||
| 725 | 'Trio', | ||
| 726 | '2017 Nathaniel J. Smith', | ||
| 727 | 'MIT', | ||
| 728 | 'https://raw.githubusercontent.com/python-trio/trio/master/LICENSE.MIT' | ||
| 724 | ], [ | 729 | ], [ |
| 725 | 'Twig', | 730 | 'Twig', |
| 726 | '2009-2018 The Twig Team', | 731 | '2009-2018 The Twig Team', |
| @@ -0,0 +1,58 @@ | |||
| 1 | module Docs | ||
| 2 | class Trio | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | @doc = at_css('div[role="main"]') | ||
| 6 | |||
| 7 | css('.section, [itemprop=articleBody]').each do |node| | ||
| 8 | node.replace node.children | ||
| 9 | end | ||
| 10 | |||
| 11 | css('.headerlink').remove | ||
| 12 | |||
| 13 | css('dt').each do |node| | ||
| 14 | node.name = 'h3' | ||
| 15 | |||
| 16 | if node.parent.classes.include? 'field-list' | ||
| 17 | node.name = 'h4' | ||
| 18 | node['style'] = 'margin: 0' | ||
| 19 | |||
| 20 | if node.text == 'Parameters' or node.text == 'Raises' | ||
| 21 | node.next_element.css('strong').each do |n| | ||
| 22 | n.name = 'code' | ||
| 23 | end | ||
| 24 | end | ||
| 25 | else | ||
| 26 | code = doc.document.create_element 'code' | ||
| 27 | |||
| 28 | if em = node.at_css('.property') | ||
| 29 | code.inner_html = "<em>#{em.text.strip}</em> " | ||
| 30 | em.remove | ||
| 31 | end | ||
| 32 | |||
| 33 | code.inner_html += node.inner_text.strip | ||
| 34 | node.inner_html = code | ||
| 35 | end | ||
| 36 | end | ||
| 37 | |||
| 38 | css('pre').each do |node| | ||
| 39 | node.content = node.content.strip | ||
| 40 | |||
| 41 | classes = node.parent.parent.classes | ||
| 42 | if classes.include? 'highlight-python3' | ||
| 43 | node['data-language'] = 'python' | ||
| 44 | end | ||
| 45 | |||
| 46 | node.parent.parent.replace(node) | ||
| 47 | end | ||
| 48 | |||
| 49 | css('.admonition').each do |node| | ||
| 50 | node.name = 'blockquote' | ||
| 51 | node.at_css('.admonition-title').name = 'h4' | ||
| 52 | end | ||
| 53 | |||
| 54 | doc | ||
| 55 | end | ||
| 56 | end | ||
| 57 | end | ||
| 58 | end | ||
| @@ -0,0 +1,48 @@ | |||
| 1 | module Docs | ||
| 2 | class Trio | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | at_css('h1').text[0...-1] | ||
| 6 | end | ||
| 7 | |||
| 8 | def get_type | ||
| 9 | at_css('h1').text[0...-1] | ||
| 10 | end | ||
| 11 | |||
| 12 | def additional_entries | ||
| 13 | css('.descname').each_with_object [] do |node, entries| | ||
| 14 | name = node.text | ||
| 15 | if node.previous.classes.include? 'descclassname' | ||
| 16 | name = node.previous.text + name | ||
| 17 | end | ||
| 18 | name.strip! | ||
| 19 | |||
| 20 | dl = node.parent.parent | ||
| 21 | |||
| 22 | if dl.classes.include?('attribute') \ | ||
| 23 | or dl.classes.include?('method') \ | ||
| 24 | or dl.classes.include?('data') | ||
| 25 | parent = dl.parent.previous_element | ||
| 26 | cls = '' | ||
| 27 | |||
| 28 | if n = parent.at_css('.descclassname') | ||
| 29 | cls += n.text | ||
| 30 | end | ||
| 31 | |||
| 32 | if n = parent.at_css('.descname') | ||
| 33 | if n.text == "The nursery interface" | ||
| 34 | cls += "Nursery." | ||
| 35 | else | ||
| 36 | cls += n.text + '.' | ||
| 37 | end | ||
| 38 | end | ||
| 39 | |||
| 40 | name = cls + name | ||
| 41 | end | ||
| 42 | |||
| 43 | entries << [name, node.parent['id']] | ||
| 44 | end | ||
| 45 | end | ||
| 46 | end | ||
| 47 | end | ||
| 48 | end | ||
| @@ -0,0 +1,31 @@ | |||
| 1 | module Docs | ||
| 2 | class Trio < UrlScraper | ||
| 3 | self.type = 'simple' | ||
| 4 | self.release = '0.12.1' | ||
| 5 | self.base_url = 'https://trio.readthedocs.io/en/v0.12.1/' | ||
| 6 | self.root_path = 'index.html' | ||
| 7 | self.links = { | ||
| 8 | home: 'https://trio.readthedocs.io/', | ||
| 9 | code: 'https://github.com/python-trio/trio' | ||
| 10 | } | ||
| 11 | |||
| 12 | html_filters.push 'trio/entries', 'trio/clean_html' | ||
| 13 | |||
| 14 | options[:only_patterns] = [ | ||
| 15 | /reference-core/, | ||
| 16 | /reference-io/, | ||
| 17 | /reference-testing/, | ||
| 18 | /reference-hazmat/, | ||
| 19 | ] | ||
| 20 | |||
| 21 | options[:attribution] = <<-HTML | ||
| 22 | © 2017 Nathaniel J. Smith<br> | ||
| 23 | Licensed under the MIT License. | ||
| 24 | HTML | ||
| 25 | |||
| 26 | def get_latest_version(opts) | ||
| 27 | doc = fetch_doc('https://trio.readthedocs.io/en/stable/', opts) | ||
| 28 | doc.at_css('.rst-other-versions a[href^="/en/v"]').content[1..-1] | ||
| 29 | end | ||
| 30 | end | ||
| 31 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://github.com/python-trio/trio/blob/37de153f858e29df3a19db9fffcd0fb3f2308951/logo/logo-transparent-no-text.svg | ||