forked from niklasf/python-chess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.py
More file actions
84 lines (66 loc) · 2.44 KB
/
conf.py
File metadata and controls
84 lines (66 loc) · 2.44 KB
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
# -*- coding: utf-8 -*-
import asyncio
import sys
import os
import sphinx
import sphinx.ext.autodoc
import sphinx.domains.python
# Import the chess module.
sys.path.insert(0, os.path.abspath('..'))
import chess
# Autodoc.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
autodoc_member_order = 'bysource'
# The suffix of source filenames.
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "python-chess"
copyright = "2014–2019, Niklas Fiekas"
# The version.
version = chess.__version__
release = chess.__version__
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "default"
# Mark coroutine functions and methods.
def setup(app):
app.add_directive_to_domain("py", "coroutine", PyCoroutineFunction)
app.add_directive_to_domain("py", "coroutinemethod", PyCoroutineMethod)
app.add_autodocumenter(FunctionDocumenter)
app.add_autodocumenter(MethodDocumenter)
return {
"version": "1.0",
"parallel_read_safe": True,
}
class PyCoroutineMixin:
def handle_signature(self, sig, signode):
ret = super().handle_signature(sig, signode)
signode.insert(0, sphinx.addnodes.desc_annotation("coroutine ", "coroutine "))
return ret
class PyCoroutineFunction(PyCoroutineMixin, sphinx.domains.python.PyModulelevel):
def run(self):
self.name = "py:function"
return super().run()
class PyCoroutineMethod(PyCoroutineMixin, sphinx.domains.python.PyClassmember):
def run(self):
self.name = "py:method"
return super().run()
class FunctionDocumenter(sphinx.ext.autodoc.FunctionDocumenter):
def import_object(self):
ret = super().import_object()
if ret and asyncio.iscoroutinefunction(self.parent.__dict__.get(self.object_name)):
self.directivetype = "coroutine"
return ret
class MethodDocumenter(sphinx.ext.autodoc.MethodDocumenter):
def import_object(self):
ret = super().import_object()
if ret and asyncio.iscoroutinefunction(self.parent.__dict__.get(self.object_name)):
self.directivetype = "coroutinemethod"
return ret