Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / man / conf.py
1 import os
2
3 project = u'Ceph'
4 copyright = u'2010-2014, Inktank Storage, Inc. and contributors. Licensed under Creative Commons BY-SA'
5 version = 'dev'
6 release = 'dev'
7
8 exclude_patterns = ['**/.#*', '**/*~']
9
10
11 def _get_description(fname, base):
12     with open(fname) as f:
13         one = None
14         while True:
15             line = f.readline().rstrip('\n')
16             if not line:
17                 continue
18             if line.startswith(':') and line.endswith(':'):
19                 continue
20             one = line
21             break
22         two = f.readline().rstrip('\n')
23         three = f.readline().rstrip('\n')
24         assert one == three
25         assert all(c=='=' for c in one)
26         name, description = two.split('--', 1)
27         assert name.strip() == base
28         return description.strip()
29
30
31 def _get_manpages():
32     src_dir = os.path.dirname(__file__)
33     top_srcdir = os.path.dirname(src_dir)
34     man_dir = os.path.join(top_srcdir, 'doc', 'man')
35     sections = os.listdir(man_dir)
36     for section in sections:
37         section_dir = os.path.join(man_dir, section)
38         if not os.path.isdir(section_dir):
39             continue
40         for filename in os.listdir(section_dir):
41             base, ext = os.path.splitext(filename)
42             if ext != '.rst':
43                 continue
44             if base == 'index':
45                 continue
46             path = os.path.join(section_dir, filename)
47             description = _get_description(path, base)
48             yield (
49                 os.path.join(section, base),
50                 base,
51                 description,
52                 '',
53                 section,
54                 )
55
56 man_pages = list(_get_manpages())
57 # sphinx warns if no toc is found, so feed it with a random file
58 # which is also rendered in this run.
59 master_doc = '8/ceph'