mirror of https://github.com/freeCodeCamp/devdocs
Godot 4.2 was released on Nov 2023. Since v3.5, godot upstream docs have used some new HTML layouts and file structures. Since older versions still need to be scrapable, this introduces another set of versioned filters for godot. This change also makes small changes to the filters to handle the current website markup for the previous godot doc versions. The @gdscript and @globalscope entries can't currently be browsed, because of an encoding mismatch between the frontend and backend; I've identified a possible fix for that but will PR that separately.pull/2201/head
parent
62e2723ca2
commit
7026706256
@ -0,0 +1,27 @@
|
|||||||
|
module Docs
|
||||||
|
class Godot
|
||||||
|
class CleanHtmlV3Filter < Filter
|
||||||
|
def call
|
||||||
|
if root_page?
|
||||||
|
at_css('h1').content = 'Godot Engine'
|
||||||
|
at_css('.admonition.caution').remove
|
||||||
|
end
|
||||||
|
|
||||||
|
css('ul[id].simple li:first-child:last-child').each do |node|
|
||||||
|
heading = Nokogiri::XML::Node.new 'h3', doc.document
|
||||||
|
heading['id'] = node.parent['id']
|
||||||
|
heading.children = node.children
|
||||||
|
node.parent.before(heading).remove
|
||||||
|
end
|
||||||
|
|
||||||
|
css('h3 strong').each do |node|
|
||||||
|
node.before(node.children).remove
|
||||||
|
end
|
||||||
|
|
||||||
|
css('a.reference').remove_attr('class')
|
||||||
|
|
||||||
|
doc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,39 @@
|
|||||||
|
module Docs
|
||||||
|
class Godot
|
||||||
|
class EntriesV3Filter < Docs::EntriesFilter
|
||||||
|
def get_name
|
||||||
|
name = at_css('h1').content
|
||||||
|
name.remove! "\u{00B6}" # Remove the pilcrow
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_type
|
||||||
|
if slug.start_with?('getting_started')
|
||||||
|
# Getting started sections are different even between different minor
|
||||||
|
# versions from v3 so we're programmatically generating them instead.
|
||||||
|
"Getting started: " + slug.split('/')[1].tr_s('_', ' ').capitalize
|
||||||
|
else
|
||||||
|
name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def additional_entries
|
||||||
|
return [] unless slug.start_with?('classes')
|
||||||
|
|
||||||
|
css('.simple[id]').each_with_object [] do |node, entries|
|
||||||
|
name = node.at_css('strong').content
|
||||||
|
next if name == self.name
|
||||||
|
name.prepend "#{self.name}."
|
||||||
|
name << '()'
|
||||||
|
entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_default_entry?
|
||||||
|
return false if subpath.start_with?('getting_started') && subpath.end_with?('index.html')
|
||||||
|
return false if subpath == 'classes/index.html'
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue