File: conf.py

package info (click to toggle)
pyliblo 0.16.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 336 kB
  • sloc: python: 552; makefile: 22; sh: 6
file content (71 lines) | stat: -rw-r--r-- 1,880 bytes parent folder | download | duplicates (2)
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
# -*- coding: utf-8 -*-
#
import sys, os

sys.path.insert(0, os.path.abspath('..'))

#extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.fulltoc']
extensions = ['sphinx.ext.autodoc']

templates_path = ['templates']
html_theme_path = ['theme']
exclude_patterns = ['build']

source_suffix = '.rst'
master_doc = 'index'

project = u'pyliblo'
copyright = u'2007-2014, Dominic Sacré'
version = '0.10.0'
release = ''

html_theme = 'nasophon'
html_copy_source = False
pygments_style = 'sphinx'

add_module_names = False
autodoc_member_order = 'bysource'
autodoc_default_flags = ['members', 'undoc-members']


from sphinx.ext.autodoc import py_ext_sig_re
from sphinx.util.docstrings import prepare_docstring
from sphinx.domains.python import PyObject, py_sig_re


def process_docstring(app, what, name, obj, options, lines):
    """
    Remove leading function signatures from docstring.
    """
    while len(lines) and py_ext_sig_re.match(lines[0]) is not None:
        del lines[0]

def process_signature(app, what, name, obj,
                      options, signature, return_annotation):
    """
    Replace function signature with those specified in the docstring.
    """
    if hasattr(obj, '__doc__') and obj.__doc__ is not None:
        lines = prepare_docstring(obj.__doc__)
        siglines = []

        for line in lines:
            if py_ext_sig_re.match(line) is not None:
                siglines.append(line)
            else:
                break

        if len(siglines):
            siglines[0] = siglines[0][siglines[0].index('('):]
            return ('\n'.join(siglines), None)

    return (signature, return_annotation)


# prevent exception fields from collapsing
PyObject.doc_field_types[2].can_collapse = False


def setup(app):
    app.connect('autodoc-process-docstring', process_docstring)
    app.connect('autodoc-process-signature', process_signature)