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
#!/usr/bin/env python3
'''
Sphinx configuration file.
'''

# pylint: disable=invalid-name,redefined-builtin

import importlib
import pathlib
import sys

source_code = '../../src'
git_url = 'https://gitlab.inria.fr/jrye/chemfeat'

this_path = pathlib.Path(__file__).resolve()
sys.path.insert(0, str((this_path.parent / source_code).resolve()))

author = 'Jan-Michael Rye'
copyright = '2023, Inria'
project = 'Chemfeat'
html_theme = 'sphinx_rtd_theme'

autodoc_mock_imports = [
    'PaDEL_pywrapper',
    'docstring_parser',
    'pandas',
    'rdkit',
    'simple_file_lock',
    'yaml'
]
extensions = [
    'myst_parser',
    'sphinx.ext.autodoc',
    'sphinx.ext.linkcode',
    'sphinx.ext.napoleon',
    'sphinx.ext.todo'
]
index_entries = [
    'gen_command_help',
    'gen_feature_set_configuration',
    'gen_features'
]


def skip(_app, _what, name, _obj, would_skip, _options):  # pylint: disable=too-many-arguments
    '''Customize autodoc member skipping.'''
    if name == '__init__':
        return False
    return would_skip


def setup(app):
    '''Connect the skip function.'''
    app.connect('autodoc-skip-member', skip)


def linkcode_resolve(domain, info):
    '''Get source links for the linkcode extension.'''
    module = info['module']
    if domain != 'py' or not module:
        return None
    top_mod = importlib.import_module(module.split('.')[0])
    mod = importlib.import_module(module)
    top_mod_path = pathlib.Path(top_mod.__file__)
    mod_path = pathlib.Path(mod.__file__)
    subpath = str(mod_path.relative_to(top_mod_path.parent.parent))
    return f'{git_url}/-/blob/main/src/{subpath}'