summaryrefslogtreecommitdiff
path: root/pylint/utils/utils.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2019-06-10 08:35:57 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-06-20 14:09:59 +0200
commitb473ef86bb91d639a20754adc4f7ab83f2241de5 (patch)
tree1c7642bd9683c8ee572b051dbac82390b254faa5 /pylint/utils/utils.py
parent2cabf33c96008b1f27d591a1495c3720869de4c9 (diff)
downloadpylint-git-b473ef86bb91d639a20754adc4f7ab83f2241de5.tar.gz
Refactor - Move utility function to utils
We want to use them in Checker too.
Diffstat (limited to 'pylint/utils/utils.py')
-rw-r--r--pylint/utils/utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index ab28a07b5..c2216575f 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -51,6 +51,31 @@ def category_id(cid):
return MSG_TYPES_LONG.get(cid)
+def get_rest_title(title, character):
+ """Permit to get a rest title underlined with a choosen character."""
+ return "%s\n%s\n" % (title, character * len(title))
+
+
+def rest_format_section(section, options, doc=None):
+ """format an options section using as ReST formatted output"""
+ result = ""
+ if section:
+ result += get_rest_title(section, "'")
+ if doc:
+ formatted_doc = normalize_text(doc, line_len=79, indent="")
+ result += "%s\n\n" % formatted_doc
+ for optname, optdict, value in options:
+ help_opt = optdict.get("help")
+ result += ":%s:\n" % optname
+ if help_opt:
+ formatted_help = normalize_text(help_opt, line_len=79, indent=" ")
+ result += "%s\n" % formatted_help
+ if value:
+ value = str(_format_option_value(optdict, value))
+ result += "\n Default: ``%s``\n" % value.replace("`` ", "```` ``")
+ return result
+
+
def safe_decode(line, encoding, *args, **kwargs):
"""return decoded line from encoding or decode with default encoding"""
try: