From 2a5fbccaf22aa96e7f905c51d75d177ac45f3863 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 30 Jul 2024 05:56:12 +0200 Subject: [PATCH 1/4] Add Linux man pages documentation --- docs/file-scrapers.md | 7 +++++++ lib/docs/filters/man/clean_html.rb | 19 +++++++++++++++++++ lib/docs/filters/man/entries.rb | 29 +++++++++++++++++++++++++++++ lib/docs/scrapers/man.rb | 16 ++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 lib/docs/filters/man/clean_html.rb create mode 100644 lib/docs/filters/man/entries.rb create mode 100644 lib/docs/scrapers/man.rb diff --git a/docs/file-scrapers.md b/docs/file-scrapers.md index 727576c7..52e4e0f9 100644 --- a/docs/file-scrapers.md +++ b/docs/file-scrapers.md @@ -142,6 +142,13 @@ $GS = '/usr/local/opt/ghostscript/bin/gs'; # GhostScript ``` +## Man + +```sh +wget --recursive --no-parent https://man7.org/linux/man-pages/ +mv man7.org/linux/man-pages/ docs/man/ +``` + ## NumPy ```sh diff --git a/lib/docs/filters/man/clean_html.rb b/lib/docs/filters/man/clean_html.rb new file mode 100644 index 00000000..1aab6fbd --- /dev/null +++ b/lib/docs/filters/man/clean_html.rb @@ -0,0 +1,19 @@ +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('form[action="https://www.google.com/search"]').remove + doc + end + end + end +end diff --git a/lib/docs/filters/man/entries.rb b/lib/docs/filters/man/entries.rb new file mode 100644 index 00000000..66af74d4 --- /dev/null +++ b/lib/docs/filters/man/entries.rb @@ -0,0 +1,29 @@ +module Docs + class Man + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('h1').content.sub(' — Linux manual page', '') + end + + def get_type + 'Linux manual page' + end + + def entries + return super unless slug == 'dir_by_project' + type0 = nil + return css('*').each_with_object [] do |node, entries| + 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 + path = node['href'] + entries << Entry.new(name, path, type0) + end + end + end + + end + end +end diff --git a/lib/docs/scrapers/man.rb b/lib/docs/scrapers/man.rb new file mode 100644 index 00000000..07ac40d2 --- /dev/null +++ b/lib/docs/scrapers/man.rb @@ -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 From 1cac51952a32d59489fe3a4b89d6b92eb2645fa4 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 30 Jul 2024 07:12:08 +0200 Subject: [PATCH 2/4] man: better entries --- lib/docs/filters/man/clean_html.rb | 1 + lib/docs/filters/man/entries.rb | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/docs/filters/man/clean_html.rb b/lib/docs/filters/man/clean_html.rb index 1aab6fbd..b78b0425 100644 --- a/lib/docs/filters/man/clean_html.rb +++ b/lib/docs/filters/man/clean_html.rb @@ -11,6 +11,7 @@ module Docs 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 diff --git a/lib/docs/filters/man/entries.rb b/lib/docs/filters/man/entries.rb index 66af74d4..72448113 100644 --- a/lib/docs/filters/man/entries.rb +++ b/lib/docs/filters/man/entries.rb @@ -2,24 +2,27 @@ 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 - 'Linux manual page' + build_types if slug == 'dir_by_project' + @@TYPES[slug] or 'Linux manual page' end - def entries - return super unless slug == 'dir_by_project' + def build_types type0 = nil - return css('*').each_with_object [] do |node, entries| + 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 - path = node['href'] - entries << Entry.new(name, path, type0) + # name = node.content + node.next_sibling.content + slug0 = node['href'].remove(/\.html\z/) + @@TYPES[slug0] = type0 end end end From e1cf4e5e12fab6ebfc81e725decfa9bc0e0f3822 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 20 Aug 2024 21:14:51 +0200 Subject: [PATCH 3/4] man: add icons --- public/icons/docs/man/16.png | Bin 0 -> 431 bytes public/icons/docs/man/16@2x.png | Bin 0 -> 1249 bytes public/icons/docs/man/SOURCE | 2 ++ 3 files changed, 2 insertions(+) create mode 100644 public/icons/docs/man/16.png create mode 100644 public/icons/docs/man/16@2x.png create mode 100644 public/icons/docs/man/SOURCE diff --git a/public/icons/docs/man/16.png b/public/icons/docs/man/16.png new file mode 100644 index 0000000000000000000000000000000000000000..c3cd192c5457e83970979083fbeafb71c5406335 GIT binary patch literal 431 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFvNcITwWnidMV_;}#VPNkD|M&0j zPwyT&d~ol_oxGbiZMw3~;__Uc)iWbjHE`wS-6?o7+P8x8e18dYa19?85mTk zoJ>a1kei>9nO2Eg17~I7eV_&nxD6$lxv9k^iMa)sdJIhmdKI;Vst E0KVCXBLDyZ literal 0 HcmV?d00001 diff --git a/public/icons/docs/man/16@2x.png b/public/icons/docs/man/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f6be19b22fa6903df0a63de2061701c7f3de5753 GIT binary patch literal 1249 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7e6l0AZa85pY67#JE_7#My5g&JNk zFq9fFFuY1&V6d9Oz#v{QXIG#NP=dY0)7O>#1&4?*FW=OC-&7eGm=XhgLR|m<|Ift4 z!pzLd!^0a85WvUB&&tZq$;l-uBFe(Ts-~tcCnsNDU%zzeQdU;BxVX42n>R09xR8Z~ zt-QQUS3{<+r$a(Qa>k75A|hht#o03pd7ka$zOz%gDVu-ol1_GZ&Piz;&o^+rJt_S4 zhR*x*{I}Qgi}15%1V~(3!hL6#=*8tcrzUeBn&ZsJ%VTF}&&I}4R9Luva@5XNfnA-N z`!`O0@Zi3$udlMQimT1HS%sH>~X z(9np3gUi|3g_oD_;ll?XKD>8xb8k)M@U-Il`}fz+54TK=bh)^=d3g9_WMt1x=Ki>o z_w9Bbe`lG42M>IIbMeDL9v>SHW+oOt2mYJ$xgW0Jd9#`4>t3DKxMoSR&wP<>i6{YEMB~5;>3wDF)`fSysmnz_m*;f+yPX^ zv%87?UFMGaQgLhT1zUaRKpD0V&okfKmcG}$ zy2Q;{*L22_giQt>;@um5u(@@fRaX#-XXti~(3vanQBP>&&0Sr5w_HMhP164V`_Zf1 z^GEWnoIkaRYe@DtD-`EDNql||a>^o?3*=uED?g3w|{(T4i zD!(*N@&C`y$~MoGH|&9H@zE_$tFxkN*Do-hsc^fYl5GcvBuBxtq=uCL?yD-dUD)`- zvgmF_gZG~%e<${W~_=_y||j+TWVo|W1w+MvjBys#|icllv9&j~i)nS;Nqac}gkjG6VMbxw_# z=Ben5qJ27cZx&qJ;HtV;+!UBD5>h4{XAtu=OSM1u)S%$RcCHEKFCr}-Du1#RTihme zGE3}<%#lp*iE|vcpI-fXc67zNci#Lz-0$C8=#o02H$@#7;;JRC5hW>!C8<`)MX5lF z!N|bKMAyJV*T^8m(9+7#*vi0M+rYrez@S3qWHO3|-29Zxv`X9>I4cY912t&CZ79ji gO)V}-%q_swV`u`gWU-zXsOVzwboFyt=akR{028JM>Hq)$ literal 0 HcmV?d00001 diff --git a/public/icons/docs/man/SOURCE b/public/icons/docs/man/SOURCE new file mode 100644 index 00000000..8d82d154 --- /dev/null +++ b/public/icons/docs/man/SOURCE @@ -0,0 +1,2 @@ +https://mirrors.edge.kernel.org/images/favicon.ico +https://commons.wikimedia.org/wiki/File:Tux.svg CC0 From 99fc2d72910482065cc9c4de0de7ce9552fddc10 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 20 Aug 2024 21:17:13 +0200 Subject: [PATCH 4/4] man: add news entry --- assets/javascripts/news.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index b964b557..e56bd8dd 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2024-08-20", + "New documentation: Linux man pages" + ], [ "2024-07-28", "New documentation: OpenGL"