|
223 | 223 | {% endfor %} |
224 | 224 | """ |
225 | 225 |
|
| 226 | + |
| 227 | +samples_template = u""".. default-domain:: nscp |
| 228 | +
|
| 229 | +.. default-domain:: nscp |
| 230 | +
|
| 231 | +=========== |
| 232 | +All samples |
| 233 | +=========== |
| 234 | +
|
| 235 | +A collection of all sample commands |
| 236 | +
|
| 237 | +{% for mk,module in plugins|dictsort -%} |
| 238 | +{% set vars = {'found': False} -%} |
| 239 | +{% for qk,query in module.queries|dictsort -%} |
| 240 | +{% if query.sample -%} |
| 241 | +{% if vars.update({'found': True}) -%}{%- endif %} |
| 242 | +{%- endif %} |
| 243 | +{%- endfor %} |
| 244 | +{% if vars.found -%} |
| 245 | +{{mk|rst_heading('=')}} |
| 246 | +
|
| 247 | +{% for qk,query in module.queries|dictsort -%} |
| 248 | +{% if query.sample -%} |
| 249 | +{{qk|rst_heading}} |
| 250 | +
|
| 251 | +{{query.info.description|firstline}} |
| 252 | +
|
| 253 | +.. include:: ../samples/{{query.sample}} |
| 254 | +
|
| 255 | +{% endif %} |
| 256 | +{%- endfor %} |
| 257 | +{%- endif %} |
| 258 | +{%- endfor %} |
| 259 | +""" |
| 260 | + |
226 | 261 | def split_argllist(name, desc): |
227 | 262 | extdata = {} |
228 | 263 | spos = desc.find('\n\n') |
@@ -298,7 +333,6 @@ def append_plugin(self, info): |
298 | 333 | else: |
299 | 334 | namespace = 'misc' |
300 | 335 |
|
301 | | - print "%s == %s"%(name, namespace) |
302 | 336 | if not name in self.plugins: |
303 | 337 | self.plugins[name] = plugin_container(info, namespace) |
304 | 338 |
|
@@ -590,6 +624,18 @@ def fetch_command(self, command, cinfo): |
590 | 624 | def generate_rst(self, input_dir, output_dir): |
591 | 625 | root = self.get_info() |
592 | 626 | i = 0 |
| 627 | + |
| 628 | + env = Environment(extensions=["jinja2.ext.do",]) |
| 629 | + env.filters['firstline'] = first_line |
| 630 | + env.filters['rst_link'] = make_rst_link |
| 631 | + env.filters['rst_table'] = render_rst_table |
| 632 | + env.filters['rst_csvtable'] = render_rst_csv_table |
| 633 | + env.filters['rst_heading'] = render_rst_heading |
| 634 | + env.filters['extract_value'] = extract_value |
| 635 | + env.filters['block_pad'] = block_pad |
| 636 | + env.filters['common_head'] = calculate_common_head |
| 637 | + env.filters['as_text'] = as_text |
| 638 | + |
593 | 639 | for (module,minfo) in root.plugins.iteritems(): |
594 | 640 | out_base_path = '%s/reference/'%output_dir |
595 | 641 | sample_base_path = '%s/samples/'%output_dir |
@@ -625,31 +671,25 @@ def generate_rst(self, input_dir, output_dir): |
625 | 671 | i=i+1 |
626 | 672 | log_debug('Processing module: %d of %d [%s]'%(i, len(root.plugins), module)) |
627 | 673 |
|
628 | | - env = Environment(extensions=["jinja2.ext.do",]) |
629 | | - env.filters['firstline'] = first_line |
630 | | - env.filters['rst_link'] = make_rst_link |
631 | | - env.filters['rst_table'] = render_rst_table |
632 | | - env.filters['rst_csvtable'] = render_rst_csv_table |
633 | | - env.filters['rst_heading'] = render_rst_heading |
634 | | - env.filters['extract_value'] = extract_value |
635 | | - env.filters['block_pad'] = block_pad |
636 | | - env.filters['common_head'] = calculate_common_head |
637 | | - env.filters['as_text'] = as_text |
638 | | - |
639 | 674 | template = env.from_string(module_template) |
640 | 675 | render_template(hash, template, '%s/%s.rst'%(out_base_path, module)) |
641 | 676 |
|
| 677 | + log_debug('%s/samples/index.rst'%output_dir) |
| 678 | + hash = root.get_hash() |
| 679 | + template = env.from_string(samples_template) |
| 680 | + render_template(hash, template, '%s/samples/index.rst'%output_dir) |
| 681 | + |
642 | 682 | def main(self, args): |
643 | 683 | parser = OptionParser(prog="") |
644 | 684 | parser.add_option("-o", "--output", help="write report to FILE(s)") |
645 | 685 | parser.add_option("-i", "--input", help="Reference folder") |
646 | 686 | (options, args) = parser.parse_args(args=args) |
647 | | - |
648 | 687 | self.generate_rst(options.input, options.output) |
649 | 688 |
|
650 | 689 | def __main__(args): |
651 | 690 | global helper |
652 | 691 | helper.main(args); |
| 692 | + return 0 |
653 | 693 |
|
654 | 694 | def init(plugin_id, plugin_alias, script_alias): |
655 | 695 | global helper |
|
0 commit comments