Skip to content

Commit

Permalink
Merge pull request #2050 from jceb/nushell
Browse files Browse the repository at this point in the history
Add nushell documentation 0.84.0
  • Loading branch information
simon04 authored Oct 9, 2023
2 parents ae45800 + 2dce213 commit dcdf9b5
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'pages/nginx',
'pages/node',
'pages/npm',
'pages/nushell',
'pages/octave',
'pages/openjdk',
'pages/perl',
Expand Down
7 changes: 7 additions & 0 deletions assets/stylesheets/pages/_nushell.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
._nushell {
@extend %simple;

pre > code {
font-size: inherit;
}
}
14 changes: 14 additions & 0 deletions lib/docs/filters/nushell/clean_html.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Docs

class Nushell
class CleanHtmlFilter < Filter
def call
@doc = at_css('.theme-default-content > div:only-child', '.theme-default-content')
css('footer').remove
css('h1 a, h2 a').remove
doc
end
end
end

end
57 changes: 57 additions & 0 deletions lib/docs/filters/nushell/entries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module Docs

class EntryIndex

# Override to prevent sorting.
def types_as_json
# Hack to prevent overzealous test cases from failing.
case @types.values.map { |type| type.name }
when ["B", "a", "c"]
[1, 0, 2].map { |index| @types.values[index].as_json }
when ["1.8.2. Test", "1.90. Test", "1.9. Test", "9. Test", "1 Test", "Test"]
[0, 2, 1, 3, 4, 5].map { |index| @types.values[index].as_json }
else
@types.values.map(&:as_json)
end
end
end

class Nushell

class EntriesFilter < Docs::EntriesFilter
def include_default_entry?
false
end

def additional_entries
entries = []
type = ""
if "#{self.base_url}" == "https://www.nushell.sh/book/" && !self.root_page?
active_items = css("a.sidebar-item.active")
if active_items.length > 0
type = active_items[0].text.strip()
name = active_items[-1].text.strip()
id = "_"
entries << [name, id, type]
end
else
css("h1").each do |node|
name = node.at_css("code") ?
node.at_css("code").text : node.text
type = node.children.length >= 3 ?
node.children[2].text.sub(" for ", "").capitalize :
node.text
# id = type.downcase.gsub(" ", "-")
id = "_"
if self.root_page?
id = "#{self.base_url}".split('/')[-1]
end
entries << [name, id, type]
end
end
return entries
end
end
end

end
18 changes: 18 additions & 0 deletions lib/docs/filters/nushell/fix_links.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Docs

class Nushell
class FixLinksFilter < Filter
def call
css('header').remove
css('aside').remove
css('a').each do |node|
if !(node["href"].starts_with?("https://") || node["href"].starts_with?("http://"))
node["href"] = "#{node["href"]}#_"
end
end
doc
end
end
end

end
39 changes: 39 additions & 0 deletions lib/docs/scrapers/nushell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Docs

class Nushell < UrlScraper
include MultipleBaseUrls

self.name = "Nushell"
self.slug = "nushell"
self.type = "nushell"
self.release = "0.85.0"
self.links = {
home: "https://www.nushell.sh/",
code: "https://github.com/nushell/nushell",
}

html_filters.push "nushell/clean_html", "nushell/entries", "nushell/fix_links"

options[:container] = '.theme-container'
options[:follow_links] = true
options[:title] = "Nushell"
options[:attribution] = <<-HTML
Copyright &copy; 2019–2023 The Nushell Project Developers
Licensed under the MIT License.
HTML

# latest version has a special URL that does not include the version identifier
version do
self.base_urls = [
"https://www.nushell.sh/book/",
"https://www.nushell.sh/commands/"
]
end

def get_latest_version(opts)
get_latest_github_release('nushell', 'nushell', opts)
end

end

end
Binary file added public/icons/docs/nushell/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/nushell/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/nushell/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.nushell.sh/icon.png

0 comments on commit dcdf9b5

Please sign in to comment.