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 'uproot': (
'https://uproot.readthedocs.io/en/stable/',
None)}
369def process_sig(app, what, name, obj, options, signature, return_annotation):
371 remove unhelpful 'self' arguments
from methods.
373 if what ==
'method' and signature:
374 reg = re.compile(
'^\\( \\(.*\\)arg1')
375 signature = reg.sub(
'(', signature)
376 return (signature, return_annotation)
379def improve_docstring(obj):
381 Enhances docstrings of PyROOT objects/classes.
387 >>> variables = ROOT.Belle2.Variable.Manager
388 >>> improve_docstring(variables)
392 classname = obj.__name__
394 except AttributeError:
395 classname = obj.__class__.__name__
396 pyclass = obj.__class__
398 if '::' not in classname:
400 pos = classname.find(
'Belle2::')
401 classname = classname[pos:]
402 if pyclass.__doc__
is None:
405 pyclass.__name__ =
'Belle2.' + classname
407 from ROOT
import TClass
408 tclass = TClass(classname)
412 doxygen_url =
'https://software.belle2.org/development/class'
413 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
414 doxygen_url +=
'.html'
415 pyclass.__doc__ += f
'\n`Doxygen page for {classname} <{doxygen_url}>`_'
418 members = tclass.GetListOfMethods()
419 if members.GetEntries() > 0:
420 pyclass.__doc__ +=
'\n\nMember functions:'
423 pyclass.__doc__ += f
'\n * {f.GetReturnTypeName()} {f.GetName()}{f.GetSignature()}'
426 pyclass.__doc__ += f
' ({title})'
428 members = tclass.GetListOfAllPublicDataMembers()
429 if members.GetEntries() > 0:
430 pyclass.__doc__ +=
'\n\nPublic data members'
432 pyclass.__doc__ += f
'\n * {f.GetName()}'
435 pyclass.__doc__ += f
' ({title})'
438def skipmember(app, what, name, obj, skip, options):
440 This is executed before docstring processing,
441 so
try improving them a bit.
444 improve_docstring(obj)
445 except AttributeError:
450def process_docstring(app, what, name, obj, options, lines):
452 convert doxygen syntax to sphinx
455 re.compile(r'^( *)@param (.*?):? '):
r':param \2: ',
456 re.compile(
r'^( *)@returns? '):
r':return: ',
461 for reg, sub
in substitutions.items():
462 new = reg.sub(sub, new)
472 Install some event handlers to improve output.
474 app.connect('autodoc-process-signature', process_sig)
475 app.connect(
'autodoc-process-docstring', process_docstring)
476 app.connect(
'autodoc-skip-member', skipmember)
477 app.add_css_file(
'css/custom.css')
Global list of available variables.