summary refs log tree commit diff stats
path: root/tests/manpage_completion_test.py
blob: b9504d06ff26421798690f6851e953abbf6c2cde (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python

from __future__ import (absolute_import, division, print_function)

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()
b3'>93358d5e ^
fb7001cf ^
72c1c496 ^
bab75cae ^
d3cc5bd7 ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65




           


                              
                             

                                 
                       






                     
                  

                   
                 
                  
                     
                   
                    
              
                









                          
                    
                        
                 
                         
                         
                     
                       
                   
                           
                   
                     

                      


               
             
             
               
                
                   




                    
[ui]
beep=false
flash=false
splash=true
wrap=true
time.console=%d/%m/%y %H:%M:%S
time.chat=%d/%m/%y %H:%M:%S
time.muc=%d/%m/%y %H:%M:%S
time.config=%d/%m/%y %H:%M:%S
time.private=%d/%m/%y %H:%M:%S
time.xmlconsole=%d/%m/%y %H:%M:%S
time.statusbar=%H:%M:%S
resource.title=true
resource.message=true
statuses.console=all
statuses.chat=all
statuses.muc=all
occupants=true
occupants.size=15
occupants.jid=true
roster=true
roster.offline=true
roster.empty=true
roster.by=presence
roster.order=presence
roster.unread=after
roster.priority=true
roster.size=25
roster.wrap=true
roster.header.char=@
roster.contact.char=-
roster.contact.indent=1
roster.resource=true
roster.resource.char=/
roster.resource.indent=1
roster.resource.join=false
roster.presence=true
roster.presence.indent=1
roster.status=true
roster.contacts=true
roster.unsubscribed=true
roster.rooms=true
roster.rooms.order=unread
roster.rooms.unread=after
roster.rooms.pos=last
roster.rooms.by=service
roster.rooms.char=#
roster.rooms.private.char=/
roster.private=room
roster.private.char=+
roster.count=unread
roster.count.zero=true
privileges=true
presence=true
intype=true
enc.warn=true
tls.show=true
console.muc=all
console.chat=all
console.private=all
titlebar.position=1
mainwin.position=2
statusbar.position=3
inputwin.position=4