def make_cmdline_overview(descr, title=True): content = Rest() if title: content.add( Title("Overview of Command Line Options for '%s'" % (descr._name, ), abovechar="=", belowchar="=")) cmdlines = [] config = Config(descr) for path in config.getpaths(include_groups=False): subconf, step = config._cfgimpl_get_home_by_path(path) fullpath = (descr._name + "." + path) prefix = fullpath.rsplit(".", 1)[0] subdescr = getattr(subconf._cfgimpl_descr, step) cmdline = get_cmdline(subdescr.cmdline, fullpath) if cmdline is not None: header = _get_section_header(cmdline, fullpath, subdescr) cmdlines.append((header, cmdline, fullpath, subdescr)) cmdlines.sort(key=lambda x: (x[0], x[1].strip("-"))) currheader = "" curr = content for header, cmdline, fullpath, subdescr in cmdlines: if header != currheader: content.add(Title(header, abovechar="", belowchar="=")) curr = content.add(Paragraph()) currheader = header curr.add(ListItem(Link(cmdline + ":", fullpath + ".html"), Text(subdescr.doc))) return content
def get_content(self, txtpath, encoding): if txtpath.basename == "commandline.rst": result = [] for line in txtpath.read().splitlines(): if line.startswith('.. GENERATE:'): start = line[len('.. GENERATE:'):].strip() descr = start_to_descr[start] line = make_cmdline_overview(descr, title=False).text() result.append(line) return "\n".join(result) fullpath = txtpath.purebasename start = fullpath.split(".")[0] path = fullpath.rsplit(".", 1)[0] basedescr = start_to_descr.get(start) if basedescr is None: return txtpath.read() if fullpath.count(".") == 0: descr = basedescr path = "" else: conf = Config(basedescr) subconf, step = conf._cfgimpl_get_home_by_path( fullpath.split(".", 1)[1]) descr = getattr(subconf._cfgimpl_descr, step) text = unicode(descr.make_rest_doc(path).text()) if txtpath.check(file=True): content = txtpath.read() if content: text += "\nDescription\n===========" return u"%s\n\n%s" % (text, unicode(txtpath.read(), encoding)) return text
def make_cmdline_overview(descr, title=True): content = Rest() if title: content.add( Title("Overview of Command Line Options for '%s'" % (descr._name, ), abovechar="=", belowchar="=")) cmdlines = [] config = Config(descr) for path in config.getpaths(include_groups=False): subconf, step = config._cfgimpl_get_home_by_path(path) fullpath = (descr._name + "." + path) subdescr = getattr(subconf._cfgimpl_descr, step) cmdline = get_cmdline(subdescr.cmdline, fullpath) if cmdline is not None: header = _get_section_header(cmdline, fullpath, subdescr) cmdlines.append((header, cmdline, fullpath, subdescr)) cmdlines.sort(key=lambda x: (x[0], x[1].strip("-"))) currheader = "" curr = content for header, cmdline, fullpath, subdescr in cmdlines: if header != currheader: content.add(Title(header, abovechar="", belowchar="=")) curr = content.add(Paragraph()) currheader = header curr.add( ListItem(Link(cmdline + ":", fullpath + ".html"), Text(subdescr.doc))) return content
def get_content(self, txtpath, encoding): if txtpath.basename == "commandline.rst": result = [] for line in txtpath.read().splitlines(): if line.startswith('.. GENERATE:'): start = line[len('.. GENERATE:'):].strip() descr = start_to_descr[start] line = make_cmdline_overview(descr, title=False).text() result.append(line) return "\n".join(result) fullpath = txtpath.purebasename start = fullpath.split(".")[0] path = fullpath.rsplit(".", 1)[0] basedescr = start_to_descr.get(start) if basedescr is None: return txtpath.read() if fullpath.count(".") == 0: descr = basedescr path = "" else: conf = Config(basedescr) subconf, step = conf._cfgimpl_get_home_by_path( fullpath.split(".", 1)[1]) descr = getattr(subconf._cfgimpl_descr, step) text = unicode(descr.make_rest_doc(path).text()) if txtpath.check(file=True): content = txtpath.read() if content: text += "\nDescription\n===========" return u"%s\n\n%s" % (text, unicode(txtpath.read(), encoding)) return text