History

Merge branch 'main' into update-zig-to-0.12

Simon Legner committed 2 years ago

Commit 08fc2202 parents 4742412 6512f2930 files · +226 −14Browse files

Showing the changes to lib/docs (17 of 30 files). Show all

Unified · Split

17 files
  1. lib/docs/filters/click/entries.rb +58 −0
  2. lib/docs/filters/click/pre_clean_html.rb +11 −0
  3. lib/docs/filters/elisp/entries.rb +1 −1
  4. lib/docs/filters/gtk/entries.rb +1 −1
  5. lib/docs/filters/kubectl/entries.rb +1 −1
  6. lib/docs/filters/nextjs/clean_html.rb +30 −0
  7. lib/docs/filters/nextjs/entries.rb +43 −0
  8. lib/docs/scrapers/click.rb +30 −0
  9. lib/docs/scrapers/crystal.rb +1 −1
  10. lib/docs/scrapers/docker.rb +1 −1
  11. lib/docs/scrapers/nextjs.rb +26 −0
  12. lib/docs/scrapers/node.rb +2 −2
  13. lib/docs/scrapers/octave.rb +1 −1
  14. lib/docs/scrapers/phalcon.rb +2 −2
  15. lib/docs/scrapers/sanctuary_type_classes.rb +1 −1
  16. lib/docs/scrapers/vite.rb +1 −1
  17. lib/docs/scrapers/vue.rb +1 −1
