summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/actions.py3
-rw-r--r--ranger/ext/trim.py31
2 files changed, 2 insertions, 32 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index 25c8262c..bc6da7b8 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -1,5 +1,6 @@
 import os
 import shutil
+from inspect import cleandoc
 
 from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
@@ -183,7 +184,7 @@ class Actions(EnvironmentAware, SettingsAware):
 			return
 
 		pager = self.ui.open_pager()
-		lines = trimmed_lines_of_docstring(command.__doc__)
+		lines = cleandoc(command.__doc__).split('\n')
 		pager.set_source(lines)
 	
 	def display_log(self):
diff --git a/ranger/ext/trim.py b/ranger/ext/trim.py
deleted file mode 100644
index d469435d..00000000
--- a/ranger/ext/trim.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import sys
-
-def trim_docstring(docstring):
-	if not docstring:
-		return ''
-	return '\n'.join(trimmed_lines_of_docstring(docstring))
-
-def trimmed_lines_of_docstring(docstring):
-	if not docstring:
-		return []
-	# Convert tabs to spaces (following the normal Python rules)
-	# and split into a list of lines:
-	lines = docstring.expandtabs().splitlines()
-	# Determine minimum indentation (first line doesn't count):
-	indent = sys.maxint
-	for line in lines[1:]:
-		stripped = line.lstrip()
-		if stripped:
-			indent = min(indent, len(line) - len(stripped))
-	# Remove indentation (first line is special):
-	trimmed = [lines[0].strip()]
-	if indent < sys.maxint:
-		for line in lines[1:]:
-			trimmed.append(line[indent:].rstrip())
-	# Strip off trailing and leading blank lines:
-	while trimmed and not trimmed[-1]:
-		trimmed.pop()
-	while trimmed and not trimmed[0]:
-		trimmed.pop(0)
-	# Return a single string:
-	return trimmed