mirror of https://github.com/freeCodeCamp/devdocs
commit
6e8441dc1d
@ -1,41 +1,26 @@
|
|||||||
module Docs
|
module Docs
|
||||||
class Typescript
|
class Typescript
|
||||||
class EntriesFilter < Docs::EntriesFilter
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
|
||||||
def get_name
|
def get_name
|
||||||
name = at_css('h1').content.strip
|
return 'Typescript' if current_url == root_url
|
||||||
name.sub! ' and ', ' & '
|
return at_css('h2').content
|
||||||
name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_type
|
def get_type
|
||||||
return 'Declaration Files' if subpath.include?('declaration-files')
|
name
|
||||||
return 'Project Configuration' if slug == 'handbook/configuring-watch'
|
|
||||||
type = at_css('#main-nav a.active').ancestors('.panel').first.at_css('> a').content
|
|
||||||
type = name if type == 'Handbook'
|
|
||||||
type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SKIP_ENTRIES = ['Introduction', 'A note', 'A Note', ', and', 'Techniques', ' Concepts', 'Hello World', 'Working with', 'Our ', 'Implementing ', 'Difference between', 'Basic', 'sample', 'Questions', 'Example', 'Export as close', 'Red Flags', 'First steps', 'Pitfalls', 'Well-known', 'Starting out', 'Comparing ', 'Do not', 'Trade-off', ' vs', 'Overview', 'Related', 'Table of contents']
|
|
||||||
|
|
||||||
def additional_entries
|
def additional_entries
|
||||||
return [] unless slug.start_with?('handbook')
|
entries = []
|
||||||
return [] if slug.include?('release-notes')
|
|
||||||
return [] if slug == 'handbook/writing-definition-files'
|
|
||||||
|
|
||||||
css('.post-content h1, .post-content h2').each_with_object [] do |node, entries|
|
css('h2').each do |node|
|
||||||
next if node.next_element.try(:name) == 'h2'
|
entries << [node.content, node['id'], name]
|
||||||
node.css('.anchor-hash').remove
|
|
||||||
name = node.content.strip
|
|
||||||
next if name.length > 40
|
|
||||||
next if name == self.name || SKIP_ENTRIES.any? { |str| name.include?(str) }
|
|
||||||
name.remove! %r{\A#{self.name.remove(/s\z/)}s? }
|
|
||||||
name.sub! 'for..of', 'for...of'
|
|
||||||
name.remove! 'Symbol.'
|
|
||||||
name.remove! '/// '
|
|
||||||
name.prepend "#{self.name}: "
|
|
||||||
entries << [name, node['id']]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
entries
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue