packet:xrouter:manpages:parsing
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
packet:xrouter:manpages:parsing [2025/04/20 07:07] – m0mzf | packet:xrouter:manpages:parsing [2025/04/20 07:28] (current) – m0mzf | ||
---|---|---|---|
Line 50: | Line 50: | ||
OUTPUTDIR=" | OUTPUTDIR=" | ||
- | # Colourise output | + | # Handy functions |
echoRed () { | echoRed () { | ||
echo -e " | echo -e " | ||
Line 57: | Line 57: | ||
echo -e " | echo -e " | ||
} | } | ||
- | |||
checkRoot () { | checkRoot () { | ||
- | if [[ $UID -eq 0 ]]; | + | if [[ $UID -eq 0 ]]; then |
- | then | + | echoRed |
- | echoError | + | |
exit 1 | exit 1 | ||
fi | fi | ||
Line 73: | Line 71: | ||
# | # | ||
# (the final encapsulation is done using " | # (the final encapsulation is done using " | ||
- | awkParseMan=' | + | awkParseMan=' |
- | { | + | |
if (NR==1 || NR==2) # For the first two lines | if (NR==1 || NR==2) # For the first two lines | ||
{ | { | ||
Line 104: | Line 101: | ||
# insert a start code block in place of the now-empty line 1 | # insert a start code block in place of the now-empty line 1 | ||
# (the final encapsulation is done using " | # (the final encapsulation is done using " | ||
- | awkParseHlp=' | + | awkParseHlp=' |
- | { | + | |
endhead="< | endhead="< | ||
gsub(" | gsub(" | ||
Line 113: | Line 109: | ||
} | } | ||
' | ' | ||
- | |||
# Use awk to extract a section name from the directory structure | # Use awk to extract a section name from the directory structure | ||
awkSectionHeader=' | awkSectionHeader=' | ||
Line 122: | Line 117: | ||
} | } | ||
' | ' | ||
- | |||
# Use awk to extract a name from the filename.extension | # Use awk to extract a name from the filename.extension | ||
awkFileHeader=' | awkFileHeader=' | ||
Line 138: | Line 132: | ||
do | do | ||
# Get the penultimate field in file path, i.e. the section (folder) name | # Get the penultimate field in file path, i.e. the section (folder) name | ||
- | section=$(echo $folder | awk -F/ ' | + | local section=$(echo $folder | awk -F/ ' |
# Format the section name as a docuWiki header | # Format the section name as a docuWiki header | ||
echo " | echo " | ||
Line 147: | Line 141: | ||
do | do | ||
# Get the last field in file path, i.e. file name | # Get the last field in file path, i.e. file name | ||
- | title=$(echo $file | awk -F/ ' | + | local title=$(echo $file | awk -F/ ' |
+ | local outputpath=" | ||
# Format the file name as a docuwiki header | # Format the file name as a docuwiki header | ||
- | echo " | + | echo " |
case " | case " | ||
# For MAN files, after awk has done it's job we need to remove the last line; this last line breaks | # For MAN files, after awk has done it's job we need to remove the last line; this last line breaks | ||
# the following < | # the following < | ||
- | MANFILES) awk " | + | MANFILES) awk " |
- | echo -e "</ | + | echo -e "</ |
;; | ;; | ||
# For HLP files we don't want to remove the last line because that truly is real content | # For HLP files we don't want to remove the last line because that truly is real content | ||
- | HLPFILES) awk " | + | HLPFILES) awk " |
- | echo -e "</ | + | echo -e "</ |
;; | ;; | ||
esac | esac |
packet/xrouter/manpages/parsing.1745132877.txt.gz · Last modified: 2025/04/20 07:07 by m0mzf