conf.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 
3 import os, sys, time
4 from os.path import abspath, dirname, join
5 
6 from docutils import nodes
7 from sphinx.ext import intersphinx
8 
9 import catkin_pkg.package
10 
11 catkin_dir = dirname(dirname(abspath(__file__)))
12 catkin_package = catkin_pkg.package.parse_package(join(catkin_dir, catkin_pkg.package.PACKAGE_MANIFEST_FILENAME))
13 
14 project = catkin_package.name
15 copyright = time.strftime("%Y") + ', Czech Technical University in Prague'
16 author = ", ".join([a.name for a in catkin_package.authors])
17 version = catkin_package.version
18 release = catkin_package.version
19 
20 import catkin_sphinx
21 html_theme_path = [catkin_sphinx.get_theme_path()]
22 
23 # Use ROS theme
24 html_theme = 'ros-theme'
25 
26 # Add any Sphinx extension module names here, as strings. They can be extensions
27 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
28 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.extlinks',
29  'sphinx.ext.viewcode']
30 
31 # Add any paths that contain templates here, relative to this directory.
32 templates_path = ['_templates']
33 
34 # The suffix of source filenames.
35 source_suffix = '.rst'
36 
37 # The master toctree document.
38 master_doc = 'index'
39 
40 # Resolve ROS message and service dependencies
41 ros_distro = os.getenv('ROS_DISTRO', 'latest')
42 ros_api_base = 'https://docs.ros.org/en/%s/api/'
43 ros_api = ros_api_base % ros_distro
44 
45 # Example configuration for intersphinx: refer to the Python standard library.
46 python_version = '{}.{}'.format(sys.version_info.major, sys.version_info.minor)
47 intersphinx_mapping = {
48  'python': ('https://docs.python.org/{}/'.format(python_version), None),
49  'genpy': (ros_api + 'genpy/html', None),
50 }
51 
52 extlinks = {
53  'diagnostic_msgs': (ros_api + 'diagnostic_msgs/html/msg/%s.html', 'diagnostic_msgs/'),
54 }
55 
56 # Produce both class and constructor doc comments
57 autoclass_content = 'both'
58 
59 
60 def ros_msg_reference(app, env, node, contnode):
61  text_node = next(iter(contnode.traverse(lambda n: n.tagname == '#text')))
62  parts = text_node.astext().split('.')
63  # diagnostic_msgs.msg.DiagnosticStatus
64  if len(parts) == 3:
65  pkg, obj_type, obj = parts
66  # diagnostic_msgs.msg._DiagnosticStatus.DiagnosticStatus
67  elif len(parts) == 4:
68  pkg, obj_type, module, obj = parts
69  if "_" + obj != module:
70  return intersphinx.missing_reference(app, env, node, contnode)
71  else:
72  return intersphinx.missing_reference(app, env, node, contnode)
73  if obj_type not in ("msg", "srv"):
74  return intersphinx.missing_reference(app, env, node, contnode)
75  target = ros_api + '{}/html/{}/{}.html'.format(pkg, obj_type, obj)
76  ref_node = nodes.reference()
77  ref_node['refuri'] = target
78  title = '{}/{}'.format(pkg, obj)
79  text_node = nodes.literal(title, title)
80  text_node['classes'] = ['xref', 'ros', 'ros-' + obj_type]
81  ref_node += text_node
82  return ref_node
83 
84 
85 # Backport of fix for issue https://github.com/sphinx-doc/sphinx/issues/2549. Without it, :ivar: fields wrongly resolve cross-references.
86 from sphinx.domains.python import PyObject
87 PyObject.doc_field_types[list(map(lambda f: f.name == 'variable', PyObject.doc_field_types)).index(True)].rolename = None
88 
89 
90 def setup(app):
91  app.connect("missing-reference", ros_msg_reference)
92 
conf.ros_msg_reference
def ros_msg_reference(app, env, node, contnode)
Definition: conf.py:60
conf.setup
def setup(app)
Definition: conf.py:90


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Tue May 6 2025 02:17:37