22 sys.path.insert(0, os.path.abspath(
"extensions"))
38 'sphinx.ext.intersphinx',
42 'sphinx.ext.napoleon',
43 'sphinx.ext.viewcode',
44 'sphinx.ext.autosectionlabel',
48 'sphinxcontrib.programoutput',
49 'IPython.sphinxext.ipython_console_highlighting',
52 nbsphinx_allow_errors =
True
57 nbsphinx_custom_formats = {
58 '.doc.jupy.py':
lambda s: jupytext.reads(s,
'.py'),
65 autosectionlabel_prefix_document =
True
66 suppress_warnings = [
'autosectionlabel.*']
69 templates_path = [
'_sphinxtemplates']
74 source_suffix =
'.rst'
84 copyright =
'Belle II Collaboration'
85 author =
'Belle II Software Group'
92 version = subprocess.check_output([
"git",
"rev-parse",
"--short",
"HEAD"]).decode().strip()
94 basf2_repository =
"https://stash.desy.de/projects/B2/repos/basf2"
95 basf2_commitid = subprocess.check_output([
"git",
"rev-parse",
"HEAD"]).decode().strip()
96 basf2_jira =
"https://agira.desy.de"
99 release = os.environ.get(
'BELLE2_RELEASE',
'development')
100 if release ==
'head':
101 release =
'development'
104 keep_warnings = release ==
"development"
105 nitpicky = keep_warnings
109 for entry
in [
'cppyy.gbl.TObject',
'cppyy.gbl.TFile',
'ROOT.TFile']:
110 nitpick_ignore.append((
'py:class', entry))
111 for entry
in [
'int',
'bool',
'list',
'str',
'object',
'None',
'LogConfig',
'ModuleStatistics']:
112 nitpick_ignore.append((
'py:class', entry +
' :'))
130 exclude_patterns = [
'.*',
'_sphinxbuild',
'Thumbs.db',
'build',
'include',
'lib',
'bin',
'modules',
'data',
'site_scons']
132 if tags.has(
'light'):
133 light_packages = set([entry.strip(
'/')
for entry
in open(
'../../.light').read().split()
if entry.endswith(
'/')])
134 for entry
in os.listdir(
"../../"):
135 if entry.find(
'.') > -1
or os.path.isfile(entry)
or entry
in exclude_patterns
or entry
in light_packages:
137 exclude_patterns.append(entry)
142 exclude_patterns.remove(
"build")
143 exclude_patterns += [
'build/html',
'build/latex',
'build/json',
'build/Linux*',
'build/belle2_tools']
145 exclude_patterns += [
'**/*.ipynb',
'*.ipynb']
163 pygments_style =
'sphinx'
172 todo_include_todos =
False
183 html_theme =
'sphinx_book_theme'
191 html_theme_path = [
"_themes", ]
202 html_logo =
"b2logo.svg"
212 html_static_path = [
'_sphinxstatic']
277 htmlhelp_basename =
'basf2doc'
283 'papersize':
'a4paper',
289 'preamble':
'\\setcounter{tocdepth}{2}',
299 (master_doc,
'basf2.tex',
'Belle 2 Software Documentation',
305 latex_logo =
"belle2-logo.pdf"
309 latex_use_parts =
True
310 latex_show_urls =
'footnote'
311 latex_show_pagerefs =
True
331 (master_doc,
'basf2',
'basf2 Documentation',
344 texinfo_documents = [
345 (master_doc,
'basf2',
'basf2 Documentation',
346 author,
'basf2',
'One line description of project.',
363 intersphinx_mapping = {
'python': (
'https://docs.python.org/3.8/',
None),
364 'numpy': (
'https://numpy.org/doc/stable/',
None),
365 'scipy': (
'https://docs.scipy.org/doc/scipy/',
None),
366 'pandas': (
'https://pandas.pydata.org/docs/',
None),
367 'matplotlib': (
'https://matplotlib.org/stable/',
None)}
370 def 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)
380 def improve_docstring(obj):
382 Enhances docstrings of PyROOT objects/classes.
384 >>> improve_docstring(Belle2.Variable.Manager)
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/class'
414 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
415 doxygen_url +=
'.html'
416 pyclass.__doc__ +=
'\n`Doxygen page for %s <%s>`_' % (classname, doxygen_url)
419 members = tclass.GetListOfMethods()
420 if members.GetEntries() > 0:
421 pyclass.__doc__ +=
'\n\nMember functions:'
424 pyclass.__doc__ +=
'\n * %s %s%s' % (f.GetReturnTypeName(), f.GetName(), f.GetSignature())
427 pyclass.__doc__ +=
' (%s)' % (title)
429 members = tclass.GetListOfAllPublicDataMembers()
430 if members.GetEntries() > 0:
431 pyclass.__doc__ +=
'\n\nPublic data members'
433 pyclass.__doc__ +=
'\n * %s' % (f.GetName())
436 pyclass.__doc__ +=
' (%s)' % (title)
439 def 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:
451 def 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')
484 from sphinx.ext
import autodoc
486 old_directive_header = autodoc.PropertyDocumenter.add_directive_header
490 def _fixed_directive_header(*args, **argk):
491 """Catch the ValueError and ignore it as done in https://github.com/sphinx-doc/sphinx/pull/9190"""
493 old_directive_header(*args, **argk)
499 autodoc.PropertyDocumenter.add_directive_header = _fixed_directive_header