-
Notifications
You must be signed in to change notification settings - Fork 1
/
remote_conf.py
96 lines (77 loc) · 3.44 KB
/
remote_conf.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# DON'T MOVE ME, OTHER REPO'S READTHEDOCS BUILDS DEPEND ON ME STAYING IN THIS DIRECTORY
#
# This file was written to build a shared readthedocs sidebar on the sovrin.readthedocs.io website.
#
# In each of the sovrin repo's docs folders, there exists a conf.py to be used when building documenation
# with sphinx. When our docs are build with readthedocs, the conf.py executes. There are a couple of lines
# in the conf.py that will clone and use this file to generate a shared sidebar that includes all of the repos
# listed below on the readthedocs website.
#
# There is almost certainly a better way to do this, but I have yet to figure that out. Please submit a PR
# against this repository if you would like to help make this process more elegant.
import os
def write_if_changed(fname, contents):
try:
with open(fname, 'r') as fp:
old_contents = fp.read()
except:
old_contents = ''
if old_contents != contents:
with open(fname, 'w') as fp:
fp.write(contents)
def generate_sidebar(conf, conf_api):
# determine 'latest' or 'stable'
# if not conf.do_gen:
do_gen = os.environ.get('SIDEBAR', None) == '1' or conf['on_rtd']
version = conf['rtd_version']
lines = [
'', '.. DO NOT MODIFY! THIS PAGE IS AUTOGENERATED!', ''
]
def toctree(name, depth):
lines.extend(['.. toctree::',
' :caption: %s' % name,
' :maxdepth: %d' % depth,
''])
def endl():
lines.append('')
def write_local_page(desc, link):
if conf_api == 'sovrin':
args = desc, link
else:
args = desc, 'https://sovrin-foundation.readthedocs.io/en/%s/%s.html' % (version, link)
lines.append(' %s <%s>' % args)
def write_subproject(project, desc, link):
if project != conf_api:
args = desc, project, version, link
lines.append(' %s <https://sovrin-foundation.readthedocs.io/projects/%s/en/%s/%s.html>' % args)
else:
lines.append(' %s <%s>' % (desc, link))
def write_link(desc, link):
lines.append(' %s <%s>' % (desc, link))
def write_page_title(title):
lines.append(title)
header_bar = '='
for i in range(0,len(title)):
header_bar += '='
lines.append(header_bar)
write_page_title('Sovrin')
# Begin creating sidebar
toctree('Sovrin', 2)
write_local_page('Introduction', 'index')
write_local_page('Build Script', 'build-scripts/ubuntu-1604/README')
write_local_page('Release Notes', 'release-notes')
toctree('Sovrin Repositories', 2)
write_subproject('connector-app', 'Connector App', 'index')
toctree('External Documentation', 1)
write_link('Hyperledger Indy', 'https://hyperledger-indy.readthedocs.io')
endl()
write_if_changed('toc.rst', '\n'.join(lines))
def get_intersphinx_mapping(version):
return {
'indy': ('http://indy.readthedocs.io/en/%s/' % version, None),
'indy-sdk': ('http://indy-sdk.readthedocs.io/en/%s/' % version, None),
'indy-node': ('http://indy-node.readthedocs.io/en/%s/' % version, None),
'indy-agent': ('http://indy-agent.readthedocs.io/en/%s' % version, None),
'indy-plenum': ('http://indy-plenum.readthedocs.io/en/%s' % version, None),
'indy-hipe': ('http://hipe.readthedocs.io/en/%s' % version, None),
}