diff --git a/docs/file-scrapers.md b/docs/file-scrapers.md index 076510fcd9..206f76630e 100644 --- a/docs/file-scrapers.md +++ b/docs/file-scrapers.md @@ -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 +``` diff --git a/lib/docs/filters/powershell/clean_html.rb b/lib/docs/filters/powershell/clean_html.rb new file mode 100644 index 0000000000..8b51696eef --- /dev/null +++ b/lib/docs/filters/powershell/clean_html.rb @@ -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 diff --git a/lib/docs/filters/powershell/entries.rb b/lib/docs/filters/powershell/entries.rb new file mode 100644 index 0000000000..ed5d280d5c --- /dev/null +++ b/lib/docs/filters/powershell/entries.rb @@ -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 diff --git a/lib/docs/scrapers/powershell.rb b/lib/docs/scrapers/powershell.rb new file mode 100644 index 0000000000..8dc69fa33e --- /dev/null +++ b/lib/docs/scrapers/powershell.rb @@ -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 diff --git a/public/icons/docs/powershell/16.png b/public/icons/docs/powershell/16.png new file mode 100644 index 0000000000..730b58a302 Binary files /dev/null and b/public/icons/docs/powershell/16.png differ diff --git a/public/icons/docs/powershell/16@2x.png b/public/icons/docs/powershell/16@2x.png new file mode 100644 index 0000000000..5840c2dafd Binary files /dev/null and b/public/icons/docs/powershell/16@2x.png differ diff --git a/public/icons/docs/powershell/SOURCE b/public/icons/docs/powershell/SOURCE new file mode 100644 index 0000000000..3604afa785 --- /dev/null +++ b/public/icons/docs/powershell/SOURCE @@ -0,0 +1 @@ +https://learn.microsoft.com/en-us/powershell/media/index/ps_black_128.svg