A portable command-line utility for generating a man-page equivalent for your custom project.
Tired of looking throughout the build directory of your project for the functions you wrote weeks before or don't remember their parameters. Want to find a quick way of querying functions and modules while displaying them like the on-line man pages?
manp is a command-line utility that lets you create a man pages equivalent documentation of your project. This is similar to how man printf works for C/C++ functions. But, now you can manp [YOUR_FUNCTIONS] from your source code instead.
All files of extension TARGET_FILE_EXTN are recursively searched inside the manp/target_data folder and added to the data section of the manp in the form of header includes.
If incorrect modules are entered, manp also has a feature for auto-suggesting most similar named module.
Running make without setting any SOURCE_DIR or TARGET_FILE_EXTN creates a default manp portable executable with documentation for the Python standard library modules and functions.
Requirements:
- Python 3.5+
- g++ compiler
- bash shell
For OSX and Linux Only
- Clone the repository.
- Set the
SOURCE_DIR(Absolute path to your build directory) andTARGET_FILE_EXTN(File extensions added tomanp, separated by a single space inside double quotes) inside themakefile_configuration.mkfile. TheSOURCE_DIRcan be specified to any directory, the make commands recursively search through the source to find all files of the extensionTARGET_FILE_EXTN. TheREPLACE_OLD_TARGETvariable, if set toTruewill clean thetarget_datafolder before make. - After the Use
makefile_configuration.mkconfig file has been properly set,manpcan be compiled and the execute permissions be set. ( The original download from GitHub builds amanpPython documentation )
make all
chmod a+x manpNote: If the .mk config file is not changed, the make command can also be run like so:
make SOURCE_DIR=/usr/project/src TARGET_FILE_EXTN="txt py md"-
Add the
manpexecutable toPATHvar for faster execution so thatmanpcan be called using abashshell from any directory and speeds documentation lookup.-
Recommended:
manpcan be indirectly added to the currentPATHvariable by creating a symlink to/usr/local/binusing the absoute path of themanpexecutable.ln -s /[ABSOLUTE_PATH]/manp /usr/local/bin
Note: If the original location of the
manpexecutable is changed, the soft link must be updated again with the above command. -
Alternative:
copy
manpto/usr/local/binwith:cp manp /usr/local/bin
Note: Every time, there is a change to the source code, the
manpbinary will have to be recopied tousr/local/bin.
-
Note: If there are any permission issues, use sudo. The manp executable can be directly added to the PATH var if sudo access is not present.
Only for Python projects as of now:
The python generate_txt_from_python_progs.py function can be used to generate txt files containing information on individual functions and classes, the source folder is denoted by [SOURCE_FILE_DIR] while the target folder is denoted by [TARGET_DIRECTORY].
python generate_funcs_from_modules [SOURCE_FILENAME] [TARGET_DIRECTORY]
python generate_txt_from_python_progs.py [SOURCE_FILE_DIR] [TARGET_DIRECTORY]Support for more projects will be added in the future
To remove the manp symlink from /usr/local/bin:
rm /usr/local/bin/manpor,
unlink /usr/local/bin/manpNote: If there are permission errors, use sudo. The symlink can be manually deleted as well
To get documentation for a artifact present in the SOURCE_DIR:
manp [MODULE_OR_FUNCTION_NAME]Example: (For the default Python std lib documentation)
manp zlibTo display help:
manp -hTo display list of all available documented artifacts:
manp -lA detailed explanation of how the program functions:
The program requires compilation and running of certain files and script before others which is handled by the Makefile.
-
The
text_to_raw_string.cppandraw_string_to_text.cppmodules are compiled before main. Thetext_to_raw_string.cppconverts all the files inside theSOURCE_DIRfolder tomanp/target_data/folder as raw string literal txt files padded with extraCPP_MAP_KEY_VALUE_DELIMandCPP_MAP_MODULE_DELIM(defined incommon.h) delimiters for creating C++ maps. -
After this, the
generate_doc_artifacts_list.shwill iterate through themanp/target_data/folder and createcombined_txt_include.hthat includes all thetxtraw string literal files in one header file anddoc_artifacts_listheader include file containing just the names of all the modules from thetarget_datafolder. -
The
main.cppfunction will finally be compiled along withSpellingCorrector.cppandmanpwill be available for execution. -
Once the
manpis added to thePATHvar one way or another, it can be used asmanp abs.
-
To add documentations manually, txt files with the name of the module in question should be added to the
SOURCE_DIRfolder and the project should be recompiled. -
To change documentation or source code files back to normal text format, run
./raw_string_to_text data.
- All documentations imported from the Python Software Foundation Official Documentation https://www.python.org/psf/
- Peter Norvig's How to Write a Spelling Corrector
- Felipe Farinon's C++ implementation of Peter Norvig's Spell Correcter felipe.farinon@gmail.com
I am not the creator of the SpellingCorrector C++ modules. The SpellingCorrector module used in this project was first written by Peter Norvig in Python and then converted to C++ by Felipe Farinon.
