History

Add documentation for Spring Boot

Aymen Hosni committed 6 years ago

Commit f4b66061 parent 4eb4bfe7 files · +68 −-2Browse files

Showing the changes to lib/docs (3 of 7 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/spring_boot/clean_html.rb +15 −0
  2. lib/docs/filters/spring_boot/entries.rb +21 −0
  3. lib/docs/scrapers/spring_boot.rb +28 −0
lib/docs/filters/spring_boot/clean_html.rb+15−0
@@ -0,0 +1,15 @@
1+module Docs
2+ class SpringBoot
3+ class CleanHtmlFilter < Filter
4+ def call
5+
6+ css('pre').each do |node|
7+ language = node.children.first['data-lang'] if node.children.first.name == 'code'
8+ node['data-language'] = language
9+ end
10+
11+ doc
12+ end
13+ end
14+ end
15+end
lib/docs/filters/spring_boot/entries.rb+21−0
@@ -0,0 +1,21 @@
1+module Docs
2+ class SpringBoot
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def get_type
6+ slug.gsub('-', ' ').capitalize
7+ end
8+
9+ def additional_entries
10+ css('td a[href], li a[href]').each_with_object [] do |node, entries|
11+ next if root_page?
12+ next if node['href'].start_with?('http')
13+ name = node.content.strip
14+ id = node['href'].remove('#')
15+ next if id.blank?
16+ entries << [name, id, get_type]
17+ end
18+ end
19+ end
20+ end
21+end
lib/docs/scrapers/spring_boot.rb+28−0
@@ -0,0 +1,28 @@
1+module Docs
2+ class SpringBoot < UrlScraper
3+ self.name = 'Spring Boot'
4+ self.slug = 'spring_boot'
5+ self.type = 'simple'
6+ self.release = '2.3.0.RELEASE'
7+ self.base_url = 'https://docs.spring.io/spring-boot/docs/current/reference/html/'
8+ self.root_path = "index.html"
9+ self.links = {
10+ home: 'https://spring.io/',
11+ code: 'https://github.com/spring-projects/spring-boot'
12+ }
13+
14+ html_filters.push 'spring_boot/entries', 'spring_boot/clean_html'
15+
16+ options[:skip_patterns] = [/legal/]
17+
18+ options[:attribution] = <<-HTML
19+ Copyright &copy; 2002 - 2020 Pivotal, Inc. All Rights Reserved.
20+ HTML
21+
22+ def get_latest_version(opts)
23+ doc = fetch_doc('https://docs.spring.io/spring-boot/docs/current/reference/html/legal.html', opts)
24+ table = doc.at_css('#content p').inner_text
25+ end
26+
27+ end
28+end