Skip to content

add support for using --output-format=md (MarkDown) #4117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
62457f7
add support for MarkDown ('md') output format for --list-easyblocks
boegel Oct 31, 2022
e825d78
add test for list_easyblocks function
boegel Oct 31, 2022
14f5486
add support for MarkDown ('md') output format for --avail-easyconfig-…
boegel Oct 31, 2022
86edb74
add tests for mk_*_table and *_title_and_table functions
boegel Oct 31, 2022
19f2a1e
remove unused textwrap import
boegel Oct 31, 2022
84e8725
add support for MarkDown ('md') output format for --list-software
boegel Dec 5, 2022
f0c877b
strip trailing whitespace in table rows in mk_md_table and mk_rst_table
boegel Dec 6, 2022
841ab60
implement support for '--avail-cfgfile-constants --output-format md' …
boegel Dec 9, 2022
c2a3e51
add test for avail_cfgfile_constants docs function
boegel Dec 9, 2022
ab4c334
run docs test suite before options test suite, to avoid included easy…
boegel Dec 9, 2022
30763d4
add test for avail_easyconfig_constants function
boegel Dec 9, 2022
d2387c5
implement support for '--avail-easyconfig-licenses --output-format md'
boegel Dec 16, 2022
bd612f3
implement support for '--avail-easyconfig-templates --output-format md'
boegel Jan 2, 2023
eac5142
Merge branch 'develop' into docs_md
boegel Jan 2, 2023
47e745d
stop using sort_looseversions in list_software_md
boegel Jan 2, 2023
58300f5
implement support for '--list-toolchains --output-format md' + provid…
boegel Jan 2, 2023
7c2bec6
add test for list_toolchains
boegel Jan 2, 2023
60f3aa8
implement support for '--avail-toolchain-opts ... --output-format md'
boegel Jan 3, 2023
63df90a
add support for 'eb --help=md' + dedicated test
boegel Jan 3, 2023
ff63993
fix test_templating_doc
boegel Jan 3, 2023
f136c93
add support for generating overview of easyblocks in MarkDown format …
boegel Jan 3, 2023
4ba33e4
do not use mutable data structures for argument defaults in gen_easyb…
boegel Jan 3, 2023
ba20c2b
fix test__list_toolchains
boegel Jan 3, 2023
dd50ce6
drop useless anchor in MarkDown version of easyblocks overview
boegel Jan 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions easybuild/base/generaloption.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from easybuild.base.fancylogger import getLogger, setroot, setLogLevel, getDetailsLogLevels
from easybuild.base.optcomplete import autocomplete, CompleterOption
from easybuild.tools.py2vs3 import StringIO, configparser, string_type, subprocess_popen_text
from easybuild.tools.utilities import mk_rst_table, nub, shell_quote
from easybuild.tools.utilities import mk_md_table, mk_rst_table, nub, shell_quote

try:
import gettext
Expand All @@ -65,7 +65,7 @@ def _gettext(message):
return message


HELP_OUTPUT_FORMATS = ['', 'rst', 'short', 'config']
HELP_OUTPUT_FORMATS = ['', 'md', 'rst', 'short', 'config']


def set_columns(cols=None):
Expand Down Expand Up @@ -638,6 +638,45 @@ def print_help(self, fh=None):
fh = self.check_help(fh)
OptionParser.print_help(self, fh)

def print_mdhelp(self, fh=None):
"""Print help in MarkDown format"""
fh = self.check_help(fh)
result = []
if self.usage:
result.extend(["## Usage", '', '``%s``' % self.get_usage().replace("Usage: ", '').strip(), ''])
if self.description:
result.extend(["## Description", '', self.description, ''])

result.append(self.format_option_mdhelp())

mdhelptxt = '\n'.join(result)
if fh is None:
fh = sys.stdout
fh.write(mdhelptxt)

def format_option_mdhelp(self, formatter=None):
""" Formatting for help in rst format """
if not formatter:
formatter = self.formatter
formatter.store_option_strings(self)

res = []
titles = ["Option flag", "Option description"]

all_opts = [("Help options", self.option_list)] + \
[(group.title, group.option_list) for group in self.option_groups]
for title, opts in all_opts:
values = []
res.extend(['## ' + title, ''])
for opt in opts:
if opt.help is not nohelp:
values.append(['``%s``' % formatter.option_strings[opt], formatter.expand_default(opt)])

res.extend(mk_md_table(titles, map(list, zip(*values))))
res.append('')

return '\n'.join(res)

def print_rsthelp(self, fh=None):
""" Print help in rst format """
fh = self.check_help(fh)
Expand Down
Loading