Example #1
0
 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
Example #2
0
 def get_content(self, txtpath, encoding):
     if txtpath.basename == "commandline.txt":
         result = [".. contents::"]
         for descr in all_optiondescrs:
             result.append(".. %s_:\n" % (descr._name, ))
             result.append(make_cmdline_overview(descr).text())
             result.append("")
         result.append(txtpath.read())
         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
Example #3
0
def make_cmdline_overview():
    result = []
    txtpath = thisdir.join("commandline.txt")
    for line in txtpath.read().splitlines():
        if line.startswith('.. GENERATE:'):
            start = line[len('.. GENERATE:'):].strip()
            descr = start_to_descr[start]
            line = makerestdoc.make_cmdline_overview(descr, title=False).text()
        result.append(line)
    rstpath = txtpath.new(ext=".rst")
    rstpath.write("\n".join(result))
Example #4
0
def make_cmdline_overview():
    result = []
    txtpath = thisdir.join("commandline.txt")
    for line in txtpath.read().splitlines():
        if line.startswith('.. GENERATE:'):
            start = line[len('.. GENERATE:'):].strip()
            descr = start_to_descr[start]
            line = makerestdoc.make_cmdline_overview(descr, title=False).text()
        result.append(line)
    rstpath = txtpath.new(ext=".rst")
    rstpath.write("\n".join(result))
Example #5
0
def test_cmdline_overview():
    descr = OptionDescription("foo", "doc", [
            ChoiceOption("bar", "more doc", ["a", "b", "c"]),
            OptionDescription("sub", "nope", [
                ChoiceOption("subbar", "", ["d", "f"]),
                BoolOption("boolean", "this is a boolean", default=False,
                           cmdline="-b --with-b")
                ]),
            StrOption("str", "string option!", default="strange"),
            IntOption("int", "integer option", default=42),
            FloatOption("float", "float option", default=py.std.math.pi),
            ArbitraryOption("surprise", "special", defaultfactory=int),
            ])
    generate_html(descr)
    c = make_cmdline_overview(descr)
    checkrest(c.text(), "index.txt")
Example #6
0
def test_cmdline_overview():
    descr = OptionDescription("foo", "doc", [
        ChoiceOption("bar", "more doc", ["a", "b", "c"]),
        OptionDescription("sub", "nope", [
            ChoiceOption("subbar", "", ["d", "f"]),
            BoolOption("boolean",
                       "this is a boolean",
                       default=False,
                       cmdline="-b --with-b")
        ]),
        StrOption("str", "string option!", default="strange"),
        IntOption("int", "integer option", default=42),
        FloatOption("float", "float option", default=py.std.math.pi),
        ArbitraryOption("surprise", "special", defaultfactory=int),
    ])
    generate_html(descr)
    c = make_cmdline_overview(descr)
    checkrest(c.text(), "index.txt")