Skip to content

Commit 09e47c4

Browse files
committed
improve titles and pre
1 parent cda737c commit 09e47c4

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source 'https://rubygems.org'
2-
ruby '2.6.0'
2+
ruby '2.6.2'
33

44
gem 'rake'
55
gem 'thor'

lib/docs/filters/trio/clean_html.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,24 @@ def call
1010
css('.headerlink').remove
1111

1212
css('dt').each do |node|
13-
new_node = doc.document.create_element "h3"
14-
new_node.content = node.inner_text[0...-1]
13+
if node.parent.classes.include? 'class'
14+
new_node = doc.document.create_element 'h2'
15+
else
16+
new_node = doc.document.create_element "h3"
17+
end
18+
new_node['id'] = node['id']
19+
new_node.content = node.inner_text
1520
node.replace new_node
1621
end
22+
23+
css('pre').each do |node|
24+
classes = node.parent.parent.classes
25+
if classes.include? 'highlight-python3'
26+
node['class'] = 'language-python'
27+
node['data-language'] = 'python'
28+
end
29+
node.parent.parent.replace(node)
30+
end
1731
doc
1832
end
1933
end

lib/docs/filters/trio/entries.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,28 @@ def get_type
1111

1212
def additional_entries
1313
css('.descname').each_with_object [] do |node, entries|
14-
name = node.previous.text + node.text
14+
15+
name = node.text
16+
if node.previous.classes.include? 'descclassname'
17+
name = node.previous.text + name
18+
end
19+
name.strip!
20+
21+
dl = node.parent.parent
22+
23+
if dl.classes.include?('attribute') or dl.classes.include?('method')
24+
parent = dl.parent.previous_element
25+
cls = ''
26+
if n = parent.at_css('.descname')
27+
if n.text == "The nursery interface"
28+
cls += "Nursery."
29+
else
30+
cls += n.text + '.'
31+
end
32+
end
33+
name = cls + name
34+
end
35+
1536
id = node.parent['id']
1637
entries << [name, id]
1738
end

public/docs/docs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"code": "https://github.com/python-trio/trio"
6464
},
6565
"release": "0.11",
66-
"mtime": 1556272773,
67-
"db_size": 736670
66+
"mtime": 1556275385,
67+
"db_size": 746040
6868
}
6969
]

0 commit comments

Comments
 (0)