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 'uproot': (
'https://uproot.readthedocs.io/en/stable/',
None)}
368def process_sig(app, what, name, obj, options, signature, return_annotation):
370 remove unhelpful 'self' arguments
from methods.
372 if what ==
'method' and signature:
373 reg = re.compile(
'^\\( \\(.*\\)arg1')
374 signature = reg.sub(
'(', signature)
375 return (signature, return_annotation)
378def improve_docstring(obj):
380 Enhances docstrings of PyROOT objects/classes.
386 >>> variables = ROOT.Belle2.Variable.Manager
387 >>> improve_docstring(variables)
391 classname = obj.__name__
393 except AttributeError:
394 classname = obj.__class__.__name__
395 pyclass = obj.__class__
397 if '::' not in classname:
399 pos = classname.find(
'Belle2::')
400 classname = classname[pos:]
401 if pyclass.__doc__
is None:
404 pyclass.__name__ =
'Belle2.' + classname
406 from ROOT
import TClass
407 tclass = TClass(classname)
411 doxygen_url =
'https://software.belle2.org/development/class'
412 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
413 doxygen_url +=
'.html'
414 pyclass.__doc__ += f
'\n`Doxygen page for {classname} <{doxygen_url}>`_'
417 members = tclass.GetListOfMethods()
418 if members.GetEntries() > 0:
419 pyclass.__doc__ +=
'\n\nMember functions:'
422 pyclass.__doc__ += f
'\n * {f.GetReturnTypeName()} {f.GetName()}{f.GetSignature()}'
425 pyclass.__doc__ += f
' ({title})'
427 members = tclass.GetListOfAllPublicDataMembers()
428 if members.GetEntries() > 0:
429 pyclass.__doc__ +=
'\n\nPublic data members'
431 pyclass.__doc__ += f
'\n * {f.GetName()}'
434 pyclass.__doc__ += f
' ({title})'
437def skipmember(app, what, name, obj, skip, options):
439 This is executed before docstring processing,
440 so
try improving them a bit.
443 improve_docstring(obj)
444 except AttributeError:
449def process_docstring(app, what, name, obj, options, lines):
451 convert doxygen syntax to sphinx
454 re.compile(r'^( *)@param (.*?):? '):
r':param \2: ',
455 re.compile(
r'^( *)@returns? '):
r':return: ',
460 for reg, sub
in substitutions.items():
461 new = reg.sub(sub, new)
471 Install some event handlers to improve output.
473 app.connect('autodoc-process-signature', process_sig)
474 app.connect(
'autodoc-process-docstring', process_docstring)
475 app.connect(
'autodoc-skip-member', skipmember)
476 app.add_css_file(
'css/custom.css')
482from sphinx.ext
import autodoc
484old_directive_header = autodoc.PropertyDocumenter.add_directive_header
488def _fixed_directive_header(*args, **argk):
489 """Catch the ValueError and ignore it as done in https://github.com/sphinx-doc/sphinx/pull/9190"""
491 old_directive_header(*args, **argk)
497autodoc.PropertyDocumenter.add_directive_header = _fixed_directive_header
Global list of available variables.