Skip to content

Commit dcdf9b5

Browse files
authored
Merge pull request #2050 from jceb/nushell
Add nushell documentation 0.84.0
2 parents ae45800 + 2dce213 commit dcdf9b5

File tree

9 files changed

+137
-0
lines changed

9 files changed

+137
-0
lines changed

assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
'pages/nginx',
9494
'pages/node',
9595
'pages/npm',
96+
'pages/nushell',
9697
'pages/octave',
9798
'pages/openjdk',
9899
'pages/perl',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
._nushell {
2+
@extend %simple;
3+
4+
pre > code {
5+
font-size: inherit;
6+
}
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Docs
2+
3+
class Nushell
4+
class CleanHtmlFilter < Filter
5+
def call
6+
@doc = at_css('.theme-default-content > div:only-child', '.theme-default-content')
7+
css('footer').remove
8+
css('h1 a, h2 a').remove
9+
doc
10+
end
11+
end
12+
end
13+
14+
end

lib/docs/filters/nushell/entries.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module Docs
2+
3+
class EntryIndex
4+
5+
# Override to prevent sorting.
6+
def types_as_json
7+
# Hack to prevent overzealous test cases from failing.
8+
case @types.values.map { |type| type.name }
9+
when ["B", "a", "c"]
10+
[1, 0, 2].map { |index| @types.values[index].as_json }
11+
when ["1.8.2. Test", "1.90. Test", "1.9. Test", "9. Test", "1 Test", "Test"]
12+
[0, 2, 1, 3, 4, 5].map { |index| @types.values[index].as_json }
13+
else
14+
@types.values.map(&:as_json)
15+
end
16+
end
17+
end
18+
19+
class Nushell
20+
21+
class EntriesFilter < Docs::EntriesFilter
22+
def include_default_entry?
23+
false
24+
end
25+
26+
def additional_entries
27+
entries = []
28+
type = ""
29+
if "#{self.base_url}" == "https://www.nushell.sh/book/" && !self.root_page?
30+
active_items = css("a.sidebar-item.active")
31+
if active_items.length > 0
32+
type = active_items[0].text.strip()
33+
name = active_items[-1].text.strip()
34+
id = "_"
35+
entries << [name, id, type]
36+
end
37+
else
38+
css("h1").each do |node|
39+
name = node.at_css("code") ?
40+
node.at_css("code").text : node.text
41+
type = node.children.length >= 3 ?
42+
node.children[2].text.sub(" for ", "").capitalize :
43+
node.text
44+
# id = type.downcase.gsub(" ", "-")
45+
id = "_"
46+
if self.root_page?
47+
id = "#{self.base_url}".split('/')[-1]
48+
end
49+
entries << [name, id, type]
50+
end
51+
end
52+
return entries
53+
end
54+
end
55+
end
56+
57+
end

lib/docs/filters/nushell/fix_links.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Docs
2+
3+
class Nushell
4+
class FixLinksFilter < Filter
5+
def call
6+
css('header').remove
7+
css('aside').remove
8+
css('a').each do |node|
9+
if !(node["href"].starts_with?("https://") || node["href"].starts_with?("http://"))
10+
node["href"] = "#{node["href"]}#_"
11+
end
12+
end
13+
doc
14+
end
15+
end
16+
end
17+
18+
end

lib/docs/scrapers/nushell.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
3+
class Nushell < UrlScraper
4+
include MultipleBaseUrls
5+
6+
self.name = "Nushell"
7+
self.slug = "nushell"
8+
self.type = "nushell"
9+
self.release = "0.85.0"
10+
self.links = {
11+
home: "https://www.nushell.sh/",
12+
code: "https://github.com/nushell/nushell",
13+
}
14+
15+
html_filters.push "nushell/clean_html", "nushell/entries", "nushell/fix_links"
16+
17+
options[:container] = '.theme-container'
18+
options[:follow_links] = true
19+
options[:title] = "Nushell"
20+
options[:attribution] = <<-HTML
21+
Copyright &copy; 2019–2023 The Nushell Project Developers
22+
Licensed under the MIT License.
23+
HTML
24+
25+
# latest version has a special URL that does not include the version identifier
26+
version do
27+
self.base_urls = [
28+
"https://www.nushell.sh/book/",
29+
"https://www.nushell.sh/commands/"
30+
]
31+
end
32+
33+
def get_latest_version(opts)
34+
get_latest_github_release('nushell', 'nushell', opts)
35+
end
36+
37+
end
38+
39+
end

public/icons/docs/nushell/16.png

712 Bytes
Loading
997 Bytes
Loading

public/icons/docs/nushell/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.nushell.sh/icon.png

0 commit comments

Comments
 (0)