'%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%8s'%' ' + ('\n%8s'%' ').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
\n'%(i[0], i[0]) for i in documented_cmds)
+ template = loader.load('cli-cmd.html')
+ open('build/cli-%s.html'%cmd, 'wb').write(
+ template.generate(cmd=cmd, parser=parser).render(doctype='xhtml'))
- 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
'
+ documented = [i[0] for i in documented_cmds]
+ template = loader.load('cli-index.html')
- template = open('templates/basic.html', 'rb').read().decode('utf-8')
- template = re.sub('\s*', '%s'%'Command Line Interface', template)
- open('cli-index.html', 'wb').write(template.replace('%body', body))
+ open('build/cli-index.html', 'wb').write(
+ template.generate(documented=documented, undocumented=undocumented_cmds).render(doctype='xhtml'))
-def html(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'):
- title = re.sub('&(?!amp;)', '&', sec.attrib['title'])
- html = '