From 579adf26d65fe6eea7751ea5c80f55430f96e26c Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Thu, 20 Oct 2022 04:06:38 +0200 Subject: [PATCH] Made the root of the man pages selectable in the CLI. Some fixes. --- Makefile | 2 +- README.md | 6 +++--- man2book | 17 +++++++++++------ template/cover.html | 0 template/foot.html | 0 template/head.html | 3 +++ template/index.html | 5 +++++ 7 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 template/cover.html create mode 100644 template/foot.html create mode 100644 template/head.html create mode 100644 template/index.html diff --git a/Makefile b/Makefile index 9fb8aab..19ee0c2 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,3 @@ clean: - rm -rf ./output/*.html + rm -rf ./out/* rm -rf ./tmp/* diff --git a/README.md b/README.md index ac5c5d2..c0655d6 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ feature ides: - Maybe support for other converters / generators. - Links to other man pages as mentioned in the footer of all man pages, e.g.: pam(8). But only if available in the current book. -- Maybe a progress bar instead of printing for every file being processed. -(https://www.geeksforgeeks.org/progress-bars-in-python/) +- Maybe a progress bar instead of printing for every file being processed +(https://www.geeksforgeeks.org/progress-bars-in-python/). ## Bugs @@ -89,4 +89,4 @@ path somewhere?). ## Links - [The Linux man-pages project](https://www.kernel.org/doc/man-pages/) - I found this -project after researching a little for my idea and inspired me a lot to start my project. +project after researching a little for my idea and it inspired me a lot to start my project. diff --git a/man2book b/man2book index 172ceba..8d83103 100755 --- a/man2book +++ b/man2book @@ -32,9 +32,7 @@ __author__ = 'Johannes Findeisen ' # currently i only increase the third number because i commit early and often and nearly on every # commit there are new features. 0.2.0 will be ready for generating a full book. then i will use the # pythonic version scheme. -__version__ = '0.1.1' - -MANPAGE_PATH = '/usr/share/man/' +__version__ = '0.1.2' def main(): @@ -62,13 +60,16 @@ def main(): 'each manpage! e.g. df.1. it is not very ' 'important actually.') + parser.add_argument('-p', '--path', help='path to the root of the man pages. (default: ' + '/usr/share/man/)') + parser.add_argument('-s', '--sections', help='the manpage sections. e.g. 8 or a list like ' '1,2,3') parser.add_argument('target_directory', metavar='TARGET_DIRECTORY', help='the target directory for the output. it must contain two directories.' - 'one is the directory for tempory file output (tmp/) and one for the ' - 'final processing result (out).') + 'one is the directory for temporary file output (tmp/) and one for ' + 'the final processing result (out).') parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + str(__version__)) @@ -77,6 +78,10 @@ def main(): args = parser.parse_args() + manpage_path = '/usr/share/man/' + if args.path: + manpage_path = args.path + output_dir = args.target_directory + 'out/' sections = ['1', '2', '3', '4', '5', '6', '7', '8'] tmp_dir = args.target_directory + 'tmp/' @@ -110,7 +115,7 @@ def main(): if args.debug: print('manpage_files: ' + str(manpage_files)) else: - manpage_files = os.listdir(MANPAGE_PATH + 'man' + section + '/') + manpage_files = os.listdir(manpage_path + 'man' + section + '/') args_limit = len(args_manpages) if args.limit: diff --git a/template/cover.html b/template/cover.html new file mode 100644 index 0000000..e69de29 diff --git a/template/foot.html b/template/foot.html new file mode 100644 index 0000000..e69de29 diff --git a/template/head.html b/template/head.html new file mode 100644 index 0000000..9802eaa --- /dev/null +++ b/template/head.html @@ -0,0 +1,3 @@ + + $TITLE + \ No newline at end of file diff --git a/template/index.html b/template/index.html new file mode 100644 index 0000000..bb66ca8 --- /dev/null +++ b/template/index.html @@ -0,0 +1,5 @@ + + + + $HEAD +