Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/file-scrapers.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,23 @@ mv three.js-r${VERSION}/docs/* docs/threejs~${VERSION}/
rm -rf three.js-r${VERSION}/
rm threejs.tar.gz
```

## PowerShell

```sh
curl -o PowerShell-Docs-main.zip 'https://github.com/MicrosoftDocs/PowerShell-Docs/archive/refs/heads/main.zip'
unzip PowerShell-Docs-main.zip
cd PowerShell-Docs-main

# strip all front matter in all Markdown files
find reference -name "*.md" -type f -exec sed -i '/^---$/,/^---$/d' {} +


npx markdown-folder-to-html reference
cp -r _reference ../docs/powershell
cd ..
bundle exec thor docs:generate powershell

rm -rdf PowerShell-Docs-main/
rm PowerShell-Docs-main.zip
```
22 changes: 22 additions & 0 deletions lib/docs/filters/powershell/clean_html.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Docs
class Powershell
class CleanHtmlFilter < Filter
def call
# web
css('header').remove
css('#ms--content-header').remove
css('#article-header').remove
css('.left-container').remove
css('.layout-body-aside').remove
css('#site-user-feedback-footer').remove
css('footer').remove
# markdown-folder-to-html
css('#menuLink').remove
css('#menu').remove
css('script').remove
css('style').remove
doc
end
end
end
end
26 changes: 26 additions & 0 deletions lib/docs/filters/powershell/entries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Docs
class Powershell
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1')&.content.chop.chop || "" # remove the extra ' #'
end

def get_type
case slug
when /^docs-conceptual/
'Scripting'
when /^5\.1/
'5.1'
when /^7\.4/
'7.4'
when /^7\.5/
'7.5'
when /^7\.6/
'7.6'
else
'Manual'
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/docs/scrapers/powershell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Docs
class Powershell < FileScraper
self.name = 'PowerShell'
self.type = 'simple'
self.release = '7.5'
self.base_url = 'https://learn.microsoft.com/en-us/powershell'
self.root_path = 'docs-conceptual/overview.html'
self.initial_paths = [
'module/index.html',
]
self.links = {
home: 'https://learn.microsoft.com/powershell',
code: 'https://github.com/MicrosoftDocs/PowerShell-Docs'
}
html_filters.push 'powershell/clean_html', 'powershell/entries'

options[:skip_patterns] = [/\/\//] # otherwise infinately adding the same pages
options[:attribution] = <<-HTML
The MIT License (MIT) Copyright (c) Microsoft Corporation
HTML
end
end
Binary file added public/icons/docs/powershell/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/powershell/16@2x.png
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/powershell/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://learn.microsoft.com/en-us/powershell/media/index/ps_black_128.svg