History

Merge pull request #2308 from freeCodeCamp/man

Add Linux man pages documentation

Simon Legner committed 2 years ago

Commit 5c820692 parents bc530da 99fc2d78 files · +79 −-2Browse files

Unified · Split

8 files
  1. assets/javascripts/news.json +4 −0
  2. docs/file-scrapers.md +7 −0
  3. lib/docs/filters/man/clean_html.rb +20 −0
  4. lib/docs/filters/man/entries.rb +32 −0
  5. lib/docs/scrapers/man.rb +16 −0
  6. public/icons/docs/man/16.png +0 −0
  7. public/icons/docs/man/16@2x.png +0 −0
  8. public/icons/docs/man/SOURCE +2 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
1[1[
2 [
3 "2024-08-20",
4 "New documentation: <a href=\"/man/\">Linux man pages</a>"
5 ],
2 [6 [
3 "2024-07-28",7 "2024-07-28",
4 "New documentation: <a href=\"/opengl/\">OpenGL</a>"8 "New documentation: <a href=\"/opengl/\">OpenGL</a>"
docs/file-scrapers.md+7−0
@@ -142,6 +142,13 @@ $GS = '/usr/local/opt/ghostscript/bin/gs'; # GhostScript · 141 unmodified lines
142```142```
143</details>143</details>
144 144
145## Man
146
147```sh
148wget --recursive --no-parent https://man7.org/linux/man-pages/
149mv man7.org/linux/man-pages/ docs/man/
150```
151
145## NumPy152## NumPy
146 153
147```sh154```sh
lib/docs/filters/man/clean_html.rb+20−0
@@ -0,0 +1,20 @@
1module Docs
2 class Man
3 class CleanHtmlFilter < Filter
4 def call
5 css('.page-top').remove
6 css('.nav-bar').remove
7 css('.nav-end').remove
8 css('.sec-table').remove
9 css('a[href="#top_of_page"]').remove
10 css('.end-man-text').remove
11 css('.start-footer').remove
12 css('.footer').remove
13 css('.end-footer').remove
14 css('.statcounter').remove
15 css('form[action="https://www.google.com/search"]').remove
16 doc
17 end
18 end
19 end
20end
lib/docs/filters/man/entries.rb+32−0
@@ -0,0 +1,32 @@
1module Docs
2 class Man
3 class EntriesFilter < Docs::EntriesFilter
4
5 @@TYPES = {}
6
7 def get_name
8 return slug.split('/').last.sub(/\.(\d[^.]*)\z/, ' (\1)') if slug.start_with?('man')
9 at_css('h1').content.sub(' — Linux manual page', '')
10 end
11
12 def get_type
13 build_types if slug == 'dir_by_project'
14 @@TYPES[slug] or 'Linux manual page'
15 end
16
17 def build_types
18 type0 = nil
19 css('*').each do |node|
20 if node.name == 'h2'
21 type0 = node.content
22 elsif node.name == 'a' and node['href'] and node['href'].start_with?('man') and type0
23 # name = node.content + node.next_sibling.content
24 slug0 = node['href'].remove(/\.html\z/)
25 @@TYPES[slug0] = type0
26 end
27 end
28 end
29
30 end
31 end
32end
lib/docs/scrapers/man.rb+16−0
@@ -0,0 +1,16 @@
1module Docs
2 class Man < FileScraper
3 self.name = 'Linux man pages'
4 self.type = 'simple'
5 self.slug = 'man'
6 self.base_url = "https://man7.org/linux/man-pages/"
7 self.initial_paths = %w(dir_by_project.html)
8 self.links = {
9 home: 'https://man7.org/linux/man-pages/',
10 }
11 html_filters.push 'man/entries', 'man/clean_html'
12 options[:attribution] = <<-HTML
13 ...
14 HTML
15 end
16end
public/icons/docs/man/16.png+0−0

Binary file not shown.

public/icons/docs/man/16@2x.png+0−0

Binary file not shown.

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