Esempio n. 1
0
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
Esempio n. 2
0
    def config_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
        from docutils import nodes
        from pypy.config.pypyoption import get_pypy_config
        from pypy.config.makerestdoc import get_cmdline

        txt = docdir.join("config", text + ".rst")
        html = docdir.join("config", text + ".html")
        assert txt.check()
        assert name == "config"
        sourcedir = py.path.local(inliner.document.settings._source).dirpath()
        curr = sourcedir
        prefix = ""
        while 1:
            relative = str(html.relto(curr))
            if relative:
                break
            curr = curr.dirpath()
            prefix += "../"
        config = get_pypy_config()
        # begin horror
        h, n = config._cfgimpl_get_home_by_path(text)
        opt = getattr(h._cfgimpl_descr, n)
        # end horror
        cmdline = get_cmdline(opt.cmdline, text)
        if cmdline is not None:
            shortest_long_option = "X" * 1000
            for cmd in cmdline.split():
                if cmd.startswith("--") and len(cmd) < len(shortest_long_option):
                    shortest_long_option = cmd
            text = shortest_long_option
        target = prefix + relative
        reference_node = nodes.reference(rawtext, text, name=text, refuri=target)
        return [reference_node], []
Esempio n. 3
0
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
Esempio n. 4
0
 def config_role(name, rawtext, text, lineno, inliner, options={},
                 content=[]):
     from docutils import nodes
     from pypy.config.pypyoption import get_pypy_config
     from pypy.config.makerestdoc import get_cmdline
     txt = docdir.join("config", text + ".rst")
     html = docdir.join("config", text + ".html")
     assert txt.check()
     assert name == "config"
     sourcedir = py.path.local(inliner.document.settings._source).dirpath()
     curr = sourcedir
     prefix = ""
     while 1:
         relative = str(html.relto(curr))
         if relative:
             break
         curr = curr.dirpath()
         prefix += "../"
     config = get_pypy_config()
     # begin horror
     h, n = config._cfgimpl_get_home_by_path(text)
     opt = getattr(h._cfgimpl_descr, n)
     # end horror
     cmdline = get_cmdline(opt.cmdline, text)
     if cmdline is not None:
         shortest_long_option = 'X'*1000
         for cmd in cmdline.split():
             if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
                 shortest_long_option = cmd
         text = shortest_long_option
     target = prefix + relative
     reference_node = nodes.reference(rawtext, text, name=text, refuri=target)
     return [reference_node], []
Esempio n. 5
0
 def make_rest_doc(self, path=""):
     fullpath = get_fullpath(self, path)
     result = Rest(Title(fullpath, abovechar="=", belowchar="="),
                   ListItem(Strong("name:"), self._name),
                   ListItem(Strong("description:"), self.doc))
     if self.cmdline is not None:
         cmdline = get_cmdline(self.cmdline, fullpath)
         result.add(ListItem(Strong("command-line:"), cmdline))
     return result
Esempio n. 6
0
 def make_rest_doc(self, path=""):
     fullpath = get_fullpath(self, path)
     result = Rest(
         Title(fullpath, abovechar="=", belowchar="="),
         ListItem(Strong("name:"), self._name),
         ListItem(Strong("description:"), self.doc))
     if self.cmdline is not None:
         cmdline = get_cmdline(self.cmdline, fullpath)
         result.add(ListItem(Strong("command-line:"), cmdline))
     return result
Esempio n. 7
0
 def make_rest_doc(self, path=""):
     fullpath = get_fullpath(self, path)
     result = Rest(Title(fullpath, abovechar="=", belowchar="="),
                   Directive("contents"),
                   Paragraph(Link("back to parent", path + ".html")),
                   Title("Basic Option Information"),
                   ListItem(Strong("name:"), self._name),
                   ListItem(Strong("description:"), self.doc))
     if self.cmdline is not None:
         cmdline = get_cmdline(self.cmdline, fullpath)
         result.add(ListItem(Strong("command-line:"), cmdline))
     return result
Esempio n. 8
0
def longoptfromname(config, name):
    from pypy.config.makerestdoc import get_cmdline
    # begin horror
    h, n = config._cfgimpl_get_home_by_path(name)
    opt = getattr(h._cfgimpl_descr, n)
    # end horror
    cmdline = get_cmdline(opt.cmdline, name)
    assert cmdline is not None
    shortest_long_option = 'X' * 1000
    for cmd in cmdline.split():
        if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
            shortest_long_option = cmd
    return shortest_long_option
Esempio n. 9
0
 def make_rest_doc(self, path=""):
     fullpath = get_fullpath(self, path)
     result = Rest(
         Title(fullpath, abovechar="=", belowchar="="),
         Directive("contents"),
         Paragraph(Link("back to parent", path + ".html")),
         Title("Basic Option Information"),
         ListItem(Strong("name:"), self._name),
         ListItem(Strong("description:"), self.doc))
     if self.cmdline is not None:
         cmdline = get_cmdline(self.cmdline, fullpath)
         result.add(ListItem(Strong("command-line:"), cmdline))
     return result
Esempio n. 10
0
def longoptfromname(config, name):
    from pypy.config.makerestdoc import get_cmdline
    # begin horror
    h, n = config._cfgimpl_get_home_by_path(name)
    opt = getattr(h._cfgimpl_descr, n)
    # end horror
    cmdline = get_cmdline(opt.cmdline, name)
    assert cmdline is not None
    shortest_long_option = 'X'*1000
    for cmd in cmdline.split():
        if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
            shortest_long_option = cmd
    return shortest_long_option