This commit is contained in:
Kovid Goyal 2008-02-26 08:28:18 +00:00
parent 262e81a905
commit 1a8e645c22
10 changed files with 286 additions and 17 deletions

View File

@ -7,7 +7,7 @@
<meta name="author" content="Kovid Goyal" />
<meta name="copyright" content="2008 Kovid Goyal" />
<title>The Graphical User Interface</title>
<link rel="stylesheet" type="text/css" href="common.css" />
<link rel="stylesheet" type="text/css" href="styles/common.css" />
</head>
<body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -2,7 +2,7 @@
<QHelpCollectionProject version="1.0">
<assistant>
<title>libprs500 Help</title>
<startPage>qthelp://libprs500/manual/index.html</startPage>
<startPage>qthelp://libprs500/manual/start.html</startPage>
<applicationIcon>../gui2/images/library.png</applicationIcon>
<enableFilterFunctionality>false</enableFilterFunctionality>
<enableDocumentationManager>false</enableDocumentationManager>

View File

@ -10,16 +10,61 @@
<filterAttribute>libprs500</filterAttribute>
<toc>
<section ref="index.html" title="Start" />
<section ref="gui.html" title="Using the GUI">
<section ref="start.html" title="Start" />
<section ref="gui.html" title="The Graphical User Interface">
<section ref="gui.html#actions" title="Actions" />
</section>
<section ref="cli-index.html" title="The Command Line Interface">
<section ref="cli-any2lrf.html" title="any2lrf" />
<section ref="cli-epub2lrf.html" title="epub2lrf" />
<section ref="cli-html2lrf.html" title="html2lrf" />
<section ref="cli-isbndb.html" title="isbndb" />
<section ref="cli-librarything.html" title="librarything" />
<section ref="cli-lit2lrf.html" title="lit2lrf" />
<section ref="cli-lrf-meta.html" title="lrf-meta" />
<section ref="cli-lrf2html.html" title="lrf2html" />
<section ref="cli-lrf2lrs.html" title="lrf2lrs" />
<section ref="cli-lrs2lrf.html" title="lrs2lrf" />
<section ref="cli-mobi2lrf.html" title="mobi2lrf" />
<section ref="cli-mobi2oeb.html" title="mobi2oeb" />
<section ref="cli-opf-meta.html" title="opf-meta" />
<section ref="cli-pdf2lrf.html" title="pdf2lrf" />
<section ref="cli-pdfreflow.html" title="pdfreflow" />
<section ref="cli-rtf-meta.html" title="rtf-meta" />
<section ref="cli-rtf2lrf.html" title="rtf2lrf" />
<section ref="cli-txt2lrf.html" title="txt2lrf" />
<section ref="cli-web2disk.html" title="web2disk" />
<section ref="cli-web2lrf.html" title="web2lrf" />
</section>
</toc>
<files>
<file>index.html</file>
<file>cli-isbndb.html</file>
<file>cli-pdfreflow.html</file>
<file>cli-mobi2lrf.html</file>
<file>cli-lrf-meta.html</file>
<file>cli-lit2lrf.html</file>
<file>cli-lrf2lrs.html</file>
<file>cli-index.html</file>
<file>cli-web2lrf.html</file>
<file>cli-lrs2lrf.html</file>
<file>cli-txt2lrf.html</file>
<file>start.html</file>
<file>cli-web2disk.html</file>
<file>gui.html</file>
<file>common.css</file>
<file>cli-opf-meta.html</file>
<file>cli-html2lrf.html</file>
<file>cli-rtf2lrf.html</file>
<file>cli-librarything.html</file>
<file>cli-epub2lrf.html</file>
<file>cli-rtf-meta.html</file>
<file>cli-pdf2lrf.html</file>
<file>cli-lrf2html.html</file>
<file>cli-any2lrf.html</file>
<file>cli-mobi2oeb.html</file>
<file>styles/common.css</file>
<file>images/edit_meta_information.png</file>
<file>images/remove_books.png</file>
<file>images/book_details.png</file>
@ -37,6 +82,7 @@
<file>images/news.png</file>
<file>images/view.png</file>
<file>images/fetch_news.png</file>
<file>images/cli.png</file>
</files>
</filterSection>

View File

@ -28,5 +28,7 @@
<item url="images/search.png" uploadstatus="1" />
<item url="libprs500.session" uploadstatus="1" />
<item url="libprs500.webprj" uploadstatus="1" />
<item url="templates/navtree.html" />
<item url="start.html" />
</project>
</webproject>

