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 'IPython.sphinxext.ipython_console_highlighting',
51 nbsphinx_allow_errors =
True
56 nbsphinx_custom_formats = {
57 '.doc.jupy.py':
lambda s: jupytext.reads(s,
'.py'),
64 autosectionlabel_prefix_document =
True
67 templates_path = [
'_sphinxtemplates']
72 source_suffix =
'.rst'
82 copyright =
'Belle II Collaboration'
83 author =
'Belle II Software Group'
90 version = subprocess.check_output([
"git",
"rev-parse",
"--short",
"HEAD"]).decode().strip()
92 basf2_repository =
"https://stash.desy.de/projects/B2/repos/basf2"
93 basf2_commitid = subprocess.check_output([
"git",
"rev-parse",
"HEAD"]).decode().strip()
94 basf2_jira =
"https://agira.desy.de"
97 release = os.environ.get(
'BELLE2_RELEASE',
'development')
99 release =
'development'
102 keep_warnings = release ==
"development"
103 nitpicky = keep_warnings
121 exclude_patterns = [
'.*',
'_sphinxbuild',
'Thumbs.db',
'build',
'include',
'lib',
'bin',
'modules',
'data',
'site_scons']
123 if tags.has(
'light'):
124 light_packages = set([entry.strip(
'/')
for entry
in open(
'../../.light').read().split()
if entry.endswith(
'/')])
125 for entry
in os.listdir(
"../../"):
126 if entry.find(
'.') > -1
or os.path.isfile(entry)
or entry
in exclude_patterns
or entry
in light_packages:
128 exclude_patterns.append(entry)
133 exclude_patterns.remove(
"build")
134 exclude_patterns += [
'build/html',
'build/latex',
'build/json',
'build/Linux*']
136 exclude_patterns += [
'**/*.ipynb',
'*.ipynb']
154 pygments_style =
'sphinx'
163 todo_include_todos =
False
174 html_theme =
'sphinx_rtd_theme'
182 html_theme_path = [
"_themes", ]
193 html_logo =
"b2logo.svg"
203 html_static_path = [
'_sphinxstatic']
268 htmlhelp_basename =
'basf2doc'
274 'papersize':
'a4paper',
280 'preamble':
'\\setcounter{tocdepth}{2}',
290 (master_doc,
'basf2.tex',
'Belle 2 Software Documentation',
296 latex_logo =
"belle2-logo.pdf"
300 latex_use_parts =
True
301 latex_show_urls =
'footnote'
302 latex_show_pagerefs =
True
322 (master_doc,
'basf2',
'basf2 Documentation',
335 texinfo_documents = [
336 (master_doc,
'basf2',
'basf2 Documentation',
337 author,
'basf2',
'One line description of project.',
354 intersphinx_mapping = {
'python': (
'https://docs.python.org/3.6',
None)}
357 def process_sig(app, what, name, obj, options, signature, return_annotation):
359 remove unhelpful 'self' arguments from methods.
361 if what ==
'method' and signature:
362 reg = re.compile(
'^\\( \\(.*\\)arg1')
363 signature = reg.sub(
'(', signature)
364 return (signature, return_annotation)
367 def improve_docstring(obj):
369 Enhances docstrings of PyROOT objects/classes.
371 >>> improve_docstring(Belle2.Variable.Manager)
375 >>> variables = ROOT.Belle2.Variable.Manager
376 >>> improve_docstring(variables)
380 classname = obj.__name__
382 except AttributeError:
383 classname = obj.__class__.__name__
384 pyclass = obj.__class__
386 if '::' not in classname:
388 pos = classname.find(
'Belle2::')
389 classname = classname[pos:]
390 if pyclass.__doc__
is None:
393 pyclass.__name__ =
'Belle2.' + classname
395 from ROOT
import TClass
396 tclass = TClass(classname)
400 doxygen_url =
'https://software.belle2.org/development/class'
401 doxygen_url +=
'_1_1'.join(classname.split(
'::'))
402 doxygen_url +=
'.html'
403 pyclass.__doc__ +=
'\n`Doxygen page for %s <%s>`_' % (classname, doxygen_url)
406 members = tclass.GetListOfMethods()
407 if members.GetEntries() > 0:
408 pyclass.__doc__ +=
'\n\nMember functions:'
411 pyclass.__doc__ +=
'\n * %s %s%s' % (f.GetReturnTypeName(), f.GetName(), f.GetSignature())
414 pyclass.__doc__ +=
' (%s)' % (title)
416 members = tclass.GetListOfAllPublicDataMembers()
417 if members.GetEntries() > 0:
418 pyclass.__doc__ +=
'\n\nPublic data members'
420 pyclass.__doc__ +=
'\n * %s' % (f.GetName())
423 pyclass.__doc__ +=
' (%s)' % (title)
426 def skipmember(app, what, name, obj, skip, options):
428 This is executed before docstring processing,
429 so try improving them a bit.
432 improve_docstring(obj)
433 except AttributeError:
438 def process_docstring(app, what, name, obj, options, lines):
440 convert doxygen syntax to sphinx
443 re.compile(
r'^( *)@param (.*?):? '):
r':param \2: ',
444 re.compile(
r'^( *)@returns? '):
r':return: ',
449 for reg, sub
in substitutions.items():
450 new = reg.sub(sub, new)
460 Install some event handlers to improve output.
462 app.connect(
'autodoc-process-signature', process_sig)
463 app.connect(
'autodoc-process-docstring', process_docstring)
464 app.connect(
'autodoc-skip-member', skipmember)
465 app.add_css_file(
'css/custom.css')
471 from sphinx.ext
import autodoc
473 old_directive_header = autodoc.PropertyDocumenter.add_directive_header
477 def _fixed_directive_header(*args, **argk):
478 """Catch the ValueError and ignore it as done in https://github.com/sphinx-doc/sphinx/pull/9190"""
480 old_directive_header(*args, **argk)
486 autodoc.PropertyDocumenter.add_directive_header = _fixed_directive_header