mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
improve entries and display of parameters
This commit is contained in:
parent
09e47c49f1
commit
94b50f3cc3
3 changed files with 33 additions and 9 deletions
|
@ -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>#{em.text.strip}</em> "
|
||||
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
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
"code": "https://github.com/python-trio/trio"
|
||||
},
|
||||
"release": "0.11",
|
||||
"mtime": 1556275385,
|
||||
"db_size": 746040
|
||||
"mtime": 1556279513,
|
||||
"db_size": 757201
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue