mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #15457 from bernt-matthias/topic/rst_invalid
[22.05] restore rst_invalid function
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
"""This module contains a linting function for a tool's help."""
|
||||
|
||||
from typing import Union
|
||||
|
||||
from galaxy.util import (
|
||||
rst_to_html,
|
||||
unicodify,
|
||||
@@ -30,10 +33,22 @@ def lint_help(tool_xml, lint_ctx):
|
||||
if "TODO" in help_text:
|
||||
lint_ctx.warn("Help contains TODO text.", node=helps[0])
|
||||
|
||||
try:
|
||||
rst_to_html(help_text, error=True)
|
||||
except Exception as e:
|
||||
lint_ctx.warn(f"Invalid reStructuredText found in help - [{unicodify(e)}].", node=helps[0])
|
||||
return
|
||||
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])
|
||||
|
||||
lint_ctx.valid("Help contains valid reStructuredText.", node=helps[0])
|
||||
|
||||
def rst_invalid(text: str) -> Union[bool, str]:
|
||||
"""
|
||||
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: Union[bool, str] = False
|
||||
try:
|
||||
rst_to_html(text, error=True)
|
||||
except Exception as e:
|
||||
invalid_rst = unicodify(e)
|
||||
return invalid_rst
|
||||
|
||||
Reference in New Issue
Block a user