21 sys.path.insert(0, os.path.abspath(
"extensions"))
37 'sphinx.ext.intersphinx',
41 'sphinx.ext.napoleon',
42 'sphinx.ext.viewcode',
43 'sphinx.ext.autosectionlabel',
44 'sphinx_codeautolink',
48 'sphinxcontrib.programoutput',
49 'IPython.sphinxext.ipython_console_highlighting',
54 codeautolink_warn_on_missing_inventory =
False
55 codeautolink_warn_on_failed_resolve =
False
57 nbsphinx_allow_errors =
True
62 nbsphinx_custom_formats = {
63 '.doc.jupy.py':
lambda s: jupytext.reads(s,
'.py'),
70 autosectionlabel_prefix_document =
True
71 suppress_warnings = [
'autosectionlabel.*',
'codeautolink.*']
74 templates_path = [
'_sphinxtemplates']
79 source_suffix =
'.rst'
89 copyright =
'Belle II Collaboration'
90 author =
'Belle II Software Group'
97 version = subprocess.check_output([
"git",
"rev-parse",
"--short",
"HEAD"]).decode().strip()
99 basf2_repository =
"https://gitlab.desy.de/belle2/software/basf2/"
100 basf2_commitid = subprocess.check_output([
"git",
"rev-parse",
"HEAD"]).decode().strip()
101 basf2_issues =
"https://gitlab.desy.de/belle2/software/basf2/-/issues/"
104 release = os.environ.get(
'BELLE2_RELEASE',
'development')
105 if release ==
'head':
106 release =
'development'
109 keep_warnings = release ==
"development"
110 nitpicky = keep_warnings
114 for entry
in [
'cppyy.gbl.TObject',
'cppyy.gbl.TFile',
'ROOT.TFile']:
115 nitpick_ignore.append((
'py:class', entry))
116 for entry
in [
'int',
'bool',
'list',
'str',
'object',
'None',
'LogConfig',
'ModuleStatistics']:
117 nitpick_ignore.append((
'py:class', entry +
' :'))
135 exclude_patterns = [
'.*',
'_sphinxbuild',
'Thumbs.db',
'build',
'include',
'lib',
'bin',
'modules',
'data',
'site_scons']
137 if tags.has(
'light'):
138 light_packages = {entry.strip(
'/')
for entry
in open(
'../../.light').read().split()
if entry.endswith(
'/')}
139 for entry
in os.listdir(
"../../"):
140 if entry.find(
'.') > -1
or os.path.isfile(entry)
or entry
in exclude_patterns
or entry
in light_packages:
142 exclude_patterns.append(entry)
147 exclude_patterns.remove(
"build")
148 exclude_patterns += [
'build/html',
'build/latex',
'build/json',
'build/Linux*',
'build/belle2_tools']
150 exclude_patterns += [
'**/*.ipynb',
'*.ipynb']
168 pygments_style =
'sphinx'
177 todo_include_todos =
False
188 html_theme =
'sphinx_book_theme'
196 html_theme_path = [
"_themes", ]
207 html_logo =
"b2logo.svg"
217 html_static_path = [
'_sphinxstatic']
282 htmlhelp_basename =
'basf2doc'
288 'papersize':
'a4paper',
294 'preamble':
'\\setcounter{tocdepth}{2}',
304 (master_doc,
'basf2.tex',
'Belle II Software Documentation',
310 latex_logo =
"belle2-logo.pdf"
314 latex_use_parts =
True
315 latex_show_urls =
'footnote'
316 latex_show_pagerefs =
True
336 (master_doc,
'basf2',
'basf2 Documentation',
349 texinfo_documents = [
350 (master_doc,
'basf2',
'basf2 Documentation',
351 author,
'basf2',
'One line description of project.',
368 intersphinx_mapping = {
'python': (
'https://docs.python.org/3.8/',
None),
369 'numpy': (
'https://numpy.org/doc/stable/',
None),
370 'scipy': (
'https://docs.scipy.org/doc/scipy/',
None),
371 'pandas': (
'https://pandas.pydata.org/docs/',
None),
372 'matplotlib': (
'https://matplotlib.org/stable/',
None),
373 'uproot': (
'https://uproot.readthedocs.io/en/stable/',
None)}
376 def process_sig(app, what, name, obj, options, signature, return_annotation):
378 remove unhelpful 'self' arguments from methods.
380 if what ==
'method' and signature:
381 reg = re.compile(
'^\\( \\(.*\\)arg1')
382 signature = reg.sub(
'(', signature)
383 return (signature, return_annotation)
386 def improve_docstring(obj):
388 Enhances docstrings of PyROOT objects/classes.
390 >>> improve_docstring(Belle2.Variable.Manager)
394 >>> variables = ROOT.Belle2.Variable.Manager
395 >>> improve_docstring(variables)
399 classname = obj.__name__
401 except AttributeError:
402 classname = obj.__class__.__name__
403 pyclass = obj.__class__
405 if '::' not in classname:
407 pos = classname.find(
'Belle2::')
408 classname = classname[pos:]
409 if pyclass.__doc__
is None:
412 pyclass.__name__ =
'Belle2.' + classname
414 from ROOT
import TClass
415 tclass = TClass(classname)
419 doxygen_url =
'https://software.belle2.org/development/class'
420 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
421 doxygen_url +=
'.html'
422 pyclass.__doc__ += f
'\n`Doxygen page for {classname} <{doxygen_url}>`_'
425 members = tclass.GetListOfMethods()
426 if members.GetEntries() > 0:
427 pyclass.__doc__ +=
'\n\nMember functions:'
430 pyclass.__doc__ += f
'\n * {f.GetReturnTypeName()} {f.GetName()}{f.GetSignature()}'
433 pyclass.__doc__ += f
' ({title})'
435 members = tclass.GetListOfAllPublicDataMembers()
436 if members.GetEntries() > 0:
437 pyclass.__doc__ +=
'\n\nPublic data members'
439 pyclass.__doc__ += f
'\n * {f.GetName()}'
442 pyclass.__doc__ += f
' ({title})'
445 def skipmember(app, what, name, obj, skip, options):
447 This is executed before docstring processing,
448 so try improving them a bit.
451 improve_docstring(obj)
452 except AttributeError:
457 def process_docstring(app, what, name, obj, options, lines):
459 convert doxygen syntax to sphinx
462 re.compile(
r'^( *)@param (.*?):? '):
r':param \2: ',
463 re.compile(
r'^( *)@returns? '):
r':return: ',
468 for reg, sub
in substitutions.items():
469 new = reg.sub(sub, new)
479 Install some event handlers to improve output.
481 app.connect(
'autodoc-process-signature', process_sig)
482 app.connect(
'autodoc-process-docstring', process_docstring)
483 app.connect(
'autodoc-skip-member', skipmember)
484 app.add_css_file(
'css/custom.css')
490 from sphinx.ext
import autodoc
492 old_directive_header = autodoc.PropertyDocumenter.add_directive_header
496 def _fixed_directive_header(*args, **argk):
497 """Catch the ValueError and ignore it as done in https://github.com/sphinx-doc/sphinx/pull/9190"""
499 old_directive_header(*args, **argk)
505 autodoc.PropertyDocumenter.add_directive_header = _fixed_directive_header