The Graphical User Interface
-
+
diff --git a/src/libprs500/manual/images/cli.png b/src/libprs500/manual/images/cli.png
new file mode 100644
index 0000000000..f6f94e7c0a
Binary files /dev/null and b/src/libprs500/manual/images/cli.png differ
diff --git a/src/libprs500/manual/libprs500.qhcp b/src/libprs500/manual/libprs500.qhcp
index a501b8966b..4d99522707 100644
--- a/src/libprs500/manual/libprs500.qhcp
+++ b/src/libprs500/manual/libprs500.qhcp
@@ -2,7 +2,7 @@
libprs500 Help
- qthelp://libprs500/manual/index.html
+ qthelp://libprs500/manual/start.html../gui2/images/library.pngfalsefalse
diff --git a/src/libprs500/manual/libprs500.qhp b/src/libprs500/manual/libprs500.qhp
index 5552224e4f..4797392025 100644
--- a/src/libprs500/manual/libprs500.qhp
+++ b/src/libprs500/manual/libprs500.qhp
@@ -10,16 +10,61 @@
libprs500
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- index.html
+ cli-isbndb.html
+ cli-pdfreflow.html
+ cli-mobi2lrf.html
+ cli-lrf-meta.html
+ cli-lit2lrf.html
+ cli-lrf2lrs.html
+ cli-index.html
+ cli-web2lrf.html
+ cli-lrs2lrf.html
+ cli-txt2lrf.html
+ start.html
+ cli-web2disk.htmlgui.html
- common.css
+ cli-opf-meta.html
+ cli-html2lrf.html
+ cli-rtf2lrf.html
+ cli-librarything.html
+ cli-epub2lrf.html
+ cli-rtf-meta.html
+ cli-pdf2lrf.html
+ cli-lrf2html.html
+ cli-any2lrf.html
+ cli-mobi2oeb.html
+ styles/common.cssimages/edit_meta_information.pngimages/remove_books.pngimages/book_details.png
@@ -37,6 +82,7 @@
images/news.pngimages/view.pngimages/fetch_news.png
+ images/cli.png
diff --git a/src/libprs500/manual/libprs500.webprj b/src/libprs500/manual/libprs500.webprj
index 97b7691da6..5171184d02 100644
--- a/src/libprs500/manual/libprs500.webprj
+++ b/src/libprs500/manual/libprs500.webprj
@@ -28,5 +28,7 @@
+
+
diff --git a/src/libprs500/manual/preprocess.py b/src/libprs500/manual/preprocess.py
index 480ca234ec..3d940d498f 100644
--- a/src/libprs500/manual/preprocess.py
+++ b/src/libprs500/manual/preprocess.py
@@ -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('%s'%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('&', '&').replace('<', '<').replace('>', '>')
+
+ 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] = '
%s
'%usage[0]
+ usage[1:] = [i.replace(cmd, '%s'%cmd) for i in usage[1:]]
+ usage = ''.join(usage).replace('\n', ' ')
+ body = ('\n
%s
\n'%cmd)+'
\n%s\n
'%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('
%s
'%title)
+ if description is not None:
+ res.append('
%s
'%sanitize_text(description))
+ for opt in option_list:
+ shf = ' '.join(opt._short_opts)
+ lgf = opt.get_opt_string()
+ name = '%s %s'%(lgf, shf)
+ help = sanitize_text(opt.help) if opt.help else ''
+ res.append('
%s
%s
'%(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