| 1 |
import sys |
| 2 |
from pathlib import Path |
| 3 |
|
| 4 |
sys.path.insert(0, str(Path.cwd().resolve())) |
| 5 |
|
| 6 |
from docutils import nodes |
| 7 |
from docutils.parsers.rst import Directive |
| 8 |
|
| 9 |
from sphinx import addnodes |
| 10 |
|
| 11 |
extensions = [ |
| 12 |
'sphinx.ext.autodoc', |
| 13 |
'sphinx.ext.todo', |
| 14 |
'sphinx.ext.coverage', |
| 15 |
'sphinx.ext.extlinks', |
| 16 |
] |
| 17 |
|
| 18 |
jsmath_path = 'dummy.js' |
| 19 |
|
| 20 |
templates_path = ['_templates'] |
| 21 |
|
| 22 |
source_suffix = { |
| 23 |
'.txt': 'restructuredtext', |
| 24 |
'.foo': 'foo', |
| 25 |
} |
| 26 |
|
| 27 |
project = 'Sphinx <Tests>' |
| 28 |
copyright = '1234-6789, copyright text credits' |
| 29 |
# If this is changed, remember to update the versionchanges! |
| 30 |
version = '0.6' |
| 31 |
release = '0.6alpha1' |
| 32 |
today_fmt = '%B %d, %Y' |
| 33 |
exclude_patterns = ['_build', '**/excluded.*'] |
| 34 |
keep_warnings = True |
| 35 |
pygments_style = 'sphinx' |
| 36 |
show_authors = True |
| 37 |
numfig = True |
| 38 |
linkcheck_timeout = 0.25 |
| 39 |
|
| 40 |
html_sidebars = { |
| 41 |
'**': [ |
| 42 |
'localtoc.html', |
| 43 |
'relations.html', |
| 44 |
'sourcelink.html', |
| 45 |
'customsb.html', |
| 46 |
'searchbox.html', |
| 47 |
], |
| 48 |
'index': ['contentssb.html', 'localtoc.html', 'globaltoc.html'], |
| 49 |
} |
| 50 |
html_last_updated_fmt = '%b %d, %Y' |
| 51 |
html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'} |
| 52 |
|
| 53 |
latex_additional_files = ['svgimg.svg'] |
| 54 |
# some random pdf layout parameters to check they don't break build |
| 55 |
latex_elements = { |
| 56 |
'sphinxsetup': """ |
| 57 |
verbatimwithframe, |
| 58 |
verbatimwrapslines, |
| 59 |
verbatimforcewraps, |
| 60 |
verbatimmaxoverfull=1, |
| 61 |
verbatimmaxunderfull=5, |
| 62 |
verbatimhintsturnover=true, |
| 63 |
verbatimcontinuesalign=l, |
| 64 |
VerbatimColor={RGB}{242,242,242}, |
| 65 |
VerbatimBorderColor={RGB}{32,32,32}, |
| 66 |
VerbatimHighlightColor={RGB}{200,200,200}, |
| 67 |
pre_box-decoration-break=slice, |
| 68 |
pre_border-top-left-radius=20pt, |
| 69 |
pre_border-top-right-radius=0pt, |
| 70 |
pre_border-bottom-right-radius=20pt, |
| 71 |
pre_border-bottom-left-radius=0pt, |
| 72 |
verbatimsep=1pt, |
| 73 |
pre_padding=5pt,% alias to verbatimsep |
| 74 |
pre_border-top-width=5pt, |
| 75 |
pre_border-right-width=10pt, |
| 76 |
pre_border-bottom-width=15pt, |
| 77 |
pre_border-left-width=20pt, |
| 78 |
pre_border-width=3pt,% overrides all previous four |
| 79 |
verbatimborder=2pt,% alias to pre_border-width |
| 80 |
% |
| 81 |
shadowrule=1pt, |
| 82 |
shadowsep=10pt, |
| 83 |
shadowsize=-10pt, |
| 84 |
div.topic_border-width=2pt, |
| 85 |
div.topic_padding=6pt, |
| 86 |
div.topic_box-shadow=5pt, |
| 87 |
div.contents_border-width=3pt, |
| 88 |
div.contents_padding=10pt, |
| 89 |
div.contents_box-shadow=none, |
| 90 |
div.sidebar_border-width=0pt, |
| 91 |
div.sidebar_border-radius=0pt, |
| 92 |
% |
| 93 |
noteBorderColor={RGB}{204,204,204}, |
| 94 |
hintBorderColor={RGB}{204,204,204}, |
| 95 |
importantBorderColor={RGB}{204,204,204}, |
| 96 |
tipBorderColor={RGB}{204,204,204}, |
| 97 |
% |
| 98 |
noteborder=5pt, |
| 99 |
hintborder=5pt, |
| 100 |
importantborder=5pt, |
| 101 |
tipborder=5pt, |
| 102 |
% |
| 103 |
warningborder=3pt, |
| 104 |
cautionborder=3pt, |
| 105 |
attentionborder=3pt, |
| 106 |
errorborder=3pt, |
| 107 |
% |
| 108 |
dangerborder=3pt, |
| 109 |
div.danger_border-width=10pt, |
| 110 |
div.danger_background-TeXcolor={rgb}{0,1,0}, |
| 111 |
div.danger_border-TeXcolor={rgb}{0,0,1}, |
| 112 |
div.danger_box-shadow=20pt -20pt, |
| 113 |
div.danger_box-shadow-TeXcolor={rgb}{0.5,0.5,0.5}, |
| 114 |
% |
| 115 |
warningBorderColor={RGB}{255,119,119}, |
| 116 |
cautionBorderColor={RGB}{255,119,119}, |
| 117 |
attentionBorderColor={RGB}{255,119,119}, |
| 118 |
dangerBorderColor={RGB}{255,119,119}, |
| 119 |
errorBorderColor={RGB}{255,119,119}, |
| 120 |
warningBgColor={RGB}{255,238,238}, |
| 121 |
cautionBgColor={RGB}{255,238,238}, |
| 122 |
attentionBgColor={RGB}{255,238,238}, |
| 123 |
dangerBgColor={RGB}{255,238,238}, |
| 124 |
errorBgColor={RGB}{255,238,238}, |
| 125 |
% |
| 126 |
TableRowColorHeader={rgb}{0,1,0}, |
| 127 |
TableRowColorOdd={rgb}{0.5,0,0}, |
| 128 |
TableRowColorEven={rgb}{0.1,0.1,0.1}, |
| 129 |
""", |
| 130 |
} |
| 131 |
|
| 132 |
coverage_c_path = ['special/*.h'] |
| 133 |
coverage_c_regexes = {'function': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'} |
| 134 |
|
| 135 |
extlinks = { |
| 136 |
'issue': ('https://bugs.python.org/issue%s', 'issue %s'), |
| 137 |
'pyurl': ('https://python.org/%s', None), |
| 138 |
} |
| 139 |
|
| 140 |
# modify tags from conf.py |
| 141 |
tags.add('confpytag') # NoQA: F821 (tags is injected into conf.py) |
| 142 |
|
| 143 |
|
| 144 |
# -- extension API |
| 145 |
def userdesc_parse(env, sig, signode): |
| 146 |
x, y = sig.split(':') |
| 147 |
signode += addnodes.desc_name(x, x) |
| 148 |
signode += addnodes.desc_parameterlist() |
| 149 |
signode[-1] += addnodes.desc_parameter(y, y) |
| 150 |
return x |
| 151 |
|
| 152 |
|
| 153 |
class ClassDirective(Directive): |
| 154 |
option_spec = {'opt': lambda x: x} |
| 155 |
|
| 156 |
def run(self): |
| 157 |
return [nodes.strong(text='from class: %s' % self.options['opt'])] |
| 158 |
|
| 159 |
|
| 160 |
def setup(app): |
| 161 |
import parsermod |
| 162 |
|
| 163 |
app.add_directive('clsdir', ClassDirective) |
| 164 |
app.add_object_type( |
| 165 |
'userdesc', 'userdescrole', '%s (userdesc)', userdesc_parse, objname='user desc' |
| 166 |
) |
| 167 |
app.add_js_file('file://moo.js') |
| 168 |
app.add_source_suffix('.foo', 'foo') |
| 169 |
app.add_source_parser(parsermod.Parser) |