Skip to content

Commit

Permalink
restore rst_invalid function
Browse files Browse the repository at this point in the history
used in planemo galaxyproject/planemo#1275

has been removed here galaxyproject#14588
  • Loading branch information
bernt-matthias committed Jan 31, 2023
1 parent ca1d2f5 commit c0eb661
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/galaxy/tool_util/linters/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ def lint_help(tool_xml, lint_ctx):
if "TODO" in help_text:
lint_ctx.warn("Help contains TODO text.", node=helps[0])

invalid_rst = rst_invalid(help_text)
if invalid_rst:
lint_ctx.warn(f"Invalid reStructuredText found in help - [{invalid_rst}].", node=helps[0])
else:
lint_ctx.valid("Help contains valid reStructuredText.", node=helps[0])


def rst_invalid(text):
"""
Predicate to determine if text is invalid reStructuredText.
Return False if the supplied text is valid reStructuredText or
a string indicating the problem.
"""
invalid_rst = False
try:
rst_to_html(help_text, error=True)
rst_to_html(text, error=True)
except Exception as e:
lint_ctx.warn(f"Invalid reStructuredText found in help - [{unicodify(e)}].", node=helps[0])
return

lint_ctx.valid("Help contains valid reStructuredText.", node=helps[0])
invalid_rst = unicodify(e)
return invalid_rst

0 comments on commit c0eb661

Please sign in to comment.