20sys.path.insert(0, os.path.abspath(
"extensions"))
36 'sphinx.ext.intersphinx',
40 'sphinx.ext.napoleon',
41 'sphinx.ext.viewcode',
42 'sphinx.ext.autosectionlabel',
43 'sphinx_codeautolink',
47 'sphinxcontrib.programoutput',
48 'IPython.sphinxext.ipython_console_highlighting',
53codeautolink_warn_on_missing_inventory =
False
54codeautolink_warn_on_failed_resolve =
False
56nbsphinx_allow_errors =
True
62autosectionlabel_prefix_document =
True
63suppress_warnings = [
'autosectionlabel.*',
'codeautolink.*']
66templates_path = [
'_sphinxtemplates']
81copyright =
'Belle II Collaboration'
82author =
'Belle II Software Group'
89version = subprocess.check_output([
"git",
"rev-parse",
"--short",
"HEAD"]).decode().strip()
91basf2_repository =
"https://gitlab.desy.de/belle2/software/basf2/"
92basf2_commitid = subprocess.check_output([
"git",
"rev-parse",
"HEAD"]).decode().strip()
93basf2_issues =
"https://gitlab.desy.de/belle2/software/basf2/-/issues/"
96release = os.environ.get(
'BELLE2_RELEASE',
'development')
98 release =
'development'
101keep_warnings = release ==
"development"
102nitpicky = keep_warnings
106for entry
in [
'cppyy.gbl.TObject',
'cppyy.gbl.TFile',
'ROOT.TFile']:
107 nitpick_ignore.append((
'py:class', entry))
108for entry
in [
'int',
'bool',
'list',
'str',
'object',
'None',
'LogConfig',
'ModuleStatistics']:
109 nitpick_ignore.append((
'py:class', entry +
' :'))
127exclude_patterns = [
'.*',
'_sphinxbuild',
'Thumbs.db',
'build',
'include',
'lib',
'bin',
'modules',
'data',
'site_scons']
130 light_packages = {entry.strip(
'/')
for entry
in open(
'../../.light').read().split()
if entry.endswith(
'/')}
131 for entry
in os.listdir(
"../../"):
132 if entry.find(
'.') > -1
or os.path.isfile(entry)
or entry
in exclude_patterns
or entry
in light_packages:
134 exclude_patterns.append(entry)
139exclude_patterns.remove(
"build")
140exclude_patterns += [
'build/html',
'build/latex',
'build/json',
'build/Linux*',
'build/belle2_tools']
142exclude_patterns += [
'**/*.ipynb',
'*.ipynb']
160pygments_style =
'sphinx'
169todo_include_todos =
False
180html_theme =
'sphinx_book_theme'
188html_theme_path = [
"_themes", ]
199html_logo =
"b2logo.svg"
209html_static_path = [
'_sphinxstatic']
274htmlhelp_basename =
'basf2doc'
280 'papersize':
'a4paper',
286 'preamble':
'\\setcounter{tocdepth}{2}',
296 (master_doc,
'basf2.tex',
'Belle II Software Documentation',
302latex_logo =
"belle2-logo.pdf"
306latex_use_parts =
True
307latex_show_urls =
'footnote'
308latex_show_pagerefs =
True
328 (master_doc,
'basf2',
'basf2 Documentation',
342 (master_doc,
'basf2',
'basf2 Documentation',
343 author,
'basf2',
'One line description of project.',
360intersphinx_mapping = {
'python': (
'https://docs.python.org/3.11/',
None),
361 'numpy': (
'https://numpy.org/doc/stable/',
None),
362 'scipy': (
'https://docs.scipy.org/doc/scipy/',
None),
363 'pandas': (
'https://pandas.pydata.org/docs/',
None),
364 'matplotlib': (
'https://matplotlib.org/stable/',
None),
365 'b2luigi': (
'https://b2luigi.belle2.org/',
None),
366 'gbasf2': (
'https://gbasf2.belle2.org/',
None),
367 'uproot': (
'https://uproot.readthedocs.io/en/stable/',
None)}
370def process_sig(app, what, name, obj, options, signature, return_annotation):
372 remove unhelpful 'self' arguments
from methods.
374 if what ==
'method' and signature:
375 reg = re.compile(
'^\\( \\(.*\\)arg1')
376 signature = reg.sub(
'(', signature)
377 return (signature, return_annotation)
380def improve_docstring(obj):
382 Enhances docstrings of PyROOT objects/classes.
388 >>> variables = ROOT.Belle2.Variable.Manager
389 >>> improve_docstring(variables)
393 classname = obj.__name__
395 except AttributeError:
396 classname = obj.__class__.__name__
397 pyclass = obj.__class__
399 if '::' not in classname:
401 pos = classname.find(
'Belle2::')
402 classname = classname[pos:]
403 if pyclass.__doc__
is None:
406 pyclass.__name__ =
'Belle2.' + classname
408 from ROOT
import TClass
409 tclass = TClass(classname)
413 doxygen_url =
'https://software.belle2.org/development/doxygen/class'
414 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
415 doxygen_url +=
'.html'
416 pyclass.__doc__ += f
'\n`Doxygen page for {classname} <{doxygen_url}>`_'
419 members = tclass.GetListOfMethods()
420 if members.GetEntries() > 0:
421 pyclass.__doc__ +=
'\n\nMember functions:'
424 pyclass.__doc__ += f
'\n * {f.GetReturnTypeName()} {f.GetName()}{f.GetSignature()}'
427 pyclass.__doc__ += f
' ({title})'
429 members = tclass.GetListOfAllPublicDataMembers()
430 if members.GetEntries() > 0:
431 pyclass.__doc__ +=
'\n\nPublic data members'
433 pyclass.__doc__ += f
'\n * {f.GetName()}'
436 pyclass.__doc__ += f
' ({title})'
439def skipmember(app, what, name, obj, skip, options):
441 This is executed before docstring processing,
442 so
try improving them a bit.
445 improve_docstring(obj)
446 except AttributeError:
451def process_docstring(app, what, name, obj, options, lines):
453 convert doxygen syntax to sphinx
456 re.compile(r'^( *)@param (.*?):? '):
r':param \2: ',
457 re.compile(
r'^( *)@returns? '):
r':return: ',
462 for reg, sub
in substitutions.items():
463 new = reg.sub(sub, new)
473 Install some event handlers to improve output.
475 app.connect('autodoc-process-signature', process_sig)
476 app.connect(
'autodoc-process-docstring', process_docstring)
477 app.connect(
'autodoc-skip-member', skipmember)
478 app.add_css_file(
'css/custom.css')
Global list of available variables.