summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@hut.pm>2018-01-28 16:43:27 +0100
committerhut <hut@hut.pm>2018-01-28 16:43:27 +0100
commit01a3ea7c7b5f1ad7f5ce47e7bb05b0ed06232347 (patch)
treedc5c2f4743d6246d622a90deacbc709ea0931cb2
parent1b92d69060743eb8b6468cda15ed5266d4397719 (diff)
parent1c44d556112c0bacf875fc80133d00097f2336fb (diff)
downloadranger-01a3ea7c7b5f1ad7f5ce47e7bb05b0ed06232347.tar.gz
Merge branch 'master' into v1.9.0
-rwxr-xr-xtests/manpage_completion_test.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/manpage_completion_test.py b/tests/manpage_completion_test.py
new file mode 100755
index 00000000..a1dd06e0
--- /dev/null
+++ b/tests/manpage_completion_test.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+
+import os.path
+import re
+import sys
+
+
+# Add relevant ranger module to PATH... there surely is a better way to do this...
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+
+def report(boolean, errormessage):
+    if not boolean:
+        sys.stderr.write('TEST FAILURE: ')
+        sys.stderr.write(errormessage)
+        sys.stderr.write('\n')
+        sys.stderr.flush()
+
+
+def get_path_of_man_page():
+    dirpath_of_this_file = os.path.dirname(__file__)
+    return os.path.join(dirpath_of_this_file, '..', 'doc', 'ranger.pod')
+
+
+def read_manpage():
+    path = get_path_of_man_page()
+    return open(path, 'r').read()
+
+
+def get_sections():
+    manpage = read_manpage()
+    parts = manpage.split('=head1 ')
+    sections = dict()
+    for part in parts:
+        if '\n' in part:
+            section_name, section_content = part.split('\n', 1)
+            sections[section_name] = section_content
+        else:
+            pass
+    return sections
+
+
+def find_undocumented_settings():
+    from ranger.container.settings import ALLOWED_SETTINGS
+    sections = get_sections()
+    setting_section = sections['SETTINGS']
+    matcher_pattern = r'^=item [\w\d_, ]*{setting}'
+    for setting in ALLOWED_SETTINGS:
+        matcher = re.compile(matcher_pattern.format(setting=setting), re.M)
+        report(matcher.search(setting_section),
+               ('Setting %s is not documented in the man page!' % setting))
+
+
+if __name__ == '__main__':
+    find_undocumented_settings()