This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
/
conf.py
116 lines (82 loc) · 2.85 KB
/
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# encoding: utf-8
"""pyspotify documentation build configuration file"""
from __future__ import unicode_literals
import os
import re
import sys
import types
try:
# Python 3.3+
from unittest import mock
except ImportError:
# Python <3.3
import mock
def get_version(filename):
init_py = open(filename).read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
return metadata['version']
# -- Workarounds to have autodoc generate API docs ----------------------------
sys.path.insert(0, os.path.abspath('..'))
# Mock cffi module
module = mock.Mock()
module.ffi = mock.Mock()
module.ffi.CData = bytes
module.lib = mock.Mock()
module.lib.sp_error_message.return_value = b''
module.lib.sp_error_message.__name__ = str('sp_error_message')
sys.modules['spotify._spotify'] = module
# Add all libspotify constants to the lib mock
with open('sp-constants.csv') as fh:
for line in fh.readlines():
key, value = line.split(',', 1)
setattr(module.lib, key, value)
# Unwrap decorated methods so Sphinx can inspect their signatures
import spotify # flake8: noqa
for mod_name, mod in vars(spotify).items():
if not isinstance(mod, types.ModuleType) or mod_name in ('threading',):
continue
for class_name, cls in vars(mod).items():
if not isinstance(cls, type):
continue
for method_name, method in vars(cls).items():
if hasattr(method, '__wrapped__'):
setattr(cls, method_name, method.__wrapped__)
# -- General configuration ----------------------------------------------------
needs_sphinx = '1.0'
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = 'pyspotify'
copyright = '2013-2015, Stein Magnus Jodal and contributors'
release = get_version('../spotify/__init__.py')
version = '.'.join(release.split('.')[:2])
exclude_patterns = ['_build']
pygments_style = 'sphinx'
modindex_common_prefix = ['spotify.']
autodoc_default_flags = ['members', 'undoc-members', 'inherited-members']
autodoc_member_order = 'bysource'
intersphinx_mapping = {
'python': ('http://docs.python.org/3/', None),
'pyalsaaudio': ('https://larsimmisch.github.io/pyalsaaudio/', None),
}
# -- Options for HTML output --------------------------------------------------
#html_theme = 'default'
html_static_path = ['_static']
html_use_modindex = True
html_use_index = True
html_split_index = False
html_show_sourcelink = True
htmlhelp_basename = 'pyspotify'
# -- Options for extlink extension --------------------------------------------
extlinks = {
'issue': ('https://github.com/mopidy/pyspotify/issues/%s', '#'),
'ms-issue': (
'https://github.com/mopidy/mopidy-spotify/issues/%s',
'mopidy-spotify#'),
}