Debian Codegraph @

tests/roots/test-ext-viewcode-find-package/conf.py

raw
1 import sys
2 from pathlib import Path
3
4 source_dir = str(Path.cwd().resolve())
5 if source_dir not in sys.path:
6 sys.path.insert(0, source_dir)
7 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
8 exclude_patterns = ['_build']
9
10
11 if 'test_linkcode' in tags: # NoQA: F821 (tags is injected into conf.py)
12 extensions.remove('sphinx.ext.viewcode')
13 extensions.append('sphinx.ext.linkcode')
14
15 def linkcode_resolve(domain, info):
16 if domain == 'py':
17 fn = info['module'].replace('.', '/')
18 return 'http://foobar/source/%s.py' % fn
19 elif domain == 'js':
20 return 'http://foobar/js/' + info['fullname']
21 elif domain in {'c', 'cpp'}:
22 return 'http://foobar/%s/%s' % (domain, ''.join(info['names']))
23 else:
24 raise AssertionError