View File

@ -16,11 +16,16 @@
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''''''
import sys, glob, mechanize, time, subprocess
import sys, glob, mechanize, time, subprocess, os, re
from tempfile import NamedTemporaryFile
from xml.etree.ElementTree import parse, tostring, fromstring
from BeautifulSoup import BeautifulSoup
# Load libprs500 from source copy
sys.path[0:1] = [os.path.dirname(os.path.dirname(os.getcwdu()))]
from libprs500.linux import entry_points
def browser():
opener = mechanize.Browser()
opener.set_handle_refresh(True)
@ -32,8 +37,8 @@ def update_manifest(src='libprs500.qhp'):
root = parse(src).getroot()
files = root.find('filterSection').find('files')
files.clear()
for f in glob.glob('*.html')+glob.glob('*.css')+glob.glob('images/*'):
if f.startswith('preview'):
for f in glob.glob('*.html')+glob.glob('styles/*.css')+glob.glob('images/*'):
if f.startswith('preview') or f in ('navtree.html', 'index.html'):
continue
files.append(fromstring('<file>%s</file>'%f))
@ -46,6 +51,9 @@ def update_manifest(src='libprs500.qhp'):
def validate_html():
br = browser()
for f in glob.glob('*.html'):
if f.startswith('preview-'):
continue
print 'Validating', f
raw = open(f).read()
br.open('http://validator.w3.org/#validate_by_input')
br.form = tuple(br.forms())[2]
@ -60,12 +68,152 @@ def validate_html():
time.sleep(2)
return
def clean():
for pat in ('preview-*.html', '*.qhc', '*.qch', 'cli-*.html', '~/.assistant/libprs500*'):
for f in glob.glob(pat):
f = os.path.abspath(os.path.expanduser(f))
if os.path.exists(f):
if os.path.isfile(f):
os.unlink(f)
def generate_cli_docs(src='libprs500.qhp'):
documented_cmds = []
undocumented_cmds = []
for script in entry_points['console_scripts']:
module = script[script.index('=')+1:script.index(':')].strip()
cmd = script[:script.index('=')].strip()
module = __import__(module, fromlist=[module.split('.')[-1]])
if hasattr(module, 'option_parser'):
documented_cmds.append((cmd, getattr(module, 'option_parser')()))
else:
undocumented_cmds.append(cmd)
documented_cmds.sort(cmp=lambda x, y: cmp(x[0], y[0]))
undocumented_cmds.sort()
def sanitize_text(txt):
return txt.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
for cmd, parser in documented_cmds:
output = open('cli-%s.html'%cmd, 'wb')
template = open('templates/basic.html', 'rb').read()
usage = [sanitize_text(i) for i in parser.usage.replace('%prog', cmd).splitlines(True) if i]
usage[0] = '<pre class="runcmd">%s</pre>'%usage[0]
usage[1:] = [i.replace(cmd, '<span class="cmd">%s</span>'%cmd) for i in usage[1:]]
usage = ''.join(usage).replace('\n', '<br />')
body = ('\n<h1 class="documentHeading">%s</h1>\n'%cmd)+'<div>\n%s\n</div>'%usage
groups = {}
for grp in parser.option_groups:
groups[(grp.title, grp.description)] = grp.option_list
def group_html(title, description, option_list):
res = []
if title is not None:
res.append('<tr><th colspan="2"><h3 class="subsectionHeading">%s</h3></th></tr>'%title)
if description is not None:
res.append('<tr><td colspan="2">%s<br />&nbsp;</td></tr>'%sanitize_text(description))
for opt in option_list:
shf = ' '.join(opt._short_opts)
lgf = opt.get_opt_string()
name = '%s<br />%s'%(lgf, shf)
help = sanitize_text(opt.help) if opt.help else ''
res.append('<tr><td class="option">%s</td><td>%s</td></tr>'%(name, help))
return '\n'.join(res)
gh = [group_html(None, None, parser.option_list)]
for title, desc in groups.keys():
olist = groups[(title, desc)]
gh.append(group_html(title, desc, olist))
if ''.join(gh).strip():
body += '\n<h2 class="sectionHeading">[options]</h2>\n'
body += '\n<table class="option_table">\n%s\n</table>\n'%'\n'.join(gh)
output.write(template.replace('%body', body))
uc_html = '\n<ul class="cmdlist">\n%s</ul>\n'%'\n'.join(\
'<li>%s</li>\n'%i for i in undocumented_cmds)
dc_html = '\n<ul class="cmdlist">\n%s</ul>\n'%'\n'.join(\
'<li><a href="cli-%s.html">%s</a></li>\n'%(i[0], i[0]) for i in documented_cmds)
body = '<h1 class="documentHeading">The Command Line Interface</h1>\n'
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 += '<h2 class="sectionHeading">Documented commands</h2>\n'+dc_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>'
open('cli-index.html', 'wb').write(template.replace('%body', body))
root = parse(src).getroot()
toc = root.find('filterSection').find('toc')
sec = None
for c in toc.findall('section'):
if c.attrib['ref'] == 'cli-index.html':
sec = c
break
attr = sec.attrib.copy()
sec.clear()
sec.attrib = attr
cmds = [i[0] for i in documented_cmds]
secs = ['<section ref="cli-%s.html" title="%s" />\n'%(i, i) for i in cmds]
[sec.append(fromstring(i)) for i in secs]
raw = tostring(root, 'UTF-8')
raw = re.sub(r'(<section ref="cli-[^<>]*?/>)', r'\n \1', raw)
raw = raw.replace('</section></toc>', '\n </section>\n </toc>')
raw = raw.replace(' <section ref="cli-index.html', ' <section ref="cli-index.html')
open(src, 'wb').write(raw+'\n')
def create_html_interface(src='libprs500.qhp'):
root = parse(src).getroot()
toc = root.find('filterSection').find('toc')
def is_leaf(sec):
return not sec.findall('section')
def process_branch(branch, toplevel=False):
parent = []
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'])
if toplevel:
html=html.replace('<li', '<li class="toplevel"')
else:
html=html.replace('<li', '<li class="nottoplevel"')
type = 'file'
if not is_leaf(sec):
html = html.replace('</li>','%s\n</li>'%process_branch(sec))
type = 'folder'
parent.append(html.replace('||||', type))
html = '\n'.join(parent)
if toplevel:
return html
return '<ul>\n%s\n</ul>'%html
tree = process_branch(toc, True)
template = open('templates/navtree.html').read()
open('navtree.html', 'wb').write(template.replace('%tree', tree))
def main(args=sys.argv):
generate_cli_docs()
update_manifest()
validate_html()
create_html_interface()
#validate_html()
return 0

