Showing the changes to lib/docs (3 of 9 files). Show all
Unified · Split
| @@ -0,0 +1,19 @@ | ||
| 1 | +module Docs | |
| 2 | + class Zig | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + at_css('main').prepend_child at_css('h1') | |
| 6 | + @doc = at_css('main') | |
| 7 | + css('a.hdr').remove | |
| 8 | + css('h1, h2, h3').each do |node| | |
| 9 | + node.content = node.content | |
| 10 | + end | |
| 11 | + css('pre > code').each do |node| | |
| 12 | + node.parent['data-language'] = 'zig' | |
| 13 | + node.parent.content = node.parent.content | |
| 14 | + end | |
| 15 | + doc | |
| 16 | + end | |
| 17 | + end | |
| 18 | + end | |
| 19 | +end | |
| @@ -0,0 +1,25 @@ | ||
| 1 | +module Docs | |
| 2 | + class Zig | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def additional_entries | |
| 5 | + entries = [] | |
| 6 | + type = nil | |
| 7 | + subtype = nil | |
| 8 | + | |
| 9 | + css('h2, h3').each do |node| | |
| 10 | + if node.name == 'h2' && node['id'] | |
| 11 | + type = node.content.gsub(/ §/, '') | |
| 12 | + subtype = nil | |
| 13 | + entries << [type, node['id'], type] | |
| 14 | + elsif node.name == 'h3' && node['id'] | |
| 15 | + subtype = node.content.gsub(/ §/, '') | |
| 16 | + name = "#{type}: #{subtype}" | |
| 17 | + entries << [name, node['id'], type] | |
| 18 | + end | |
| 19 | + end | |
| 20 | + | |
| 21 | + entries | |
| 22 | + end | |
| 23 | + end | |
| 24 | + end | |
| 25 | +end | |
| @@ -0,0 +1,24 @@ | ||
| 1 | +module Docs | |
| 2 | + class Zig < UrlScraper | |
| 3 | + self.name = 'Zig' | |
| 4 | + self.type = 'simple' | |
| 5 | + self.release = '0.9.0' | |
| 6 | + self.base_url = 'https://ziglang.org/documentation/0.9.0/' | |
| 7 | + self.links = { | |
| 8 | + home: 'https://ziglang.org/', | |
| 9 | + code: 'https://github.com/ziglang/zig' | |
| 10 | + } | |
| 11 | + | |
| 12 | + html_filters.push 'zig/entries', 'zig/clean_html' | |
| 13 | + | |
| 14 | + options[:follow_links] = false | |
| 15 | + options[:attribution] = <<-HTML | |
| 16 | + © 2015–2021, Zig contributors | |
| 17 | + HTML | |
| 18 | + | |
| 19 | + def get_latest_version(opts) | |
| 20 | + tags = get_github_tags('ziglang', 'zig', opts) | |
| 21 | + tags[0]['name'] | |
| 22 | + end | |
| 23 | + end | |
| 24 | +end | |