User Tools

Site Tools


packet:xrouter:docs:parsing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
packet:xrouter:docs:parsing [2025/04/26 19:26] m0mzfpacket:xrouter:docs:parsing [2025/04/26 21:44] (current) m0mzf
Line 85: Line 85:
 } }
  
 +# awk functions
 awkFormatIndexMANTitle=' awkFormatIndexMANTitle='
 { {
Line 101: Line 102:
 awkParseMan=' awkParseMan='
 { {
- if (NR>=(recs - 1) && flag==0) {print "</code>" ; exit} # If we have EOF and didn'have a see also line write code close and exit + if (NR>=(recs - 1) && flag==0) {print "</code>" ; exit} # If we have EOF and didnt have a SEE ALSO section write code close and exit 
- if (NR>=(recs - 1) && flag==1) {print "" ; exit} # If we are EOF and have a see also line write nothing and exit+ if (NR>=(recs - 1) && flag==1) {print "" ; exit} # If we are EOF and have a SEE ALSO section write nothing and exit
  
  if (NR==1 || NR==2) # For the first two lines  if (NR==1 || NR==2) # For the first two lines
Line 120: Line 121:
  print "</code> **SEE ALSO:** \\\\" # Output a reformatted see also line  print "</code> **SEE ALSO:** \\\\" # Output a reformatted see also line
  }  }
- else if (NR>lno && NR<(recs -1) && NF>0) # If we're in see also and are not EOF and have non-empty lines+ else if (NR>lno && NR<(recs -1) && NF>0) # If we are in SEE ALSO and are not EOF and have non-empty lines
  {  {
  line=$0 # Save the inital line to print later  line=$0 # Save the inital line to print later
Line 154: Line 155:
 ' '
  
 +# File enumerator / reader / writer
 parseFiles () { parseFiles () {
  mkdir "${OUTPUTDIR}/$1"  mkdir "${OUTPUTDIR}/$1"
Line 192: Line 194:
  # Parse the file!  # Parse the file!
  awk -v flag=0 -v recs="$recs" -v lno=99999 -v ns="$NAMESPACE" "$awkParseMan" "$file" >> "$outputpath"  awk -v flag=0 -v recs="$recs" -v lno=99999 -v ns="$NAMESPACE" "$awkParseMan" "$file" >> "$outputpath"
 + # Add a link back to index page
 + echo "[[$NAMESPACE|< Back to Index]]" >> "$outputpath"
  # Add a line break after each MAN entry  # Add a line break after each MAN entry
- echo -e "\n\n----\n\n" >> "$outputpath"+ echo -e "\n----" >> "$outputpath"
  # and add an entry to the index  # and add an entry to the index
  echo "$section" | awk -v ns="$NAMESPACE" -v ti="$title" "$awkFormatIndexMANTitle" >> "$INDEXFILE"  echo "$section" | awk -v ns="$NAMESPACE" -v ti="$title" "$awkFormatIndexMANTitle" >> "$INDEXFILE"
Line 202: Line 206:
  awk "$awkParseHlp" "$file" >> "$outputpath"  awk "$awkParseHlp" "$file" >> "$outputpath"
  echo "</code>" >> "$outputpath"  echo "</code>" >> "$outputpath"
 + # Add a link back to index page
 + echo "[[$NAMESPACE|< Back to Index]]" >> "$outputpath"
  echo "$section" | awk -v ns="$NAMESPACE" -v ti="$title" "$awkFormatIndexHLPTitle" >> "$INDEXFILE"  echo "$section" | awk -v ns="$NAMESPACE" -v ti="$title" "$awkFormatIndexHLPTitle" >> "$INDEXFILE"
  ;;  ;;
Line 216: Line 222:
 echo "======= XRouter Documentation =======" >> "$INDEXFILE" echo "======= XRouter Documentation =======" >> "$INDEXFILE"
 echo "This content is auto-generated from the XRouter documentation using [[$NAMESPACE:parsing|this bash / awk script]] to parse MAN / HLP files into docuWiki some simple markup language" >> "$INDEXFILE" echo "This content is auto-generated from the XRouter documentation using [[$NAMESPACE:parsing|this bash / awk script]] to parse MAN / HLP files into docuWiki some simple markup language" >> "$INDEXFILE"
-echoGreen "Parsing MAN files from $MANFILES"+echoGreen "Parsing MAN files from $MAN"
 parseFiles MAN parseFiles MAN
-echoGreen "Parsing HLP files from $HLPFILES"+echoGreen "Parsing HLP files from $HLP"
 parseFiles HLP parseFiles HLP
-#echoGreen "Parsing DOC files from $DOCFILES"+#echoGreen "Parsing DOC files from $DOC"
 #parseFiles DOC #parseFiles DOC
 </file> </file>
packet/xrouter/docs/parsing.1745695565.txt.gz · Last modified: by m0mzf