Merge pull request #2308 from freeCodeCamp/man
Some checks failed
Deploy / Deploy to Heroku (push) Has been cancelled

Add Linux man pages documentation
This commit is contained in:
Simon Legner 2024-08-20 21:26:47 +02:00 committed by GitHub
commit 5c82069d89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 81 additions and 0 deletions

View file

@ -1,4 +1,8 @@
[ [
[
"2024-08-20",
"New documentation: <a href=\"/man/\">Linux man pages</a>"
],
[ [
"2024-07-28", "2024-07-28",
"New documentation: <a href=\"/opengl/\">OpenGL</a>" "New documentation: <a href=\"/opengl/\">OpenGL</a>"

View file

@ -142,6 +142,13 @@ $GS = '/usr/local/opt/ghostscript/bin/gs'; # GhostScript
``` ```
</details> </details>
## Man
```sh
wget --recursive --no-parent https://man7.org/linux/man-pages/
mv man7.org/linux/man-pages/ docs/man/
```
## NumPy ## NumPy
```sh ```sh

View file

@ -0,0 +1,20 @@
module Docs
class Man
class CleanHtmlFilter < Filter
def call
css('.page-top').remove
css('.nav-bar').remove
css('.nav-end').remove
css('.sec-table').remove
css('a[href="#top_of_page"]').remove
css('.end-man-text').remove
css('.start-footer').remove
css('.footer').remove
css('.end-footer').remove
css('.statcounter').remove
css('form[action="https://www.google.com/search"]').remove
doc
end
end
end
end

View file

@ -0,0 +1,32 @@
module Docs
class Man
class EntriesFilter < Docs::EntriesFilter
@@TYPES = {}
def get_name
return slug.split('/').last.sub(/\.(\d[^.]*)\z/, ' (\1)') if slug.start_with?('man')
at_css('h1').content.sub(' — Linux manual page', '')
end
def get_type
build_types if slug == 'dir_by_project'
@@TYPES[slug] or 'Linux manual page'
end
def build_types
type0 = nil
css('*').each do |node|
if node.name == 'h2'
type0 = node.content
elsif node.name == 'a' and node['href'] and node['href'].start_with?('man') and type0
# name = node.content + node.next_sibling.content
slug0 = node['href'].remove(/\.html\z/)
@@TYPES[slug0] = type0
end
end
end
end
end
end

16
lib/docs/scrapers/man.rb Normal file
View file

@ -0,0 +1,16 @@
module Docs
class Man < FileScraper
self.name = 'Linux man pages'
self.type = 'simple'
self.slug = 'man'
self.base_url = "https://man7.org/linux/man-pages/"
self.initial_paths = %w(dir_by_project.html)
self.links = {
home: 'https://man7.org/linux/man-pages/',
}
html_filters.push 'man/entries', 'man/clean_html'
options[:attribution] = <<-HTML
...
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,2 @@
https://mirrors.edge.kernel.org/images/favicon.ico
https://commons.wikimedia.org/wiki/File:Tux.svg CC0