You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
improve the rendering of the man pages
This commit is contained in:
@@ -68,62 +68,14 @@ jobs:
|
||||
|
||||
- name: Convert Manpages to HTML and Generate Index
|
||||
run: |
|
||||
mkdir -p manpages-html
|
||||
# Extract tldr pages for examples
|
||||
mkdir -p tldr-pages
|
||||
if [ -f coreutils/docs/tldr.zip ]; then
|
||||
unzip -o coreutils/docs/tldr.zip -d tldr-extract
|
||||
find tldr-extract -name "*.md" -exec cp {} tldr-pages/ \;
|
||||
fi
|
||||
|
||||
# Convert manpages to HTML and collect names
|
||||
manpage_names=""
|
||||
for man in manpages/usr/local/share/man/man*/*.1; do
|
||||
if [ -f "$man" ]; then
|
||||
name=$(basename "$man" .1)
|
||||
man2html -r "$man" > "manpages-html/${name}.html"
|
||||
manpage_names="$manpage_names $name"
|
||||
fi
|
||||
done
|
||||
|
||||
# Generate index.html with links to all manpages
|
||||
cat > manpages-html/index.html << 'HEADER'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>uutils coreutils - Manual Pages</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
|
||||
h1 { color: #333; }
|
||||
.breadcrumb { margin-bottom: 20px; }
|
||||
.breadcrumb a { color: #007acc; text-decoration: none; }
|
||||
.breadcrumb a:hover { text-decoration: underline; }
|
||||
.manpage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-top: 30px; }
|
||||
.manpage-link { display: block; padding: 12px; background: #f5f5f5; border: 1px solid #ddd; border-radius: 5px; text-decoration: none; color: #333; text-align: center; font-family: monospace; font-weight: bold; font-size: 1.1em; transition: all 0.3s ease; }
|
||||
.manpage-link:hover { background: #007acc; color: white; border-color: #007acc; transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #1a1a1a; color: #e0e0e0; }
|
||||
h1 { color: #e0e0e0; }
|
||||
.manpage-link { background: #2a2a2a; border-color: #444; color: #e0e0e0; }
|
||||
.manpage-link:hover { background: #007acc; color: white; border-color: #007acc; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="breadcrumb">
|
||||
<a href="/">Home</a> /
|
||||
<a href="/coreutils">Coreutils</a> /
|
||||
<span>Manual Pages</span>
|
||||
</div>
|
||||
<h1>Manual Pages</h1>
|
||||
<p>Complete manual pages for all uutils coreutils commands. Click on any command to view its full documentation.</p>
|
||||
<div class="manpage-grid">
|
||||
HEADER
|
||||
|
||||
for name in $(echo $manpage_names | tr ' ' '\n' | sort); do
|
||||
echo " <a href=\"${name}.html\" class=\"manpage-link\">${name}</a>" >> manpages-html/index.html
|
||||
done
|
||||
|
||||
cat >> manpages-html/index.html << 'FOOTER'
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
FOOTER
|
||||
uutils.github.io/scripts/build-manpages.sh manpages tldr-pages manpages-html uutils.github.io/templates
|
||||
|
||||
- name: Build Findutils Docs
|
||||
run: |
|
||||
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# Build styled HTML manpages from man files
|
||||
# Usage: build-manpages.sh <manpages-dir> <tldr-dir> <output-dir> <templates-dir>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
MANPAGES_DIR="${1:?Usage: $0 <manpages-dir> <tldr-dir> <output-dir> <templates-dir>}"
|
||||
TLDR_DIR="${2:?}"
|
||||
OUTPUT_DIR="${3:?}"
|
||||
TEMPLATES_DIR="${4:?}"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
MANPAGE_TEMPLATE="$TEMPLATES_DIR/manpage.html"
|
||||
INDEX_TEMPLATE="$TEMPLATES_DIR/manpage-index.html"
|
||||
|
||||
manpage_names=""
|
||||
|
||||
for man in "$MANPAGES_DIR"/usr/local/share/man/man*/*.1; do
|
||||
[ -f "$man" ] || continue
|
||||
name=$(basename "$man" .1)
|
||||
|
||||
# Convert manpage, strip man2html header and footer
|
||||
man_content=$(man2html -r "$man" | sed '1,/^$/d' | sed '/This document was created by/,/<\/BODY>/d; /<\/HTML>/d')
|
||||
|
||||
# Build tldr examples section
|
||||
tldr_html=""
|
||||
tldr_file="$TLDR_DIR/${name}.md"
|
||||
if [ -f "$tldr_file" ]; then
|
||||
tldr_html="<div class=\"tldr-section\"><h2>Examples (from tldr)</h2>"
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
"# "* | "> "* | "---" | "") ;;
|
||||
"- "*)
|
||||
desc="${line#- }"
|
||||
tldr_html="$tldr_html<div class=\"tldr-example\"><p class=\"tldr-desc\">$desc</p>"
|
||||
;;
|
||||
'`'*'`')
|
||||
cmd="${line#\`}"
|
||||
cmd="${cmd%\`}"
|
||||
cmd=$(echo "$cmd" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
|
||||
tldr_html="$tldr_html<pre><code>$cmd</code></pre></div>"
|
||||
;;
|
||||
esac
|
||||
done < "$tldr_file"
|
||||
tldr_html="$tldr_html</div>"
|
||||
fi
|
||||
|
||||
# Apply template: split at placeholders, concatenate with content
|
||||
# Get line numbers of placeholders
|
||||
content_line=$(grep -n '{{CONTENT}}' "$MANPAGE_TEMPLATE" | cut -d: -f1)
|
||||
tldr_line=$(grep -n '{{TLDR}}' "$MANPAGE_TEMPLATE" | cut -d: -f1)
|
||||
|
||||
{
|
||||
# Before {{CONTENT}}
|
||||
head -n $((content_line - 1)) "$MANPAGE_TEMPLATE" | sed "s|{{NAME}}|${name}|g"
|
||||
# The manpage content
|
||||
echo "$man_content"
|
||||
# Between {{CONTENT}} and {{TLDR}}
|
||||
sed -n "$((content_line + 1)),$((tldr_line - 1))p" "$MANPAGE_TEMPLATE" | sed "s|{{NAME}}|${name}|g"
|
||||
# The tldr content
|
||||
echo "$tldr_html"
|
||||
# After {{TLDR}}
|
||||
tail -n +$((tldr_line + 1)) "$MANPAGE_TEMPLATE" | sed "s|{{NAME}}|${name}|g"
|
||||
} > "$OUTPUT_DIR/${name}.html"
|
||||
|
||||
manpage_names="$manpage_names $name"
|
||||
done
|
||||
|
||||
# Build index page
|
||||
content_line=$(grep -n '{{LINKS}}' "$INDEX_TEMPLATE" | cut -d: -f1)
|
||||
{
|
||||
head -n $((content_line - 1)) "$INDEX_TEMPLATE"
|
||||
for name in $(echo $manpage_names | tr ' ' '\n' | sort); do
|
||||
echo " <a href=\"${name}.html\" class=\"manpage-link\">${name}</a>"
|
||||
done
|
||||
tail -n +$((content_line + 1)) "$INDEX_TEMPLATE"
|
||||
} > "$OUTPUT_DIR/index.html"
|
||||
|
||||
echo "Built $(echo $manpage_names | wc -w) manpages in $OUTPUT_DIR"
|
||||
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>uutils coreutils - Manual Pages</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
|
||||
h1 { color: #333; }
|
||||
.breadcrumb { margin-bottom: 20px; }
|
||||
.breadcrumb a { color: #007acc; text-decoration: none; }
|
||||
.breadcrumb a:hover { text-decoration: underline; }
|
||||
.manpage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-top: 30px; }
|
||||
.manpage-link { display: block; padding: 12px; background: #f5f5f5; border: 1px solid #ddd; border-radius: 5px; text-decoration: none; color: #333; text-align: center; font-family: monospace; font-weight: bold; font-size: 1.1em; transition: all 0.3s ease; }
|
||||
.manpage-link:hover { background: #007acc; color: white; border-color: #007acc; transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #1a1a1a; color: #e0e0e0; }
|
||||
h1 { color: #e0e0e0; }
|
||||
.manpage-link { background: #2a2a2a; border-color: #444; color: #e0e0e0; }
|
||||
.manpage-link:hover { background: #007acc; color: white; border-color: #007acc; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="breadcrumb">
|
||||
<a href="/">Home</a> /
|
||||
<a href="/coreutils">Coreutils</a> /
|
||||
<span>Manual Pages</span>
|
||||
</div>
|
||||
<h1>Manual Pages</h1>
|
||||
<p>Complete manual pages for all uutils coreutils commands. Click on any command to view its full documentation.</p>
|
||||
<div class="manpage-grid">
|
||||
{{LINKS}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{NAME}}(1) - uutils coreutils</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 900px; margin: 0 auto; padding: 20px; line-height: 1.6; color: #333; }
|
||||
h1, h2 { color: #333; border-bottom: 1px solid #ddd; padding-bottom: 8px; }
|
||||
a { color: #007acc; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
pre, code { background: #f5f5f5; border-radius: 3px; }
|
||||
pre { padding: 12px; overflow-x: auto; border: 1px solid #ddd; }
|
||||
code { padding: 2px 5px; }
|
||||
dl dt { font-weight: bold; margin-top: 10px; }
|
||||
dl dd { margin-left: 20px; }
|
||||
.breadcrumb { margin-bottom: 20px; }
|
||||
.breadcrumb a { color: #007acc; }
|
||||
.manpage-content { margin-top: 20px; }
|
||||
.tldr-section { margin-top: 30px; padding: 20px; background: #f0f7ff; border: 1px solid #c0d8f0; border-radius: 8px; }
|
||||
.tldr-section h2 { color: #005a9e; border-bottom: 1px solid #c0d8f0; }
|
||||
.tldr-example { margin-bottom: 15px; }
|
||||
.tldr-desc { margin-bottom: 5px; font-style: italic; color: #555; }
|
||||
.tldr-example pre { background: #1e1e1e; color: #d4d4d4; border: none; }
|
||||
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
||||
.top-links { display: flex; gap: 15px; font-size: 0.9em; }
|
||||
.top-links a { color: #007acc; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #1a1a1a; color: #e0e0e0; }
|
||||
h1, h2 { color: #e0e0e0; border-bottom-color: #444; }
|
||||
pre, code { background: #2a2a2a; }
|
||||
pre { border-color: #444; }
|
||||
.tldr-section { background: #1a2a3a; border-color: #2a4a6a; }
|
||||
.tldr-section h2 { color: #6cb4ee; border-bottom-color: #2a4a6a; }
|
||||
.tldr-desc { color: #aaa; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="top-bar">
|
||||
<div class="breadcrumb">
|
||||
<a href="/">Home</a> /
|
||||
<a href="/coreutils">Coreutils</a> /
|
||||
<a href="/coreutils/manpages/">Manual Pages</a> /
|
||||
<span>{{NAME}}(1)</span>
|
||||
</div>
|
||||
<div class="top-links">
|
||||
<a href="https://github.com/uutils/coreutils/tree/main/src/uu/{{NAME}}">Source code</a>
|
||||
<a href="https://github.com/uutils/coreutils/issues/new?title={{NAME}}:%20&labels=bug">Report an issue</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="manpage-content">
|
||||
{{CONTENT}}
|
||||
</div>
|
||||
{{TLDR}}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user