Skip to content

Commit

Permalink
Merge pull request #12 from boegel/dump-formatting
Browse files Browse the repository at this point in the history
sync with develop
  • Loading branch information
Caylo committed Aug 7, 2015
2 parents cf43c0d + bfd5546 commit c0666bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 64 deletions.
34 changes: 1 addition & 33 deletions easybuild/tools/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import copy
import inspect
import os
from vsc.utils.docs import mk_rst_table

from easybuild.framework.easyconfig.default import DEFAULT_CONFIG, HIDDEN, sorted_categories
from easybuild.framework.easyconfig.easyconfig import get_easyblock_class
Expand Down Expand Up @@ -271,36 +272,3 @@ def gen_easyblock_doc_section_rst(eb_class, path_to_examples, common_params, doc
lines.append('') # empty line after literal block

return '\n'.join(lines)


def mk_rst_table(titles, values):
"""
Returns an rst table with given titles and values (a nested list of string values for each column)
"""
num_col = len(titles)
table = []
col_widths = []
tmpl = []
line= []

# figure out column widths
for i in range(0, num_col):
col_widths.append(det_col_width(values[i], titles[i]))

# make line template
tmpl.append('{' + str(i) + ':{c}<' + str(col_widths[i]) + '}')
line.append('') # needed for table line

line_tmpl = ' '.join(tmpl)
table_line = line_tmpl.format(*line, c="=")

table.append(table_line)
table.append(line_tmpl.format(*titles, c=' '))
table.append(table_line)

for i in range(0, len(values[0])):
table.append(line_tmpl.format(*[v[i] for v in values], c=' '))

table.extend([table_line, ''])

return table
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ def find_rel_test():
provides=["eb"] + easybuild_packages,
test_suite="test.framework.suite",
zip_safe=False,
install_requires=["vsc-base >= 2.2.0"],
install_requires=["vsc-base >= 2.2.4"],
)
37 changes: 8 additions & 29 deletions test/framework/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,13 @@
import sys
import inspect

from easybuild.tools.docs import gen_easyblocks_overview_rst, mk_rst_table
from easybuild.tools.docs import gen_easyblocks_overview_rst
from easybuild.tools.utilities import import_available_modules
from test.framework.utilities import EnhancedTestCase, init_config
from unittest import TestLoader, main

class DocsTest(EnhancedTestCase):

def test_rst_table(self):
""" Test mk_rst_table function """
entries = [['one', 'two', 'three']]
t = 'This title is longer than the entries in the column'
titles = [t]

# small table
table = '\n'.join(mk_rst_table(titles, entries))
check = '\n'.join([
'=' * len(t),
t,
'=' * len(t),
'one' + ' ' * (len(t) - 3),
'two' + ' ' * (len(t) -3),
'three' + ' ' * (len(t) - 5),
'=' * len(t),
'',
])

self.assertEqual(table, check)

def test_gen_easyblocks(self):
""" Test gen_easyblocks_overview_rst function """
module = 'easybuild.easyblocks.generic'
Expand All @@ -84,13 +63,13 @@ def test_gen_easyblocks(self):
'',
"Commonly used easyconfig parameters with ``ConfigureMake`` easyblock",
"--------------------------------------------------------------------",
"==================== ================================================================",
"easyconfig parameter description ",
"==================== ================================================================",
"configopts Extra options passed to configure (default already has --prefix)",
"buildopts Extra options passed to make step (default already has -j X) ",
"installopts Extra options for installation ",
"==================== ================================================================",
"==================== ================================================================",
"easyconfig parameter description ",
"==================== ================================================================",
"configopts Extra options passed to configure (default already has --prefix)",
"buildopts Extra options passed to make step (default already has -j X) ",
"installopts Extra options for installation ",
"==================== ================================================================",
])

self.assertTrue(check_configuremake in ebdoc)
Expand Down
2 changes: 1 addition & 1 deletion test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_help_long(self):
)
outtxt = topt.parser.help_to_file.getvalue()

self.assertTrue(re.search("-H, --help", outtxt), "Long documentation expanded in long help")
self.assertTrue(re.search("-H OUTPUT_FORMAT, --help=OUTPUT_FORMAT", outtxt), "Long documentation expanded in long help")
self.assertTrue(re.search("show short help message and exit", outtxt), "Documentation included in long help")
self.assertTrue(re.search("Software search and build options", outtxt), "Not all option groups included in short help (1)")
self.assertTrue(re.search("Regression test options", outtxt), "Not all option groups included in short help (2)")
Expand Down

0 comments on commit c0666bf

Please sign in to comment.