Skip to content

Commit b7075dd

Browse files
committed
Implement working crawling and section building for salt
1 parent 9d60cc8 commit b7075dd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

lib/docs/filters/salt_stack/clean_html.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Docs
22
class SaltStack
33
class CleanHtmlFilter < Filter
44
def call
5+
css('.headerlink').remove
6+
57
doc
68
end
79
end

lib/docs/filters/salt_stack/entries.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
module Docs
22
class SaltStack
33
class EntriesFilter < Docs::EntriesFilter
4+
SALT_REF_RGX = /salt\.([^\.]+)\.([^\s]+)/
5+
46
def get_name
5-
at_css('h1').content
7+
header = at_css('h1').content
8+
9+
ref_match = SALT_REF_RGX.match(header)
10+
if ref_match
11+
ns, mod = ref_match.captures
12+
"#{ns}.#{mod}"
13+
else
14+
header
15+
end
616
end
717

818
def get_type
9-
'TODO'
19+
type, _ = slug.split('/', 2)
20+
type
21+
end
22+
23+
def include_default_entry?
24+
!subpath.end_with?('index.html')
1025
end
1126
end
1227
end

lib/docs/scrapers/salt_stack.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
module Docs
22
class SaltStack < UrlScraper
3+
self.type = 'salt_stack'
34
self.release = '2018.3.2'
45
self.base_url = 'https://docs.saltstack.com/en/latest/ref/'
56

6-
html_filters.push 'salt_stack/entries', 'salt_stack/clean_html'
7+
html_filters.push 'salt_stack/clean_html', 'salt_stack/entries'
8+
9+
options[:only_patterns] = [
10+
%r{[^/]+/all/}
11+
]
712

813
options[:container] = '.body-content'
914

0 commit comments

Comments
 (0)