mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Command line interface documentation added to User Manual
This commit is contained in:
parent
2d6c394ba8
commit
e95a7902e0
@ -110,6 +110,8 @@ class OptionParser(_OptionParser):
|
|||||||
epilog=_('Created by ')+terminal_controller.RED+__author__+terminal_controller.NORMAL,
|
epilog=_('Created by ')+terminal_controller.RED+__author__+terminal_controller.NORMAL,
|
||||||
gui_mode=False,
|
gui_mode=False,
|
||||||
**kwds):
|
**kwds):
|
||||||
|
usage += '''\n\nWhenever you pass arguments to %prog that have spaces in them, '''\
|
||||||
|
'''enclose the arguments in quotation marks.'''
|
||||||
_OptionParser.__init__(self, usage=usage, version=version, epilog=epilog,
|
_OptionParser.__init__(self, usage=usage, version=version, epilog=epilog,
|
||||||
formatter=CustomHelpFormatter(), **kwds)
|
formatter=CustomHelpFormatter(), **kwds)
|
||||||
self.gui_mode = gui_mode
|
self.gui_mode = gui_mode
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import sys, os, logging, shutil, tempfile, glob
|
import sys, os, logging, shutil, tempfile, glob
|
||||||
|
|
||||||
from libprs500.ebooks import UnknownFormatError
|
from libprs500.ebooks import UnknownFormatError
|
||||||
from libprs500.ebooks.lrf import option_parser
|
from libprs500.ebooks.lrf import option_parser as _option_parser
|
||||||
from libprs500 import __appname__, setup_cli_handlers, extract
|
from libprs500 import __appname__, setup_cli_handlers, extract
|
||||||
from libprs500.ebooks.lrf.lit.convert_from import process_file as lit2lrf
|
from libprs500.ebooks.lrf.lit.convert_from import process_file as lit2lrf
|
||||||
from libprs500.ebooks.lrf.pdf.convert_from import process_file as pdf2lrf
|
from libprs500.ebooks.lrf.pdf.convert_from import process_file as pdf2lrf
|
||||||
@ -148,14 +148,18 @@ def process_file(path, options, logger=None):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main(args=sys.argv, logger=None, gui_mode=False):
|
def option_parser(gui_mode=False):
|
||||||
parser = option_parser(usage='''\
|
return _option_parser(usage='''\
|
||||||
any2lrf myfile
|
any2lrf myfile
|
||||||
|
|
||||||
Convert any ebook format into LRF. Supported formats are:
|
Convert any ebook format into LRF. Supported formats are:
|
||||||
LIT, RTF, TXT, HTML, EPUB, MOBI, PRC and PDF. any2lrf will also process a RAR or
|
LIT, RTF, TXT, HTML, EPUB, MOBI, PRC and PDF. any2lrf will also process a RAR or
|
||||||
ZIP archive.
|
ZIP archive, looking for an ebook inside the archive.
|
||||||
''', gui_mode=gui_mode)
|
''', gui_mode=gui_mode)
|
||||||
|
|
||||||
|
|
||||||
|
def main(args=sys.argv, logger=None, gui_mode=False):
|
||||||
|
parser = option_parser(gui_mode)
|
||||||
options, args = parser.parse_args(args)
|
options, args = parser.parse_args(args)
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
@ -1823,7 +1823,10 @@ def try_opf(path, options, logger):
|
|||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
return lrf_option_parser('''Usage: %prog [options] mybook.html\n\n'''
|
return lrf_option_parser('''Usage: %prog [options] mybook.html\n\n'''
|
||||||
'''%prog converts mybook.html to mybook.lrf''')
|
'''%prog converts mybook.html to mybook.lrf. '''
|
||||||
|
'''html2lrf follows all links in mybook.html that point '''
|
||||||
|
'''to local files recursively. Thus, you can use it to '''
|
||||||
|
'''convert a whole tree of HTML files.''')
|
||||||
|
|
||||||
def main(args=sys.argv):
|
def main(args=sys.argv):
|
||||||
try:
|
try:
|
||||||
|
@ -34,7 +34,7 @@ class DefaultProfile(object):
|
|||||||
delay = 0 # Delay between consecutive downloads
|
delay = 0 # Delay between consecutive downloads
|
||||||
timeout = 10 # Timeout for fetching files from server in seconds
|
timeout = 10 # Timeout for fetching files from server in seconds
|
||||||
timefmt = ' [%a %d %b %Y]' # The format of the date shown on the first page
|
timefmt = ' [%a %d %b %Y]' # The format of the date shown on the first page
|
||||||
url_search_order = ['guid', 'link'] # THe order of elements to search for a URL when parssing the RSS feed
|
url_search_order = ['guid', 'link'] # The order of elements to search for a URL when parssing the RSS feed
|
||||||
pubdate_fmt = None # The format string used to parse the publication date in the RSS feed. If set to None some default heuristics are used, these may fail, in which case set this to the correct string or re-implement strptime in your subclass.
|
pubdate_fmt = None # The format string used to parse the publication date in the RSS feed. If set to None some default heuristics are used, these may fail, in which case set this to the correct string or re-implement strptime in your subclass.
|
||||||
use_pubdate = True, # If True will look for a publication date for each article. If False assumes the publication date is the current time.
|
use_pubdate = True, # If True will look for a publication date for each article. If False assumes the publication date is the current time.
|
||||||
summary_length = 500 # Max number of characters in the short description (ignored in DefaultProfile)
|
summary_length = 500 # Max number of characters in the short description (ignored in DefaultProfile)
|
||||||
|
@ -601,8 +601,11 @@ class OPFCreator(OPF):
|
|||||||
|
|
||||||
self._commit(doc)
|
self._commit(doc)
|
||||||
|
|
||||||
|
def option_parser():
|
||||||
|
return get_parser('opf')
|
||||||
|
|
||||||
def main(args=sys.argv):
|
def main(args=sys.argv):
|
||||||
parser = get_parser('opf')
|
parser = option_parser()
|
||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
@ -177,9 +177,11 @@ def set_metadata(stream, options):
|
|||||||
stream.write(src)
|
stream.write(src)
|
||||||
stream.write(after)
|
stream.write(after)
|
||||||
|
|
||||||
|
def option_parser():
|
||||||
|
return get_parser('rtf')
|
||||||
|
|
||||||
def main(args=sys.argv):
|
def main(args=sys.argv):
|
||||||
parser = get_parser('rtf')
|
parser = option_parser()
|
||||||
options, args = parser.parse_args(args)
|
options, args = parser.parse_args(args)
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
QTDIR=/usr/local/Trolltech/Qt-4.4.0-tp1
|
|
||||||
QCG=${QTDIR}/bin/qcollectiongenerator
|
|
||||||
ASSISTANT=${QTDIR}/bin/assistant_new
|
|
||||||
LD_LIBRARY_PATH=${QTDIR}/lib
|
|
||||||
|
|
||||||
all : clean
|
|
||||||
python preprocess.py
|
|
||||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${QCG} libprs500.qhcp && \
|
|
||||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${ASSISTANT} -collectionFile libprs500.qhc &
|
|
||||||
|
|
||||||
clean :
|
|
||||||
rm -rf *.qhc *.qch ~/.assistant/libprs500.qhc
|
|
@ -16,7 +16,7 @@
|
|||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
''''''
|
''''''
|
||||||
|
|
||||||
import sys, glob, mechanize, time, subprocess, os, re
|
import sys, glob, mechanize, time, subprocess, os, re, shutil
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from xml.etree.ElementTree import parse, tostring, fromstring
|
from xml.etree.ElementTree import parse, tostring, fromstring
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
@ -73,9 +73,22 @@ def clean():
|
|||||||
for f in glob.glob(pat):
|
for f in glob.glob(pat):
|
||||||
f = os.path.abspath(os.path.expanduser(f))
|
f = os.path.abspath(os.path.expanduser(f))
|
||||||
if os.path.exists(f):
|
if os.path.exists(f):
|
||||||
if os.path.isfile(f):
|
if os.path.isdir(f):
|
||||||
|
shutil.rmtree(f)
|
||||||
|
else:
|
||||||
os.unlink(f)
|
os.unlink(f)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def compile_help():
|
||||||
|
QTDIR = '/usr/local/Trolltech/Qt-4.4.0-tp1'
|
||||||
|
QTBIN = QTDIR + '/bin'
|
||||||
|
QTLIB = QTDIR + '/lib'
|
||||||
|
QCG = os.path.join(QTBIN, 'qcollectiongenerator')
|
||||||
|
QTA = os.path.join(QTBIN, 'assistant_new')
|
||||||
|
os.environ['LD_LIBRARY_PATH'] = QTLIB
|
||||||
|
subprocess.check_call((QCG, 'libprs500.qhcp'))
|
||||||
|
subprocess.call((QTA, '-collectionFile', 'libprs500.qhc'))
|
||||||
|
|
||||||
|
|
||||||
def generate_cli_docs(src='libprs500.qhp'):
|
def generate_cli_docs(src='libprs500.qhp'):
|
||||||
documented_cmds = []
|
documented_cmds = []
|
||||||
@ -144,7 +157,7 @@ def generate_cli_docs(src='libprs500.qhp'):
|
|||||||
|
|
||||||
body = '<h1 class="documentHeading">The Command Line Interface</h1>\n'
|
body = '<h1 class="documentHeading">The Command Line Interface</h1>\n'
|
||||||
body += '<div style="text-align:center"><img src="images/cli.png" /></div>'
|
body += '<div style="text-align:center"><img src="images/cli.png" /></div>'
|
||||||
body += '<p>%s</p>\n'%'libprs500 has a very comprehensive command line interface to perform most operations that can be performed by the GUI.'
|
body += '<p>%s</p>\n'%'<b class="cmd">libprs500</b> has a very comprehensive command line interface to perform most operations that can be performed by the GUI.'
|
||||||
body += '<h2 class="sectionHeading">Documented commands</h2>\n'+dc_html
|
body += '<h2 class="sectionHeading">Documented commands</h2>\n'+dc_html
|
||||||
body += '<h2 class="sectionHeading">Undocumented commands</h2>\n'+uc_html
|
body += '<h2 class="sectionHeading">Undocumented commands</h2>\n'+uc_html
|
||||||
body += '<p>You can see usage for undocumented commands by executing them without arguments in a terminal</p>'
|
body += '<p>You can see usage for undocumented commands by executing them without arguments in a terminal</p>'
|
||||||
@ -185,11 +198,10 @@ def create_html_interface(src='libprs500.qhp'):
|
|||||||
def process_branch(branch, toplevel=False):
|
def process_branch(branch, toplevel=False):
|
||||||
parent = []
|
parent = []
|
||||||
for sec in branch.findall('section'):
|
for sec in branch.findall('section'):
|
||||||
html = '<li class="||||">\n<a target="content" href="%s">%s</s>\n</li>\n'%(sec.attrib['ref'], sec.attrib['title'])
|
html = '<li class="||||">\n<a target="content" href="%s">%s</a>\n</li>\n'%(sec.attrib['ref'], sec.attrib['title'])
|
||||||
if toplevel:
|
lc = 'toplevel' if toplevel else 'nottoplevel'
|
||||||
html=html.replace('<li', '<li class="toplevel"')
|
html=html.replace('||||', '%s ||||'%lc)
|
||||||
else:
|
|
||||||
html=html.replace('<li', '<li class="nottoplevel"')
|
|
||||||
type = 'file'
|
type = 'file'
|
||||||
if not is_leaf(sec):
|
if not is_leaf(sec):
|
||||||
html = html.replace('</li>','%s\n</li>'%process_branch(sec))
|
html = html.replace('</li>','%s\n</li>'%process_branch(sec))
|
||||||
@ -204,18 +216,25 @@ def create_html_interface(src='libprs500.qhp'):
|
|||||||
tree = process_branch(toc, True)
|
tree = process_branch(toc, True)
|
||||||
|
|
||||||
template = open('templates/navtree.html').read()
|
template = open('templates/navtree.html').read()
|
||||||
open('navtree.html', 'wb').write(template.replace('%tree', tree))
|
open('navtree.html', 'wb').write(template.replace('%tree', tree)+'\n')
|
||||||
|
|
||||||
|
|
||||||
def main(args=sys.argv):
|
def all(args=sys.argv):
|
||||||
generate_cli_docs()
|
generate_cli_docs()
|
||||||
update_manifest()
|
update_manifest()
|
||||||
create_html_interface()
|
create_html_interface()
|
||||||
#validate_html()
|
compile_help()
|
||||||
|
validate_html()
|
||||||
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
if len(sys.argv) == 1:
|
||||||
|
clean()
|
||||||
|
sys.exit(all())
|
||||||
|
elif len(sys.argv) == 2:
|
||||||
|
func = eval(sys.argv[1])
|
||||||
|
if func is None:
|
||||||
|
print >>sys.stderr, 'Unknown target', sys.argv(1)
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(func())
|
@ -1,11 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
|
||||||
<head>
|
<head>
|
||||||
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
|
||||||
<link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.css" type="text/css" />
|
<link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.css" type="text/css">
|
||||||
<link rel="stylesheet" href="styles/common.css" type="text/css" />
|
<link rel="stylesheet" href="styles/common.css" type="text/css">
|
||||||
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.js"></script>
|
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.js"></script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#browser {
|
#browser {
|
||||||
@ -18,12 +17,12 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#browser").treeview({collapsed:true});
|
$("#browser").treeview({collapsed:true});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<title>libprs500 User Manual</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2 class="documentHeading">libprs500 Manual</h2>
|
<h2 class="documentHeading">libprs500 Manual</h2>
|
||||||
@ -31,14 +30,15 @@
|
|||||||
%tree
|
%tree
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr />
|
<hr>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>
|
<p>
|
||||||
<a href="http://validator.w3.org/check?uri=referer">
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
<img src="images/valid.png" alt="Valid XHTML 1.1" height="31" width="88" />
|
<img src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01 Transitional" height="31" width="88">
|
||||||
</a><br />
|
</a><br>
|
||||||
Created by Kovid Goyal © 2008
|
Created by Kovid Goyal © 2008
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user