Author Topic: Docs  (Read 2099 times)

Offline saquivor

  • BFF
  • ***
  • Posts: 110
    • View Profile
Docs
« on: November 22, 2006, 10:12:03 AM »
I have been experimenting with creating a single set of documents from the docs folder in DS2 , as I was always jumping around looking for information.


I will release the script for doing this tomorrow, after I tidy it up a bit.

<a href="http://www.monkeyx.net/pdf/saq.zip">This zip</a> file contains a txt and pdf versions of all the docs.

Please have a look and let me know what you think.
« Last Edit: April 08, 2007, 01:03:32 PM by saquivor »

Offline saquivor

  • BFF
  • ***
  • Posts: 110
    • View Profile
Docs
« Reply #1 on: November 23, 2006, 06:48:38 AM »
As promised, here is my bash script, it may suck but it does the job I wanted it to. If anyone would like to point out how to improve the script, please let me know.



bash code:

#/!/bin/bash
# what happend to ksh!
# should be run from doc folder on ds2
# suggestions to saquivor@monkeyx.net


#change to your mudlib doc folders
myDocSourceFolder='/home/ds2.1a15/lib/doc'
mydelim='-----------------------------------------------------------------------------------\n'
#change to writable folder on your system
myTargetfolder='/home/ds2.1a15/saquivor'
BookCount=0;
myExt='txt'

#create target folder use if ? fi
if [ ! -d $myTargetfolder ]
then
   mkdir $myTargetfolder
fi

#Create Contents Page
echo -e $mydelim  >$myTargetfolder/1contents.$myExt
echo -e Contents '\n' >>$myTargetfolder/1contents.$myExt
echo -e >>$myTargetfolder/1contents.$myExt

# Merge files in every folder to a single text file
# Also add book name to files and contents
for item in $(ls -d */ )
do
   # will replace with awk/cut in find to avoid this!
   # cut/awk tips provided by Andrew@Nanvaent
   a=`expr length $item`
   a=$((a - 1))
   b=`expr substr $item 1 $a`
   count=$((count + 1))
   echo -e $mydelim >>$myTargetfolder/1contents.$myExt
   echo -e Book Number - $count - $b '\n' >>$myTargetfolder/1contents.$myExt
   echo -e $mydelim >$myTargetfolder/$b.$myExt
   echo -e Book Number - $count - $item '\n' >>$myTargetfolder/$b.$myExt
   echo -e $mydelim >>$myTargetfolder/$b.$myExt
   find $b -depth -exec cat {} \; >>$myTargetfolder/$b.$myExt
done
echo -e $mydelim >>$myTargetfolder/1contents.$myExt
wait

#Convert Text files to ps format
for fitem in $myTargetfolder/*.$myExt
do
   groff $fitem > $fitem.ps
done
wait
cd $myTargetfolder

#Convert Text files to pdfformat
for fitem in *.ps
do
   ps2pdf $fitem   
done
wait

#This section creates one big file from all docs and removes ps files as they use more space.
cd $myTargetfolder
cat $myTargetfolder/*.txt >fulldocs.txt
wait
groff $myTargetfolder/fulldocs.txt > $myTargetfolder/fulldocs.ps
wait
ps2pdf $myTargetfolder/fulldocs.ps
rm $myTargetfolder/*.ps


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Docs
« Reply #2 on: November 23, 2006, 07:57:08 AM »
Thank you for the contribution!