lib/docs/filters/click/entries.rb+58−0
@@ -0,0 +1,58 @@
1+module Docs
2+ class Click
3+ class EntriesFilter < Docs::EntriesFilter
4+ TYPE_BY_SLUG = {}
5+
6+ def call
7+ if root_page?
8+ css('section').each do |node|
9+ next if ['documentation', 'api-reference'].include?(node['id'])
10+ type = node.at_css('h2').content.strip
11+ node.css('li > a').each do |toclink|
12+ slug = toclink['href'].split('/')[-2]
13+ TYPE_BY_SLUG[slug] = type
14+ end
15+ end
16+ end
17+ super
18+ end
19+
20+ def get_name
21+ return at_css('h1').content.strip
22+ end
23+
24+ def get_type
25+ TYPE_BY_SLUG[slug.split('/').first] || at_css('h1').content.strip
26+ end
27+
28+ def include_default_entry?
29+ TYPE_BY_SLUG.include?(slug.split('/').first)
30+ end
31+
32+ def additional_entries
33+ return [] if root_page? || TYPE_BY_SLUG.include?(slug.split('/').first)
34+
35+ if slug == 'api/'
36+ entries = []
37+ doc.css('> section').each do |section|
38+ title = section.at_css('h2').content.strip
39+ section.css('dl.py > dt[id]').each do |dt|
40+ name = dt['id'].split('.')[1..].join('.')
41+ name << '()' if dt.parent.classes.intersect?(['function', 'method', 'classmethod', 'staticmethod'])
42+ entries << [name, dt['id'], title]
43+ end
44+ end
45+ return entries
46+ end
47+
48+ (doc.css('> section') || []).map do |section|
49+ title = section.at_css('h2').content.strip
50+ [title, section['id']]
51+ end
52+ end
53+
54+ private
55+
56+ end
57+ end
58+end
lib/docs/filters/click/pre_clean_html.rb+11−0
@@ -0,0 +1,11 @@
1+module Docs
2+ class Click
3+ class PreCleanHtmlFilter < Filter
4+ def call
5+ # Remove ¶ character from headers
6+ css('.headerlink').remove
7+ doc
8+ end
9+ end
10+ end
11+end
lib/docs/filters/elisp/entries.rb+1−1
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
22 class Elisp
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
5− # remove numbers at the beginnig
5+ # remove numbers at the beginning
66 name = at_css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').content.slice(/[[:alpha:]]...*/)
77
88 # remove 'Appendix' word
lib/docs/filters/gtk/entries.rb+1−1
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
44 # The GTK documentation paths are "flat" and while the contents of each
55 # page provides a way to determine the direct parent relationship, we
66 # really need a full hierarchy of pages *a priori* to be able to fully
7− # categorize all pages and entries. So we're going to recursivly generate
7+ # categorize all pages and entries. So we're going to recursively generate
88 # a full map of page -> parent relationships from the table of contents...
99 PARENT_BY_PATH = {}
1010
lib/docs/filters/kubectl/entries.rb+1−1
@@ -15,7 +15,7 @@ module Docs · 14 unmodified lines
1515 group = 'kubectl'
1616 commands = css('h1').to_a()
1717 commands.map do |node|
18− # handle titles differnetly by converting them into sidebar groups (types)
18+ # handle titles differently by converting them into sidebar groups (types)
1919 new_group = at_css("##{node['id']} > strong")
2020 if new_group
2121 group = new_group.content.titleize
lib/docs/filters/nextjs/clean_html.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Nextjs
3+ class CleanHtmlFilter < Filter
4+ def call
5+ @doc = at_css('.prose')
6+
7+ css('.zola-anchor').remove
8+ doc.prepend_child("<h1>NextJS2</h1>") if root_page?
9+ css('div:contains("NEWS:")').remove
10+ css('h2:contains("sponsors"), #sponsor-table').remove
11+ css('div.sticky').remove #remove the floating menu
12+ css('div.-mt-4').remove #remove the navigation line
13+ css('footer').remove
14+ css('div.feedback_inlineTriggerWrapper__o7yUx').remove
15+ css('header').remove #remove links from the top of the page
16+ css('nav').remove
17+
18+ css('h1, h2, h3, h4').each { |node| node.content = node.content }
19+
20+ css('pre > code').each do |node|
21+ node.parent['data-language'] = 'typescript'
22+ node.parent.content = node.parent.content
23+ end
24+ css('div[class^="code-block_header"]').remove
25+
26+ doc
27+ end
28+ end
29+ end
30+end
lib/docs/filters/nextjs/entries.rb+43−0
@@ -0,0 +1,43 @@
1+module Docs
2+ class Nextjs
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ name = at_css('h1').content
6+ name.strip!
7+ #name
8+ subpath_items = subpath.split('/', -1)
9+ if subpath_items.length >= 5
10+ subpath_items[3].capitalize + ': ' + name # e.g. Routing: Defining Routes
11+ else
12+ name
13+ end
14+ end
15+
16+ def get_type
17+ if slug.start_with?('architecture')
18+ 'Architecture'
19+ elsif slug.start_with?('community')
20+ 'Community'
21+ elsif slug.start_with?('getting-started')
22+ 'Getting Started'
23+ elsif slug.start_with?('messages')
24+ 'Messages'
25+ elsif slug.start_with?('app/building-your-application')
26+ 'Using App Router: Building your application'
27+ elsif slug.start_with?('app/api-reference')
28+ 'Using App Router: api-reference'
29+ elsif slug.start_with?('app')
30+ 'Using App Router'
31+ elsif slug.start_with?('pages/building-your-application')
32+ 'Using Pages Router: Building your application'
33+ elsif slug.start_with?('pages/api-reference')
34+ 'Using Pages Router: api-reference'
35+ elsif slug.start_with?('pages')
36+ 'Using Pages Router'
37+ else
38+ get_name
39+ end
40+ end
41+ end
42+ end
43+end
lib/docs/scrapers/click.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Click < UrlScraper
3+ self.name = 'click'
4+ self.type = 'sphinx'
5+ self.root_path = 'index.html'
6+ self.links = {
7+ home: 'https://click.palletsprojects.com/',
8+ code: 'https://github.com/pallets/click'
9+ }
10+
11+ html_filters.push 'click/pre_clean_html', 'click/entries', 'sphinx/clean_html'
12+
13+ options[:container] = '.body > section'
14+ options[:skip] = ['changes/', 'genindex/', 'py-modindex/']
15+ options[:title] = false
16+
17+ options[:attribution] = <<-HTML
18+ &copy; Copyright 2014 Pallets.<br>
19+ Licensed under the BSD 3-Clause License.<br>
20+ We are not supported nor endorsed by Pallets.
21+ HTML
22+
23+ self.release = '8.1.x'
24+ self.base_url = "https://click.palletsprojects.com/en/#{self.release}/"
25+
26+ def get_latest_version(opts)
27+ get_latest_github_release('pallets', 'click', opts)
28+ end
29+ end
30+end
lib/docs/scrapers/crystal.rb+1−1
@@ -36,7 +36,7 @@ module Docs · 35 unmodified lines
3636
3737 def get_latest_version(opts)
3838 doc = fetch_doc('https://crystal-lang.org/', opts)
39− doc.at_css('.latest-release').content.scan(/([0-9.]+)/)[0][0]
39+ doc.at_css('.latest-release-info > a > strong').content.scan(/([0-9.]+)/)[0][0]
4040 end
4141 end
4242 end
lib/docs/scrapers/docker.rb+1−1
@@ -96,7 +96,7 @@ module Docs · 95 unmodified lines
9696
9797 def get_latest_version(opts)
9898 doc = fetch_doc('https://docs.docker.com/engine/release-notes/', opts)
99− latest_version = doc.at_css('.content > section > h2').content.strip
99+ latest_version = doc.at_css('.DocSearch-content > h2 > a').content.strip
100100 latest_version.rpartition(' ')[-1]
101101 end
102102 end
lib/docs/scrapers/nextjs.rb+26−0
@@ -0,0 +1,26 @@
1+module Docs
2+ class Nextjs < UrlScraper
3+ self.name = 'Next.js'
4+ self.slug = 'nextjs'
5+ self.type = 'simple'
6+ self.release = '14.2.4'
7+ self.base_url = 'https://nextjs.org/docs'
8+ self.initial_paths = %w(reference/)
9+ self.links = {
10+ home: 'https://www.nextjs.org/',
11+ code: 'https://github.com/vercel/next.js'
12+ }
13+
14+ html_filters.push 'nextjs/entries', 'nextjs/clean_html'
15+ options[:download_images] = false
16+
17+ options[:attribution] = <<-HTML
18+ &copy; 2024 Vercel, Inc.<br>
19+ Licensed under the MIT License.
20+ HTML
21+
22+ def get_latest_version(opts)
23+ get_npm_version('next', opts)
24+ end
25+ end
26+end
lib/docs/scrapers/node.rb+2−2
@@ -74,8 +74,8 @@ module Docs · 73 unmodified lines
7474 end
7575
7676 def get_latest_version(opts)
77− doc = fetch_doc('https://nodejs.org/en/', opts)
78− doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
77+ tags = get_github_tags('nodejs', 'node', opts)
78+ tags[0]['name'][1..-1]
7979 end
8080 end
8181 end
lib/docs/scrapers/octave.rb+1−1
@@ -51,7 +51,7 @@ module Docs · 50 unmodified lines
5151
5252 def get_latest_version(opts)
5353 doc = fetch_doc('https://octave.org/doc/interpreter/', opts)
54− doc.at_css('h1').content.scan(/([0-9.]+)/)[0][0]
54+ doc.at_css('#SEC_Top + p').content.scan(/([0-9.]+)/)[1][0][0..-2]
5555 end
5656
5757 end
lib/docs/scrapers/phalcon.rb+2−2
@@ -31,8 +31,8 @@ module Docs · 30 unmodified lines
3131 end
3232
3333 def get_latest_version(opts)
34− doc = fetch_doc('https://docs.phalconphp.com/', opts)
35− doc.at_css('.header__lang.expand > div > ul > li > a').content
34+ tags = get_github_tags('phalcon', 'cphalcon', opts)
35+ tags[0]['name'][1..-1]
3636 end
3737 end
3838 end
lib/docs/scrapers/sanctuary_type_classes.rb+1−1
@@ -23,7 +23,7 @@ module Docs · 22 unmodified lines
2323 HTML
2424
2525 def get_latest_version(opts)
26− get-npm-version("sanctuary-type-classes", opts)
26+ get_npm_version("sanctuary-type-classes", opts)
2727 end
2828 end
2929 end
lib/docs/scrapers/vite.rb+1−1
@@ -22,7 +22,7 @@ module Docs · 21 unmodified lines
2222 html_filters.push 'vite/entries', 'vite/clean_html'
2323
2424 version do
25− self.release = '5.0.11'
25+ self.release = '5.2.13'
2626 self.base_url = 'https://vitejs.dev/'
2727 end
2828
lib/docs/scrapers/vue.rb+1−1
@@ -19,7 +19,7 @@ module Docs · 18 unmodified lines
1919 HTML
2020
2121 version '3' do
22− self.release = '3.4.5'
22+ self.release = '3.4.27'
2323 self.base_url = 'https://vuejs.org/'
2424 self.initial_paths = %w(guide/introduction.html)
2525 html_filters.push 'vue/entries_v3', 'vue/clean_html'

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t