Skip to content

Commit 6b38d4b

Browse files
authored
Merge pull request easybuilders#2421 from boegel/fix_sorting_auto_docs
fix order in result of gen_list_easyblocks and gen_easyblocks_overview_rst
2 parents 7ab5d92 + 96d9814 commit 6b38d4b

4 files changed

Lines changed: 59 additions & 16 deletions

File tree

easybuild/tools/docs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def add_class(classes, cls):
490490
children = cls.__subclasses__()
491491
classes.update({cls.__name__: {
492492
'module': cls.__module__,
493-
'children': [x.__name__ for x in children]
493+
'children': sorted([c.__name__ for c in children], key=lambda x: x.lower())
494494
}})
495495
for child in children:
496496
add_class(classes, child)
@@ -891,12 +891,14 @@ def gen_easyblock_doc_section_rst(eb_class, path_to_examples, common_params, doc
891891
if eb_class.extra_options():
892892
title = 'Extra easyconfig parameters specific to ``%s`` easyblock' % classname
893893
ex_opt = eb_class.extra_options()
894+
keys = sorted(ex_opt.keys())
895+
values = [ex_opt[k] for k in keys]
894896

895897
table_titles = ['easyconfig parameter', 'description', 'default value']
896898
table_values = [
897-
['``' + key + '``' for key in ex_opt], # parameter name
898-
[val[1] for val in ex_opt.values()], # description
899-
['``' + str(quote_str(val[0])) + '``' for val in ex_opt.values()] # default value
899+
['``' + key + '``' for key in keys], # parameter name
900+
[val[1] for val in values], # description
901+
['``' + str(quote_str(val[0])) + '``' for val in values] # default value
900902
]
901903

902904
doc.extend(rst_title_and_table(title, table_titles, table_values))

test/framework/docs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ def test_gen_easyblocks(self):
6262
'',
6363
"Dummy support for building and installing applications with configure/make/make install.",
6464
'',
65+
"Extra easyconfig parameters specific to ``ConfigureMake`` easyblock",
66+
"-------------------------------------------------------------------",
67+
'',
68+
"==================== ============ =============",
69+
"easyconfig parameter description default value",
70+
"==================== ============ =============",
71+
'``test_123`` Test 1, 2, 3 ``""`` ',
72+
"``test_bool`` Just a test ``False`` ",
73+
"``test_none`` Another test ``None`` ",
74+
"==================== ============ =============",
75+
'',
6576
"Commonly used easyconfig parameters with ``ConfigureMake`` easyblock",
6677
"--------------------------------------------------------------------",
6778
'',
@@ -74,7 +85,7 @@ def test_gen_easyblocks(self):
7485
"==================== ================================================================",
7586
])
7687

77-
self.assertTrue(check_configuremake in ebdoc)
88+
self.assertTrue(check_configuremake in ebdoc, "Found '%s' in: %s" % (check_configuremake, ebdoc))
7889
names = []
7990

8091
for mod in modules:

test/framework/options.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,29 @@ def test_list_easyblocks(self):
551551
self.eb_main(args, logfile=dummylogfn)
552552
logtxt = read_file(self.logfile)
553553

554-
for pat in [
555-
r"EasyBlock\n",
556-
r"|--\s+EB_foo\n|\s+|--\s+EB_foofoo\n",
557-
r"|--\s+bar\n",
558-
]:
559-
560-
msg = "Pattern '%s' is found in output of --list-easyblocks: %s" % (pat, logtxt)
561-
self.assertTrue(re.search(pat, logtxt), msg)
554+
expected = '\n'.join([
555+
r'EasyBlock',
556+
r'\|-- bar',
557+
r'\|-- ConfigureMake',
558+
r'\|-- EB_foo',
559+
r'\| \|-- EB_foofoo',
560+
r'\|-- EB_GCC',
561+
r'\|-- EB_HPL',
562+
r'\|-- EB_ScaLAPACK',
563+
r'\|-- EB_toy_buggy',
564+
r'\|-- ExtensionEasyBlock',
565+
r'\| \|-- DummyExtension',
566+
r'\| \|-- EB_toy',
567+
r'\| \|-- Toy_Extension',
568+
r'\|-- Toolchain',
569+
r'Extension',
570+
r'\|-- ExtensionEasyBlock',
571+
r'\| \|-- DummyExtension',
572+
r'\| \|-- EB_toy',
573+
r'\| \|-- Toy_Extension',
574+
])
575+
regex = re.compile(expected, re.M)
576+
self.assertTrue(regex.search(logtxt), "Pattern '%s' found in: %s" % (regex.pattern, logtxt))
562577

563578
# clear log
564579
write_file(self.logfile, '')
@@ -1892,7 +1907,9 @@ def generate_cmd_line(ebopts):
18921907
ebopts = EasyBuildOptions(go_args=args, envvar_prefix='EASYBUILD')
18931908
self.assertEqual(generate_cmd_line(ebopts), expected)
18941909

1895-
def test_include_easyblocks(self):
1910+
# must be run after test for --list-easyblocks, hence the '_xxx_'
1911+
# cleaning up the imported easyblocks is quite difficult...
1912+
def test_xxx_include_easyblocks(self):
18961913
"""Test --include-easyblocks."""
18971914
orig_local_sys_path = sys.path[:]
18981915

@@ -1954,7 +1971,9 @@ def test_include_easyblocks(self):
19541971
# 'undo' import of foo easyblock
19551972
del sys.modules['easybuild.easyblocks.foo']
19561973

1957-
def test_include_generic_easyblocks(self):
1974+
# must be run after test for --list-easyblocks, hence the '_xxx_'
1975+
# cleaning up the imported easyblocks is quite difficult...
1976+
def test_xxx_include_generic_easyblocks(self):
19581977
"""Test --include-easyblocks with a generic easyblock."""
19591978
orig_local_sys_path = sys.path[:]
19601979
fd, dummylogfn = tempfile.mkstemp(prefix='easybuild-dummy', suffix='.log')

test/framework/sandbox/easybuild/easyblocks/generic/configuremake.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@
2929
@author: Kenneth Hoste (Ghent University)
3030
"""
3131
from easybuild.framework.easyblock import EasyBlock
32+
from easybuild.framework.easyconfig import CUSTOM
3233

3334
class ConfigureMake(EasyBlock):
3435
"""Dummy support for building and installing applications with configure/make/make install."""
35-
pass
36+
37+
@staticmethod
38+
def extra_options(extra_vars=None):
39+
"""Extra easyconfig parameters specific to ConfigureMake."""
40+
extra_vars = EasyBlock.extra_options(extra=extra_vars)
41+
extra_vars.update({
42+
'test_bool': [False, "Just a test", CUSTOM],
43+
'test_none': [None, "Another test", CUSTOM],
44+
'test_123': ['', "Test 1, 2, 3", CUSTOM],
45+
})
46+
return extra_vars

0 commit comments

Comments
 (0)