From 1a8e645c22bf45a25fdc55b1d094a2adbb4b2d2c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 26 Feb 2008 08:28:18 +0000 Subject: [PATCH] --- src/libprs500/manual/gui.html | 2 +- src/libprs500/manual/images/cli.png | Bin 0 -> 6250 bytes src/libprs500/manual/libprs500.qhcp | 2 +- src/libprs500/manual/libprs500.qhp | 54 +++++- src/libprs500/manual/libprs500.webprj | 2 + src/libprs500/manual/preprocess.py | 158 +++++++++++++++++- .../manual/{index.html => start.html} | 2 +- src/libprs500/manual/{ => styles}/common.css | 31 ++++ src/libprs500/manual/templates/basic.html | 8 +- src/libprs500/manual/templates/navtree.html | 44 +++++ 10 files changed, 286 insertions(+), 17 deletions(-) create mode 100644 src/libprs500/manual/images/cli.png rename src/libprs500/manual/{index.html => start.html} (91%) rename src/libprs500/manual/{ => styles}/common.css (54%) create mode 100644 src/libprs500/manual/templates/navtree.html diff --git a/src/libprs500/manual/gui.html b/src/libprs500/manual/gui.html index e83aafd8bd..2eee951a1e 100644 --- a/src/libprs500/manual/gui.html +++ b/src/libprs500/manual/gui.html @@ -7,7 +7,7 @@ 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 0000000000000000000000000000000000000000..f6f94e7c0ab245e7e94fae1f6adf8442d649f0ab GIT binary patch literal 6250 zcmV-w7?tOVP)=UbmA6PR!q zayXMfU>uwP0ftF(63!3^Cd z)cv~NefNG{RrlR@?<=92+ImXLLuWhP_N!zNP}tJ5y2y~?n1vv%v_%eQ zC~P^IS@+D3Tp|S)fpeKz&>bzCeo;iH5gV6GceJ!yE^oJ7-u{ci#o)55x`Z^n< z75mGrN)9UlGRbPGBl+SvOyi4f*N_!LK$9^t*c7*O|X-njDu$$*o zXA*d0PCKWc925AIX^#P?$xAoNRuG|*Bm4(G$x#@ihio15gOXGM^ zdQ#q2>{g}xy6E`$d_nk+iG6OOw=yPRUXz&fMuO6br30~fK=yg}7&4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zk0HK+O?2S-)G1-%9V0+uO>u(HMj|!-A0tH% U2$L|pivR!s07*qoM6N<$g12y7iU0rr literal 0 HcmV?d00001 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.png false false 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.html gui.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.css images/edit_meta_information.png images/remove_books.png images/book_details.png @@ -37,6 +82,7 @@ images/news.png images/view.png images/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

[options]

\n' + body += '\n\n%s\n
\n'%'\n'.join(gh) + output.write(template.replace('%body', body)) + + uc_html = '\n
    \n%s
\n'%'\n'.join(\ + '
  • %s
  • \n'%i for i in undocumented_cmds) + dc_html = '\n
      \n%s
    \n'%'\n'.join(\ + '
  • %s
  • \n'%(i[0], i[0]) for i in documented_cmds) + + body = '

    The Command Line Interface

    \n' + body += '
    ' + body += '

    %s

    \n'%'libprs500 has a very comprehensive command line interface to perform most operations that can be performed by the GUI.' + body += '

    Documented commands

    \n'+dc_html + body += '

    Undocumented commands

    \n'+uc_html + body += '

    You can see usage for undocumented commands by executing them without arguments in a terminal

    ' + 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 = ['
    \n'%(i, i) for i in cmds] + [sec.append(fromstring(i)) for i in secs] + raw = tostring(root, 'UTF-8') + raw = re.sub(r'(
    \n%s\n\n'%(sec.attrib['ref'], sec.attrib['title']) + if toplevel: + html=html.replace('','%s\n'%process_branch(sec)) + type = 'folder' + + parent.append(html.replace('||||', type)) + html = '\n'.join(parent) + if toplevel: + return html + return '
      \n%s\n
    '%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 diff --git a/src/libprs500/manual/index.html b/src/libprs500/manual/start.html similarity index 91% rename from src/libprs500/manual/index.html rename to src/libprs500/manual/start.html index ce7900fdaa..2997ad1932 100644 --- a/src/libprs500/manual/index.html +++ b/src/libprs500/manual/start.html @@ -7,7 +7,7 @@ libprs500 User Manual - + diff --git a/src/libprs500/manual/common.css b/src/libprs500/manual/styles/common.css similarity index 54% rename from src/libprs500/manual/common.css rename to src/libprs500/manual/styles/common.css index 9f7ed49057..76a3b8e8c1 100644 --- a/src/libprs500/manual/common.css +++ b/src/libprs500/manual/styles/common.css @@ -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; } \ No newline at end of file diff --git a/src/libprs500/manual/templates/basic.html b/src/libprs500/manual/templates/basic.html index 58d245eb92..deb45fd783 100644 --- a/src/libprs500/manual/templates/basic.html +++ b/src/libprs500/manual/templates/basic.html @@ -1,20 +1,18 @@ - + - + + %body