First you have to create a file and write the actual text for the man page, using some special tags, the most important can be found here. This is the main step of the creation of the man page, and where you should spend most of the time.
So that you can check how your man page will look while you're writing it and/or after you've written it, there is a very useful program,
nroff
, that is used the following way:nroff -e -mandoc yourFile | less -s
Once you feel your page is as you want it, you'll have to rename your file to XXX.1 (or any other number from 1 to 8, according to this standard) and then compress it using
gzip
or bzip2
. Your man page is now ready!If you try the command
man yourFile
, you'll notice it doesn't work. That's because you're man page isn't in the MANPATH
yet. To do this you'll first have to move your file to a directory with the name manX, being X the number you chose from the 8 possible (it is normal to have a directory called man and all the manX directories to be it's children). So, let's do that:mkdir path/to/program/man
mkdir path/to/program/man/man1
mv yourFile.1.gz path/to/program/man/man1
The last thing to be done is actually adding your man folder to the
MANPATH
, if it isn't already added. The first thing to do is check if you have to add it or not:echo $MANPATH (Just to check if the folder is in the current MANPATH)
export MANPATH=path/to/program/man:$MANPATH
Instead of doing this, if you have root privileges, you can create a directory in one of the directories already pointed by the
MANPATH
, like /usr/share/man
.And that's it! Go try it out!
No comments:
Post a Comment