View File

@ -7,7 +7,7 @@
<meta name="author" content="Kovid Goyal" />
<meta name="copyright" content="&copy; 2008 Kovid Goyal" />
<title>libprs500 User Manual</title>
<link rel="stylesheet" type="text/css" href="common.css" />
<link rel="stylesheet" type="text/css" href="styles/common.css" />
</head>

View File

@ -5,12 +5,17 @@ body {
a {
text-decoration: none;
color: blue;
}
a:hover {
color: red;
}
a:visited {
color: blue;
}
.documentHeading {
text-align: center;
font-family: monospace;
@ -33,4 +38,30 @@ font-family: monospace;
font-size: x-small;
color: lightgray;
text-align: right;
}
.option {
font-family: monospace;
color: green;
}
.option_table td {
padding-bottom : 1em;
}
.cmd {
font-family: monospace;
font-weight: bold;
}
.runcmd {
background: #eeeeee;
border: inset 2px;
padding: 0.2em;
}
.cmdlist li {
font-family: monospace;
margin-bottom: 0.2em;
}

View File

@ -1,20 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"
xml:lang="en" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta name="author" content="Kovid Goyal" />
<meta name="copyright" content="&copy; 2008 Kovid Goyal" />
<title></title>
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<link rel="stylesheet" type="text/css" href="styles/common.css" />
</head>
<body>
%body
<hr />
<div class="footer">

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<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" />
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.js"></script>
<style type="text/css">
#browser {
font-family: monospace;
}
.toplevel {
font-weight: bold;
}
.nottoplevel {
font-weight: normal;
}
</style>
<script>
$(document).ready(function(){
$("#browser").treeview({collapsed:true});
});
</script>
</head>
<body>
<h2 class="documentHeading">libprs500 Manual</h2>
<ul id="browser" class="filetree">
%tree
</ul>
<hr />
<div class="footer">
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img src="images/valid.png" alt="Valid XHTML 1.1" height="31" width="88" />
</a><br />
Created by Kovid Goyal &copy; 2008
</p>
</div>
</body>
</html>