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',
44 'sphinx_togglebutton',
48 'sphinxcontrib.programoutput',
49 'IPython.sphinxext.ipython_console_highlighting',
54codeautolink_warn_on_missing_inventory =
False
55codeautolink_warn_on_failed_resolve =
False
57basf2_doxygen_xml_dir = f
"{os.environ.get('BELLE2_RELEASE_DIR', os.environ.get('BELLE2_LOCAL_DIR'))}/build/doxygen/xml"
59nbsphinx_allow_errors =
True
65autosectionlabel_prefix_document =
True
66suppress_warnings = [
'autosectionlabel.*',
'codeautolink.*']
69togglebutton_hint =
"Click to reveal"
73togglebutton_selector =
".toggle, .admonition.dropdown"
76togglebutton_hint_toggle =
"▶▼"
79templates_path = [
'_sphinxtemplates']
94copyright =
'Belle II Collaboration'
95author =
'Belle II Software Group'
102version = subprocess.check_output([
"git",
"rev-parse",
"--short",
"HEAD"]).decode().strip()
104basf2_repository =
"https://gitlab.desy.de/belle2/software/basf2/"
105basf2_commitid = subprocess.check_output([
"git",
"rev-parse",
"HEAD"]).decode().strip()
106basf2_issues =
"https://gitlab.desy.de/belle2/software/basf2/-/issues/"
109release = os.environ.get(
'BELLE2_RELEASE',
'development')
111 release =
'development'
114keep_warnings = release ==
"development"
115nitpicky = keep_warnings
119for entry
in [
'cppyy.gbl.TObject',
'cppyy.gbl.TFile',
'ROOT.TFile']:
120 nitpick_ignore.append((
'py:class', entry))
121for entry
in [
'int',
'bool',
'list',
'str',
'object',
'None',
'LogConfig',
'ProcessStatistics.ModuleStatistics']:
122 nitpick_ignore.append((
'py:class', entry +
' :'))
124basf2_doxygen_baseurl = f
"https://software.belle2.org/{release}/doxygen/"
142exclude_patterns = [
'.*',
'_sphinxbuild',
'Thumbs.db',
'build',
'include',
'lib',
'bin',
'modules',
'data',
'site_scons']
145 light_packages = {entry.strip(
'/')
for entry
in open(
'../../.light').read().split()
if entry.endswith(
'/')}
146 for entry
in os.listdir(
"../../"):
147 if entry.find(
'.') > -1
or os.path.isfile(entry)
or entry
in exclude_patterns
or entry
in light_packages:
149 exclude_patterns.append(entry)
154exclude_patterns.remove(
"build")
155exclude_patterns += [
'build/html',
'build/latex',
'build/json',
'build/Linux*',
'build/belle2_tools']
157exclude_patterns += [
'**/*.ipynb',
'*.ipynb']
175pygments_style =
'sphinx'
184todo_include_todos =
False
195html_theme =
'sphinx_book_theme'
203html_theme_path = [
"_themes", ]
214html_logo =
"b2logo.svg"
224html_static_path = [
'_sphinxstatic']
289htmlhelp_basename =
'basf2doc'
295 'papersize':
'a4paper',
301 'preamble':
'\\setcounter{tocdepth}{2}',
311 (master_doc,
'basf2.tex',
'Belle II Software Documentation',
317latex_logo =
"belle2-logo.pdf"
321latex_use_parts =
True
322latex_show_urls =
'footnote'
323latex_show_pagerefs =
True
343 (master_doc,
'basf2',
'basf2 Documentation',
357 (master_doc,
'basf2',
'basf2 Documentation',
358 author,
'basf2',
'One line description of project.',
375intersphinx_mapping = {
'python': (
'https://docs.python.org/3.11/',
None),
376 'numpy': (
'https://numpy.org/doc/stable/',
None),
377 'scipy': (
'https://docs.scipy.org/doc/scipy/',
None),
378 'pandas': (
'https://pandas.pydata.org/docs/',
None),
379 'matplotlib': (
'https://matplotlib.org/stable/',
None),
380 'b2luigi': (
'https://b2luigi.belle2.org/',
None),
381 'gbasf2': (
'https://gbasf2.belle2.org/',
None),
382 'uproot': (
'https://uproot.readthedocs.io/en/stable/',
None)}
385def process_sig(app, what, name, obj, options, signature, return_annotation):
387 remove unhelpful 'self' arguments from methods.
389 if what ==
'method' and signature:
390 reg = re.compile(
'^\\( \\(.*\\)arg1')
391 signature = reg.sub(
'(', signature)
392 return (signature, return_annotation)
395def improve_docstring(obj):
397 Enhances docstrings of PyROOT objects/classes.
399 >>> improve_docstring(Belle2.Variable.Manager)
403 >>> variables = ROOT.Belle2.Variable.Manager
404 >>> improve_docstring(variables)
408 classname = obj.__name__
410 except AttributeError:
411 classname = obj.__class__.__name__
412 pyclass = obj.__class__
414 if '::' not in classname:
416 pos = classname.find(
'Belle2::')
417 classname = classname[pos:]
418 if pyclass.__doc__
is None:
421 pyclass.__name__ =
'Belle2.' + classname
423 from ROOT
import TClass
424 tclass = TClass(classname)
428 doxygen_url = f
'{basf2_doxygen_baseurl}/class'
429 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
430 doxygen_url +=
'.html'
431 pyclass.__doc__ += f
'\n`Doxygen page for {classname} <{doxygen_url}>`_'
434 members = tclass.GetListOfMethods()
435 if members.GetEntries() > 0:
436 pyclass.__doc__ +=
'\n\nMember functions:'
439 pyclass.__doc__ += f
'\n * {f.GetReturnTypeName()} {f.GetName()}{f.GetSignature()}'
442 pyclass.__doc__ += f
' ({title})'
444 members = tclass.GetListOfAllPublicDataMembers()
445 if members.GetEntries() > 0:
446 pyclass.__doc__ +=
'\n\nPublic data members'
448 pyclass.__doc__ += f
'\n * {f.GetName()}'
451 pyclass.__doc__ += f
' ({title})'
454def skipmember(app, what, name, obj, skip, options):
456 This is executed before docstring processing,
457 so try improving them a bit.
460 improve_docstring(obj)
461 except AttributeError:
466def process_docstring(app, what, name, obj, options, lines):
468 convert doxygen syntax to sphinx
471 re.compile(
r'^( *)@param (.*?):? '):
r':param \2: ',
472 re.compile(
r'^( *)@returns? '):
r':return: ',
477 for reg, sub
in substitutions.items():
478 new = reg.sub(sub, new)
488 Install some event handlers to improve output.
490 app.connect(
'autodoc-process-signature', process_sig)
491 app.connect(
'autodoc-process-docstring', process_docstring)
492 app.connect(
'autodoc-skip-member', skipmember)
493 app.add_css_file(
'css/custom.css')