| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
|
| 4 |
# miniEigen documentation build configuration file, created by |
| 5 |
# sphinx-quickstart on Thu Feb 16 09:55:33 2012. |
| 6 |
# |
| 7 |
# This file is execfile()d with the current directory set to its containing dir. |
| 8 |
# |
| 9 |
# Note that not all possible configuration values are present in this |
| 10 |
# autogenerated file. |
| 11 |
# |
| 12 |
# All configuration values have a default; values that are commented out |
| 13 |
# serve to show the default. |
| 14 |
|
| 15 |
import sys, os, re, glob |
| 16 |
|
| 17 |
# If extensions (or modules to document with autodoc) are in another directory, |
| 18 |
# add these directories to sys.path here. If the directory is relative to the |
| 19 |
# documentation root, use os.path.abspath to make it absolute, like shown here. |
| 20 |
|
| 21 |
#sys.path.insert(0, os.path.abspath('../../src')) |
| 22 |
|
| 23 |
# possible locations |
| 24 |
for p in ('../../build/lib.*','../../debian/python-minieigen/usr/lib/python*/dist-packages','../../debian/python3-minieigen/usr/lib/python*/dist-packages'): |
| 25 |
pp=glob.glob(os.path.abspath(p)) |
| 26 |
if pp: sys.path.insert(0,pp[0]) |
| 27 |
print sys.path |
| 28 |
|
| 29 |
|
| 30 |
def isBoostFunc(what,obj): |
| 31 |
return what=='function' and obj.__repr__().startswith('<Boost.Python.function object at 0x') |
| 32 |
def isBoostMethod(what,obj): |
| 33 |
"I don't know how to distinguish boost and non-boost methods..." |
| 34 |
return what=='method' and obj.__repr__().startswith('<unbound method ') |
| 35 |
def isBoostStaticMethod(what,obj): |
| 36 |
return what=='method' and obj.__repr__().startswith('<Boost.Python.function object at 0x') |
| 37 |
|
| 38 |
def fixDocstring(app,what,name,obj,options,lines): |
| 39 |
if isBoostFunc(what,obj) or isBoostMethod(what,obj) or isBoostStaticMethod(what,obj): |
| 40 |
l2=boostFuncSignature(name,obj)[1] |
| 41 |
# we must replace lines one by one (in-place) :-| |
| 42 |
# knowing that l2 is always shorter than lines (l2 is docstring with the signature stripped off) |
| 43 |
for i in range(0,len(lines)): |
| 44 |
lines[i]=l2[i] if i<len(l2) else '' |
| 45 |
|
| 46 |
def fixSignature(app, what, name, obj, options, signature, return_annotation): |
| 47 |
print what,obj |
| 48 |
if what in ('attribute','class'): return signature,None |
| 49 |
elif isBoostFunc(what,obj): |
| 50 |
sig=boostFuncSignature(name,obj)[0] or ' (wrapped c++ function)' |
| 51 |
return sig,None |
| 52 |
elif isBoostMethod(what,obj): |
| 53 |
sig=boostFuncSignature(name,obj,removeSelf=True)[0] |
| 54 |
return sig,None |
| 55 |
elif isBoostStaticMethod(what,obj): |
| 56 |
sig=boostFuncSignature(name,obj,removeSelf=False)[0]+' [STATIC]' |
| 57 |
return sig,None |
| 58 |
|
| 59 |
def boostFuncSignature(name,obj,removeSelf=False): |
| 60 |
"""Scan docstring of obj, returning tuple of properly formatted boost python signature |
| 61 |
(first line of the docstring) and the rest of docstring (as list of lines). |
| 62 |
The rest of docstring is stripped of 4 leading spaces which are automatically |
| 63 |
added by boost. |
| 64 |
|
| 65 |
removeSelf will attempt to remove the first argument from the signature. |
| 66 |
""" |
| 67 |
doc=obj.__doc__ |
| 68 |
if doc==None: # not a boost method |
| 69 |
return None,None |
| 70 |
nname=name.split('.')[-1] |
| 71 |
docc=doc.split('\n') |
| 72 |
if len(docc)<2: return None,docc |
| 73 |
doc1=docc[1] |
| 74 |
# functions with weird docstring, likely not documented by boost |
| 75 |
if not re.match('^'+nname+r'(.*)->.*$',doc1): |
| 76 |
return None,docc |
| 77 |
if doc1.endswith(':'): doc1=doc1[:-1] |
| 78 |
strippedDoc=doc.split('\n')[2:] |
| 79 |
# check if all lines are padded |
| 80 |
allLinesHave4LeadingSpaces=True |
| 81 |
for l in strippedDoc: |
| 82 |
if l.startswith(' '): continue |
| 83 |
allLinesHave4LeadingSpaces=False; break |
| 84 |
# remove the padding if so |
| 85 |
if allLinesHave4LeadingSpaces: strippedDoc=[l[4:] for l in strippedDoc] |
| 86 |
for i in range(len(strippedDoc)): |
| 87 |
# fix signatures inside docstring (one function with multiple signatures) |
| 88 |
strippedDoc[i],n=re.subn(r'([a-zA-Z_][a-zA-Z0-9_]*\() \(object\)arg1(, |)',r'\1',strippedDoc[i].replace('->','→')) |
| 89 |
# inspect dosctring after mangling |
| 90 |
sig=doc1.split('(',1)[1] |
| 91 |
if removeSelf: |
| 92 |
# remove up to the first comma; if no comma present, then the method takes no arguments |
| 93 |
# if [ precedes the comma, add it to the result (ugly!) |
| 94 |
try: |
| 95 |
ss=sig.split(',',1) |
| 96 |
if ss[0].endswith('['): sig='['+ss[1] |
| 97 |
else: sig=ss[1] |
| 98 |
except IndexError: |
| 99 |
# grab the return value |
| 100 |
try: |
| 101 |
sig=') -> '+sig.split('->')[-1] |
| 102 |
except IndexError: |
| 103 |
sig=')' |
| 104 |
return '('+sig,strippedDoc |
| 105 |
|
| 106 |
def setup(app): |
| 107 |
app.connect('autodoc-process-docstring',fixDocstring) |
| 108 |
app.connect('autodoc-process-signature',fixSignature) |
| 109 |
|
| 110 |
|
| 111 |
# |
| 112 |
# -- General configuration ----------------------------------------------------- |
| 113 |
|
| 114 |
# If your documentation needs a minimal Sphinx version, state it here. |
| 115 |
#needs_sphinx = '1.0' |
| 116 |
|
| 117 |
# Add any Sphinx extension module names here, as strings. They can be extensions |
| 118 |
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. |
| 119 |
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.pngmath', 'sphinx.ext.todo'] |
| 120 |
|
| 121 |
# Add any paths that contain templates here, relative to this directory. |
| 122 |
templates_path = ['_templates'] |
| 123 |
|
| 124 |
# The suffix of source filenames. |
| 125 |
source_suffix = '.rst' |
| 126 |
|
| 127 |
# The encoding of source files. |
| 128 |
#source_encoding = 'utf-8-sig' |
| 129 |
|
| 130 |
# The master toctree document. |
| 131 |
master_doc = 'index' |
| 132 |
|
| 133 |
# General information about the project. |
| 134 |
project = u'minieigen' |
| 135 |
copyright = u'2012−2015, Václav Šmilauer' |
| 136 |
|
| 137 |
# The version info for the project you're documenting, acts as replacement for |
| 138 |
# |version| and |release|, also used in various other places throughout the |
| 139 |
# built documents. |
| 140 |
# |
| 141 |
# The short X.Y version. |
| 142 |
version = '0.4' |
| 143 |
# The full version, including alpha/beta/rc tags. |
| 144 |
release = '0.4-1' |
| 145 |
|
| 146 |
# The language for content autogenerated by Sphinx. Refer to documentation |
| 147 |
# for a list of supported languages. |
| 148 |
#language = None |
| 149 |
|
| 150 |
# There are two options for replacing |today|: either, you set today to some |
| 151 |
# non-false value, then it is used: |
| 152 |
#today = '' |
| 153 |
# Else, today_fmt is used as the format for a strftime call. |
| 154 |
#today_fmt = '%B %d, %Y' |
| 155 |
|
| 156 |
# List of patterns, relative to source directory, that match files and |
| 157 |
# directories to ignore when looking for source files. |
| 158 |
exclude_patterns = [] |
| 159 |
|
| 160 |
# The reST default role (used for this markup: `text`) to use for all documents. |
| 161 |
#default_role = None |
| 162 |
|
| 163 |
# If true, '()' will be appended to :func: etc. cross-reference text. |
| 164 |
#add_function_parentheses = True |
| 165 |
|
| 166 |
# If true, the current module name will be prepended to all description |
| 167 |
# unit titles (such as .. function::). |
| 168 |
#add_module_names = True |
| 169 |
|
| 170 |
# If true, sectionauthor and moduleauthor directives will be shown in the |
| 171 |
# output. They are ignored by default. |
| 172 |
#show_authors = False |
| 173 |
|
| 174 |
# The name of the Pygments (syntax highlighting) style to use. |
| 175 |
pygments_style = 'sphinx' |
| 176 |
|
| 177 |
# A list of ignored prefixes for module index sorting. |
| 178 |
#modindex_common_prefix = [] |
| 179 |
|
| 180 |
|
| 181 |
# -- Options for HTML output --------------------------------------------------- |
| 182 |
|
| 183 |
# The theme to use for HTML and HTML Help pages. See the documentation for |
| 184 |
# a list of builtin themes. |
| 185 |
html_theme = 'classic' |
| 186 |
|
| 187 |
# Theme options are theme-specific and customize the look and feel of a theme |
| 188 |
# further. For a list of options available for each theme, see the |
| 189 |
# documentation. |
| 190 |
#html_theme_options = {} |
| 191 |
|
| 192 |
# Add any paths that contain custom themes here, relative to this directory. |
| 193 |
#html_theme_path = [] |
| 194 |
|
| 195 |
# The name for this set of Sphinx documents. If None, it defaults to |
| 196 |
# "<project> v<release> documentation". |
| 197 |
#html_title = None |
| 198 |
|
| 199 |
# A shorter title for the navigation bar. Default is the same as html_title. |
| 200 |
#html_short_title = None |
| 201 |
|
| 202 |
# The name of an image file (relative to this directory) to place at the top |
| 203 |
# of the sidebar. |
| 204 |
#html_logo = None |
| 205 |
|
| 206 |
# The name of an image file (within the static path) to use as favicon of the |
| 207 |
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 |
| 208 |
# pixels large. |
| 209 |
#html_favicon = None |
| 210 |
|
| 211 |
# Add any paths that contain custom static files (such as style sheets) here, |
| 212 |
# relative to this directory. They are copied after the builtin static files, |
| 213 |
# so a file named "default.css" will overwrite the builtin "default.css". |
| 214 |
html_static_path = ['_static'] |
| 215 |
|
| 216 |
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, |
| 217 |
# using the given strftime format. |
| 218 |
#html_last_updated_fmt = '%b %d, %Y' |
| 219 |
|
| 220 |
# If true, SmartyPants will be used to convert quotes and dashes to |
| 221 |
# typographically correct entities. |
| 222 |
#html_use_smartypants = True |
| 223 |
|
| 224 |
# Custom sidebar templates, maps document names to template names. |
| 225 |
#html_sidebars = {} |
| 226 |
|
| 227 |
# Additional templates that should be rendered to pages, maps page names to |
| 228 |
# template names. |
| 229 |
#html_additional_pages = {} |
| 230 |
|
| 231 |
# If false, no module index is generated. |
| 232 |
html_domain_indices = False |
| 233 |
|
| 234 |
# If false, no index is generated. |
| 235 |
html_use_index = True |
| 236 |
|
| 237 |
# If true, the index is split into individual pages for each letter. |
| 238 |
#html_split_index = False |
| 239 |
|
| 240 |
# If true, links to the reST sources are added to the pages. |
| 241 |
html_show_sourcelink = False |
| 242 |
|
| 243 |
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. |
| 244 |
#html_show_sphinx = True |
| 245 |
|
| 246 |
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. |
| 247 |
#html_show_copyright = True |
| 248 |
|
| 249 |
# If true, an OpenSearch description file will be output, and all pages will |
| 250 |
# contain a <link> tag referring to it. The value of this option must be the |
| 251 |
# base URL from which the finished HTML is served. |
| 252 |
#html_use_opensearch = '' |
| 253 |
|
| 254 |
# This is the file name suffix for HTML files (e.g. ".xhtml"). |
| 255 |
#html_file_suffix = None |
| 256 |
|
| 257 |
# Output file base name for HTML help builder. |
| 258 |
htmlhelp_basename = 'minieigen' |
| 259 |
|
| 260 |
|
| 261 |
# -- Options for LaTeX output -------------------------------------------------- |
| 262 |
|
| 263 |
# The paper size ('letter' or 'a4'). |
| 264 |
#latex_paper_size = 'letter' |
| 265 |
|
| 266 |
# The font size ('10pt', '11pt' or '12pt'). |
| 267 |
#latex_font_size = '10pt' |
| 268 |
|
| 269 |
# Grouping the document tree into LaTeX files. List of tuples |
| 270 |
# (source start file, target name, title, author, documentclass [howto/manual]). |
| 271 |
latex_documents = [ |
| 272 |
('index', 'minieigen.tex', u'minieigen Documentation', |
| 273 |
u'Václav Šmilauer', 'manual'), |
| 274 |
] |
| 275 |
|
| 276 |
# The name of an image file (relative to this directory) to place at the top of |
| 277 |
# the title page. |
| 278 |
#latex_logo = None |
| 279 |
|
| 280 |
# For "manual" documents, if this is true, then toplevel headings are parts, |
| 281 |
# not chapters. |
| 282 |
#latex_use_parts = False |
| 283 |
|
| 284 |
# If true, show page references after internal links. |
| 285 |
#latex_show_pagerefs = False |
| 286 |
|
| 287 |
# If true, show URL addresses after external links. |
| 288 |
#latex_show_urls = False |
| 289 |
|
| 290 |
# Additional stuff for the LaTeX preamble. |
| 291 |
#latex_preamble = '' |
| 292 |
|
| 293 |
# Documents to append as an appendix to all manuals. |
| 294 |
#latex_appendices = [] |
| 295 |
|
| 296 |
# If false, no module index is generated. |
| 297 |
#latex_domain_indices = True |
| 298 |
|
| 299 |
|
| 300 |
# -- Options for manual page output -------------------------------------------- |
| 301 |
|
| 302 |
# One entry per manual page. List of tuples |
| 303 |
# (source start file, name, description, authors, manual section). |
| 304 |
man_pages = [ |
| 305 |
('index', 'minieigen', u'minieigen Documentation', |
| 306 |
[u'Václav Šmilauer'], 1) |
| 307 |
] |
| 308 |
|
| 309 |
todo_include_todos=True |
| 310 |
|