def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 2: print(__doc__, file=sys.stderr) return 1 if argv[1] in ('-h', '--help'): print(__doc__, file=sys.stdout) return 0 rstlist_file = argv[1] gm_topdir = None if len(argv) >= 3: gm_topdir = argv[2] outfile_dir = None if len(argv) >= 4: outfile_dir = argv[3] if not gm_topdir: # NOTE: the following is predicated on the directory structure of the # GraphicsMagick source tree. It assumes this script resides in # TOPDIR/scripts and the .c files referred to by the whatis file # reside in TOPDIR/magick current_dir = os.path.dirname(os.path.abspath(__file__)) gm_topdir = os.path.normpath(os.path.join(current_dir, '..')) if not outfile_dir: outfile_dir = gm_topdir f = file(rstlist_file, 'r') cnt = 0 for line in f: cnt += 1 line = line.strip() if not line: continue if line.startswith('#'): continue try: rstfile, outfile, stylesheet_url, url_prefix = line.split(None, 3) except ValueError: print("Line %u of %s: improper format" % (cnt, rstlist_file), file=sys.stderr) return 1 rstfile_path = os.path.join(gm_topdir, rstfile.strip()) outfile_path = os.path.join(outfile_dir, outfile.strip()) args = [ '--link-stylesheet=%s' % stylesheet_url, '--url-prefix=%s' % url_prefix, rstfile_path, outfile_path ] print('rst2htmldeco.py %s' % ' '.join(args)) rst2htmldeco.main(args) f.close()
def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 2: print >> sys.stderr, __doc__ return 1 if argv[1] in ('-h', '--help'): print >> sys.stdout, __doc__ return 0 rstlist_file = argv[1] gm_topdir = None if len(argv) >= 3: gm_topdir = argv[2] outfile_dir = None if len(argv) >= 4: outfile_dir = argv[3] if not gm_topdir: # NOTE: the following is predicated on the directory structure of the # GraphicsMagick source tree. It assumes this script resides in # TOPDIR/scripts and the .c files referred to by the whatis file # reside in TOPDIR/magick current_dir = os.path.dirname(os.path.abspath(__file__)) gm_topdir = os.path.normpath(os.path.join(current_dir, '..')) if not outfile_dir: outfile_dir = gm_topdir f = file(rstlist_file, 'r') cnt = 0 for line in f: cnt += 1 line = line.strip() if not line: continue if line.startswith('#'): continue try: rstfile, outfile, stylesheet_url, url_prefix = line.split(None, 3) except ValueError: print >> sys.stderr, "Line %u of %s: improper format" % (cnt, rstlist_file) return 1 rstfile_path = os.path.join(gm_topdir, rstfile.strip()) outfile_path = os.path.join(outfile_dir, outfile.strip()) args = ['--link-stylesheet=%s' % stylesheet_url, '--url-prefix=%s' % url_prefix, rstfile_path, outfile_path] print 'rst2htmldeco.py %s' % ' '.join(args) rst2htmldeco.main(args) f.close()
def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 2: print >> sys.stderr, __doc__ return 1 if argv[1] in ('-h', '--help'): print __doc__ return 0 whatis_file = argv[1] gm_topdir = None if len(argv) >= 3: gm_topdir = argv[2] outfile_dir = None if len(argv) >= 4: outfile_dir = argv[3] current_dir = os.path.dirname(os.path.abspath(__file__)) if not gm_topdir: # NOTE: the following is predicated on the directory structure of the # GraphicsMagick source tree. It assumes this script resides in # TOPDIR/scripts and the .c files referred to by the whatis file # reside in TOPDIR/magick gm_topdir = os.path.normpath(os.path.join(current_dir, '..')) srcfile_dir = os.path.join(gm_topdir, 'magick') if not outfile_dir: outfile_dir = os.path.join(gm_topdir, 'www', 'api') f = file(whatis_file, 'r') cnt = 0 for line in f: cnt += 1 if not line.strip(): continue if line.startswith('#'): continue try: cfile, whatis = line.split(None, 1) except ValueError: print >> sys.stderr, "Line %u of %s: improper format" % ( cnt, whatis_file) return 1 srcfile_path = os.path.join(srcfile_dir, cfile) srcfile = os.path.basename(srcfile_path) base, ext = os.path.splitext(srcfile) rstfile = base + '.rst' rstfile_path = os.path.join(outfile_dir, rstfile) htmlfile = base + '.html' htmlfile_path = os.path.join(outfile_dir, htmlfile) args = ['-w', whatis_file, srcfile_path, rstfile_path] print 'format_c_api_doc.py', ' '.join(args) format_c_api_doc.main(args) # Now generate HTML from the .rst files args = [ '--link-stylesheet=%s' % stylesheet_url, '--url-prefix=%s' % url_prefix, rstfile_path, htmlfile_path ] print 'rst2htmldeco.py %s' % ' '.join(args) rst2htmldeco.main(args) print 'rm', rstfile_path os.unlink(rstfile_path) f.close()
def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 2: print >> sys.stderr, __doc__ return 1 if argv[1] in ('-h', '--help'): print __doc__ return 0 whatis_file = argv[1] gm_topdir = None if len(argv) >= 3: gm_topdir = argv[2] outfile_dir = None if len(argv) >= 4: outfile_dir = argv[3] current_dir = os.path.dirname(os.path.abspath(__file__)) if not gm_topdir: # NOTE: the following is predicated on the directory structure of the # GraphicsMagick source tree. It assumes this script resides in # TOPDIR/scripts and the .c files referred to by the whatis file # reside in TOPDIR/magick gm_topdir = os.path.normpath(os.path.join(current_dir, '..')) srcfile_dir = os.path.join(gm_topdir, 'magick') if not outfile_dir: outfile_dir = os.path.join(gm_topdir, 'www', 'api') f = file(whatis_file, 'r') cnt = 0 for line in f: cnt += 1 if not line.strip(): continue if line.startswith('#'): continue try: cfile, whatis = line.split(None, 1) except ValueError: print >> sys.stderr, "Line %u of %s: improper format" % (cnt, whatis_file) return 1 srcfile_path = os.path.join(srcfile_dir, cfile) srcfile = os.path.basename(srcfile_path) base, ext = os.path.splitext(srcfile) rstfile = base + '.rst' rstfile_path = os.path.join(outfile_dir, rstfile) htmlfile = base + '.html' htmlfile_path = os.path.join(outfile_dir, htmlfile) args = ['-w', whatis_file, srcfile_path, rstfile_path] print 'format_c_api_doc.py', ' '.join(args) format_c_api_doc.main(args) # Now generate HTML from the .rst files args = ['--link-stylesheet=%s' % stylesheet_url, '--url-prefix=%s' % url_prefix, rstfile_path, htmlfile_path] print 'rst2htmldeco.py %s' % ' '.join(args) rst2htmldeco.main(args) print 'rm', rstfile_path os.unlink(rstfile_path) f.close()