def generate_client_subcommand_doc(app, module, cls): from bkr.client.main import BeakerCommandContainer docname = 'bkr-%s' % BeakerCommandContainer.normalize_name(cls.__name__) doc = module.__doc__ doctitle = _get_title_from_docstring(doc) doc = '.. GENERATED FROM %s, DO NOT EDIT THIS FILE\n%s' % (module.__file__, doc) outpath = os.path.join(app.srcdir, 'man', '%s.rst' % docname) # only write it if the contents have changed, this helps conditional builds if not os.path.exists(outpath) or open(outpath, 'r').read() != doc: open(outpath, 'w').write(doc) description = doctitle.split(':', 1)[1].strip() app.config.man_pages.append(('man/%s' % docname, docname, description, [u'The Beaker team <*****@*****.**>'], 1))
def generate_client_subcommand_doc(app, module, cls): from bkr.client.main import BeakerCommandContainer docname = 'bkr-%s' % BeakerCommandContainer.normalize_name(cls.__name__) doc = module.__doc__ doctitle = _get_title_from_docstring(doc) doc = '.. GENERATED FROM %s, DO NOT EDIT THIS FILE\n%s' % (module.__file__, doc) outpath = os.path.join(app.srcdir, 'man', '%s.rst' % docname) # only write it if the contents have changed, this helps conditional builds if not os.path.exists(outpath) or open(outpath, 'r').read() != doc: open(outpath, 'w').write(doc) description = doctitle.split(':', 1)[1].strip() app.config.man_pages.append( ('man/%s' % docname, docname, description, [u'The Beaker team <*****@*****.**>'], 1))
def generate_subcommand_list(app): from bkr.client.main import BeakerCommandContainer subcommand_list = [] for module, cls in find_client_subcommands(): cmd_name = BeakerCommandContainer.normalize_name(cls.__name__) man_entry_name = 'bkr-%s' % cmd_name subcommand_list_entry = [man_entry_name] docstring = module.__doc__ title = _get_title_from_docstring(docstring) # Get the descriptive text from the title match = re.search('bkr %s: (.+)$' % cmd_name, title) if match: try: title_description = match.group(1) subcommand_list_entry.append(title_description) except IndexError: pass # Ideally we should have the man entry name, and the description if len(subcommand_list_entry) < 2: warnings.filterwarnings( 'always', 'Cannot find command description for %s, not adding it to bkr.rst' % module) subcommand_list.append(subcommand_list_entry) # Write bkr.rst subcommands subcommands_path = os.path.join(app.srcdir, 'man', 'subcommands.rst') with open(subcommands_path, 'w') as command_file: command_file.write(':orphan:\n\n') command_file.write('.. This file is autogenerated with commands found' ' in bkr.client.commands\n\n') command_file.write('Subcommands\n***********\n\n') # Sort by command name subcommand_list = sorted( subcommand_list, key=lambda subcommand_list_entry: subcommand_list_entry[0]) for subcommand_list_entry in subcommand_list: man_text = subcommand_list_entry[0] desc = '' if len(subcommand_list_entry) == 2: desc = subcommand_list_entry[1] command_file.write('* :manpage:`%s(1)` -- %s\n' % (man_text, desc))
def generate_subcommand_list(app): from bkr.client.main import BeakerCommandContainer subcommand_list = [] for module, cls in find_client_subcommands(): cmd_name = BeakerCommandContainer.normalize_name(cls.__name__) man_entry_name = 'bkr-%s' % cmd_name subcommand_list_entry = [man_entry_name] docstring = module.__doc__ title = _get_title_from_docstring(docstring) # Get the descriptive text from the title match = re.search('bkr %s: (.+)$' % cmd_name, title) if match: try: title_description = match.group(1) subcommand_list_entry.append(title_description) except IndexError: pass # Ideally we should have the man entry name, and the description if len(subcommand_list_entry) < 2: warnings.filterwarnings('always', 'Cannot find command description for %s, not adding it to bkr.rst' % module) subcommand_list.append(subcommand_list_entry) # Write bkr.rst subcommands subcommands_path = os.path.join(app.srcdir, 'man', 'subcommands.rst') with open(subcommands_path, 'w') as command_file: command_file.write(':orphan:\n\n') command_file.write('.. This file is autogenerated with commands found' ' in bkr.client.commands\n\n') command_file.write('Subcommands\n***********\n\n') # Sort by command name subcommand_list = sorted(subcommand_list, key=lambda subcommand_list_entry: subcommand_list_entry[0]) for subcommand_list_entry in subcommand_list: man_text = subcommand_list_entry[0] desc = '' if len(subcommand_list_entry) == 2: desc = subcommand_list_entry[1] command_file.write('* :manpage:`%s(1)` -- %s\n' % (man_text, desc))