"Fossies" - the Fresh Open Source Software Archive

Member "zim-0.70/makeman.py" (14 Mar 2019, 1776 Bytes) of package /linux/privat/zim-0.70.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "makeman.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.69.1_vs_0.70.

    1 #!/usr/bin/python3
    2 
    3 
    4 # Copyright 2009 Jaap Karssenberg <jaap.karssenberg@gmail.com>
    5 
    6 import os
    7 
    8 from time import strftime, gmtime, time
    9 from locale import setlocale, LC_TIME
   10 
   11 from zim import __version__, __url__, \
   12     __author__, __copyright__, __license__
   13 from zim.main import HelpCommand
   14 
   15 
   16 def get_about():
   17     '''Get the tagline and short description from the README'''
   18     readme = open('README.md')
   19     lines = []
   20     for line in readme:
   21         if line.startswith('## '):
   22             break # next header
   23         elif line.startswith('====') or line.startswith('!['):
   24             pass # skip images and header underline
   25         else:
   26             lines.append(line)
   27 
   28     lines = ''.join(lines).strip().splitlines(True)
   29     assert lines and lines[0].startswith('Zim - ')
   30     tagline = lines[0][6:].strip()
   31     about = ''.join(lines[1:]).strip()
   32 
   33     return tagline, about
   34 
   35 
   36 def make():
   37     '''Generate man page for zim'''
   38 
   39     tagline, about = get_about()
   40     try:
   41         os.mkdir('man')
   42     except OSError:
   43         pass # dir already exists
   44     setlocale(LC_TIME, "C")
   45     manpage = open('man/zim.1', 'w')
   46     manpage.write('.TH ZIM "1" "%s" "zim %s" "User Commands"\n' % (strftime('%B %Y', gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time())))), __version__))
   47     manpage.write('.SH NAME\nzim \\- %s\n\n' % tagline)
   48     manpage.write('.SH SYNOPSIS\n%s\n' % HelpCommand.usagehelp.replace('-', r'\-'))
   49     manpage.write('.SH DESCRIPTION\n%s\n' % about)
   50     manpage.write('.SH OPTIONS\n%s\n' % HelpCommand.optionhelp.replace('-', r'\-'))
   51     manpage.write('.SH AUTHOR\n%s\n\n' % __author__)
   52     manpage.write( '''\
   53 .SH "SEE ALSO"
   54 The full documentation for
   55 .B zim
   56 is maintained as a zim notebook. The command
   57 .IP
   58 .B zim --manual
   59 .PP
   60 should give you access to the complete manual.
   61 
   62 The website for
   63 .B zim
   64 can be found at
   65 .I %s
   66 ''' % __url__)
   67     manpage.close()
   68 
   69 
   70 if __name__ == '__main__':
   71     make()