Пример #1
0
 def generateDoc(self, doc):
     para = rst.Paragraph('\n')
     doc.add_child(para)
     sec = rst.Section('Test Case : ' + str(self.info['index']), 2)
     doc.add_child(sec)
     desc = self.info['description'][0].lstrip()
     desc = desc.rstrip()
     para = rst.Paragraph('**' + desc + '**\n\n')
     doc.add_child(para)
     tbl = rst.Table(header=['Test Execution Steps'])
     for line in self.info['steps']:
         row = []
         row.append(line)
         tbl.add_item(row)
     doc.add_child(tbl)
     para = rst.Paragraph('\n**Expected Results**\n')
     doc.add_child(para)
     bList = rst.Bulletlist()
     for line in self.info['expect']:
         bList.add_item(line)
     doc.add_child(bList)
     para = rst.Paragraph('\n**Actual Results**\n')
     doc.add_child(para)
     para = rst.Paragraph('    PASS\n')
     doc.add_child(para)
Пример #2
0
def getEnumerationDescripion(elem, headerPrefix='', refPrefix=''):
    text = '.. _%s%s:\n\n' % (refPrefix, elem.attrib['abbrev'])
    text += '.. _%s%s%s:\n\n' % (refPrefix, 'prefix-', elem.attrib['prefix'])
    text += rst.h3(headerPrefix + elem.attrib['name'])
    text += findDescriptionTagAndOutputTextBlock(elem)
    text += '- Abbreviation: ' + elem.attrib['abbrev'] + '\n'
    text += '- Prefix: ' + elem.attrib['prefix'] + '\n'
    text += '\n'
    tenums = rst.Table()
    tenums.add_row('Value', 'Name', 'Abbreviation', 'Description')
    for v in elem.findall('value'):
        tenums.add_row(v.attrib['id'], v.attrib['name'], v.attrib['abbrev'],
                       findDescriptionTagAndOutputTextBlock(v, True))
    text += str(tenums)

    return text
Пример #3
0
    def output(self, results):
        # Prepare the rst
        doc = rst.Document('Metrics for the code "%s"' %
                           self.prettify(results[CODE_PATH]))
        doc.add_child(
            rst.Paragraph('*Date of the report:* %s\n\n' %
                          self.prettify(results[REPORT_DATE])))

        table = rst.Table('Metrics', ['Name', 'Value'])
        for k, v in results.items():
            if k in [CODE_PATH, REPORT_DATE]:
                continue  # Skip some fields
            table.add_item((k, self.prettify(v)))
        doc.add_child(table)

        # Write it
        os.makedirs(os.path.dirname(self.path), exist_ok=True)
        with open('%s' % self.path, 'w') as file:
            file.write(doc.get_rst())
Пример #4
0
def main():
    doc = rst.Document('Title of the report')
    para = rst.Paragraph('Just another paragraph. We need few more of these.')
    doc.add_child(para)
    sec = rst.Section('Another', 2)
    doc.add_child(sec)
    para = rst.Paragraph('Can we do this? Yes we can.')
    doc.add_child(para)

    blt = rst.Orderedlist()
    blt.add_item('Red Hat')
    blt.add_item('Fedora')
    blt.add_item('Debian')

    doc.add_child(blt)

    blt = rst.Bulletlist()
    blt.add_item('Python')
    blt.add_item('C')
    blt.add_item('C++')
    blt.add_item('Lisp')

    doc.add_child(blt)



    sec2 = rst.Section('Why Python is awesome?', 2)
    sec.add_child(sec2)

    tbl = rst.Table('My friends', ['Name', 'Major Project'])
    tbl.add_item(('Ramki', 'Python'))
    tbl.add_item(('Pradeepto', 'Kde'))
    tbl.add_item(('Nicubunu', 'Fedora'))
    doc.add_child(tbl)

    print doc.get_rst()
Пример #5
0
files = []

# Prepare directory tree.
shutil.rmtree(src_dir, True)
shutil.rmtree(bld_dir, True)
os.makedirs(src_dir)
shutil.copytree(img_dir, os.path.join(bld_dir, 'images'))

# Message format.
text = rst.h1('Message Format')
files.append('Message Format.rst')

# Field types.
text += rst.h2('Field types')
text += rst.block(root.find('types/description').text)
ttypes = rst.Table()
ttypes.add_row('Name', 'Size', 'Description')
for t in root.findall('types/type'):
    if 'size' in t.attrib:
        size = t.attrib['size'].strip()
    else:
        size = 'n/a'
    ttypes.add_row(t.attrib['name'], size, t.find('description').text)
text += str(ttypes)
open(os.path.join(src_dir, 'Message Format.rst'), 'w').write(text)

# Serialization.
text = rst.h2('Serialization')
text += rst.block(root.find('serialization/description').text)
ttypes = rst.Table()
ttypes.add_row('Name', 'Serialization')
Пример #6
0
# Prepare directory tree.
shutil.rmtree(src_dir, True)
shutil.rmtree(bld_dir, True)
os.makedirs(src_dir)
shutil.copytree(img_dir, os.path.join(bld_dir, 'images'))

# Message format.
text = rst.h1('Message Format')
files.append('Message Format.rst')

headerFooterSize = 0

# Field types.
text += rst.h2('Field types')
text += rst.block(root.find('types/description').text)
ttypes = rst.Table()
ttypes.add_row('Name', 'Size', 'Description')
for t in root.findall('types/type'):
    if 'size' in t.attrib:
        size = t.attrib['size'].strip()
    else:
        size = 'n/a'
    ttypes.add_row(t.attrib['name'], size, t.find('description').text)
text += str(ttypes)
open(os.path.join(src_dir, 'Message Format.rst'), 'w',
     encoding='utf-8').write(text)

# Serialization.
if root.find('serialization') is not None:
    text = rst.h2('Serialization')
    descElm = root.find('serialization/description')