Skip to content

Commit 0481fa0

Browse files
authored
Add support for sphinx as a documentation generator (#595)
1 parent 71d5b1d commit 0481fa0

13 files changed

+333
-87
lines changed

api/docs/Doxyfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ WARN_LOGFILE =
790790
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
791791
# Note: If this tag is empty the current directory is searched.
792792

793-
INPUT = ./Overview.md \
794-
../include/opentelemetry/common \
793+
INPUT = ../include/opentelemetry/common \
795794
../include/opentelemetry/core \
796795
../include/opentelemetry/nostd/shared_ptr.h \
797796
../include/opentelemetry/nostd/span.h \
@@ -839,6 +838,8 @@ RECURSIVE = YES
839838
# run.
840839

841840
EXCLUDE = ../include/opentelemetry/common/spin_lock_mutex.h \
841+
../include/opentelemetry/common/key_value_iterable_view.h \
842+
../include/opentelemetry/trace/span_context_kv_iterable_view.h \
842843
../include/opentelemetry/nostd/detail
843844

844845
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
@@ -1088,7 +1089,7 @@ IGNORE_PREFIX =
10881089
# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
10891090
# The default value is: YES.
10901091

1091-
GENERATE_HTML = YES
1092+
GENERATE_HTML = NO
10921093

10931094
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
10941095
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1444,7 +1445,7 @@ DISABLE_INDEX = NO
14441445
# The default value is: NO.
14451446
# This tag requires that the tag GENERATE_HTML is set to YES.
14461447

1447-
GENERATE_TREEVIEW = NO
1448+
GENERATE_TREEVIEW = YES
14481449

14491450
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
14501451
# doxygen will group on one line in the generated HTML documentation.
@@ -1912,15 +1913,15 @@ MAN_LINKS = NO
19121913
# captures the structure of the code including all documentation.
19131914
# The default value is: NO.
19141915

1915-
GENERATE_XML = NO
1916+
GENERATE_XML = YES
19161917

19171918
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
19181919
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
19191920
# it.
19201921
# The default directory is: xml.
19211922
# This tag requires that the tag GENERATE_XML is set to YES.
19221923

1923-
XML_OUTPUT = xml
1924+
XML_OUTPUT = doxyoutput/xml
19241925

19251926
# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
19261927
# listings (including syntax highlighting and cross-referencing information) to

api/docs/Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile clean
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
mkdir -p doxyoutput
21+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22+
23+
clean:
24+
rm -rf doxyoutput
25+
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

api/docs/Overview.md

-79
This file was deleted.

api/docs/conf.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'OpenTelemetry C++ API'
21+
copyright = '2021, OpenTelemetry authors'
22+
author = 'OpenTelemetry authors'
23+
24+
# Run doxygen
25+
# -----------
26+
# For the readthedocs builds, for some reason exhale doesn't find doxygen.
27+
# So we run it manually here.
28+
import subprocess
29+
import os
30+
if not os.path.isdir('doxyoutput'):
31+
os.mkdir('doxyoutput')
32+
subprocess.call(['doxygen'])
33+
34+
35+
# -- General configuration ---------------------------------------------------
36+
37+
# Add any Sphinx extension module names here, as strings. They can be
38+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39+
# ones.
40+
extensions = [
41+
"breathe",
42+
"exhale",
43+
]
44+
45+
breathe_projects = {
46+
"OpenTelemetry C++ API": "./doxyoutput/xml"
47+
}
48+
49+
breathe_default_project = "OpenTelemetry C++ API"
50+
51+
exhale_args = {
52+
"containmentFolder": "otel_api",
53+
"rootFileName": "otel_api.rst",
54+
"rootFileTitle": "Reference documentation",
55+
"doxygenStripFromPath": "..",
56+
"exhaleUseDoxyfile": True,
57+
"createTreeView": True,
58+
}
59+
60+
primary_domain = "cpp"
61+
62+
higlight_language = "cpp"
63+
64+
65+
# Add any paths that contain templates here, relative to this directory.
66+
templates_path = ['_templates']
67+
68+
# List of patterns, relative to source directory, that match files and
69+
# directories to ignore when looking for source files.
70+
# This pattern also affects html_static_path and html_extra_path.
71+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
72+
73+
74+
# -- Options for HTML output -------------------------------------------------
75+
76+
# The theme to use for HTML and HTML Help pages. See the documentation for
77+
# a list of builtin themes.
78+
#
79+
html_theme = "sphinx_rtd_theme"
80+
81+
# Add any paths that contain custom static files (such as style sheets) here,
82+
# relative to this directory. They are copied after the builtin static files,
83+
# so a file named "default.css" will overwrite the builtin "default.css".
84+
html_static_path = ['_static']

api/docs/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OpenTelemetry C++ API
2+
=====================

buildscripts/pre-commit

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ END
7878
git add "$(pwd)/sdk/src/version/version.cc"
7979

8080
# Update documentation version
81-
sed -i "/^PROJECT_BRIEF/cPROJECT_BRIEF = \"Version ${short_version}\"" "$(pwd)/api/docs/Doxyfile"
82-
git add "$(pwd)/api/docs/Doxyfile"
81+
sed -i "/^release =/crelease = \"${short_version}\"" "$(pwd)/docs/public/conf.py"
82+
git add "$(pwd)/docs/public/conf.py"

docs/public/GettingHelp.rst

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Getting help
2+
------------
3+
4+
- Refer to `opentelemetry.io <https://opentelemetry.io/>`__ for general
5+
information about OpenTelemetry.
6+
- Refer to the `OpenTelemetry C++ GitHub
7+
repository <https://github.com/open-telemetry/opentelemetry-cpp>`__
8+
for further information and resources related to OpenTelemetry C++.
9+
- For questions related to OpenTelemetry C++ that are not covered by
10+
the existing documentation, please ask away in `GitHub
11+
discussions <https://github.com/open-telemetry/opentelemetry-cpp/discussions>`__.
12+
- Feel free to join the `CNCF OpenTelemetry C++ Slack
13+
channel <https://cloud-native.slack.com/archives/C01N3AT62SJ>`__. If
14+
you are new, you can create a CNCF Slack account
15+
`here <http://slack.cncf.io/>`__.
16+
- For bugs and feature requests, write a `GitHub
17+
issue <https://github.com/open-telemetry/opentelemetry-cpp/issues>`__.

docs/public/GettingStarted.rst

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Getting started
2+
---------------
3+
4+
Tracing
5+
~~~~~~~
6+
7+
When instrumenting libraries and applications, the most simple approach
8+
requires three steps.
9+
10+
Obtain a tracer
11+
^^^^^^^^^^^^^^^
12+
13+
.. code:: cpp
14+
15+
auto provider = opentelemetry::trace::Provider::GetTracerProvider();
16+
auto tracer = provider->GetTracer("foo_library", "1.0.0");
17+
18+
The ``TracerProvider`` acquired in the first step is a singleton object
19+
that is usually provided by the OpenTelemetry C++ SDK. It is used to
20+
provide specific implementations for API interfaces. In case no SDK is
21+
used, the API provides a default no-op implementation of a
22+
``TracerProvider``.
23+
24+
The ``Tracer`` acquired in the second step is needed to create and start
25+
``Span``\ s.
26+
27+
Start a span
28+
^^^^^^^^^^^^
29+
30+
.. code:: cpp
31+
32+
auto span = tracer->StartSpan("HandleRequest");
33+
34+
This creates a span, sets its name to ``"HandleRequest"``, and sets its
35+
start time to the current time. Refer to the API documentation for other
36+
operations that are available to enrich spans with additional data.
37+
38+
Mark a span as active
39+
^^^^^^^^^^^^^^^^^^^^^
40+
41+
.. code:: cpp
42+
43+
auto scope = tracer->WithActiveSpan(span);
44+
45+
This marks a span as active and returns a ``Scope`` object bound to the
46+
lifetime of the span. When the ``Scope`` object is destroyed, the
47+
related span is ended.
48+
49+
The concept of an active span is important, as any span that is created
50+
without explicitly specifying a parent is parented to the currently
51+
active span.
52+

docs/public/Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile clean
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
22+
clean:
23+
rm -rf doxyoutput
24+
@$(SPHINXBUILD) -M clean ../../api/docs "$(BUILDDIR)" $(SPHINXOPTS) $(O)
25+
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/public/Overview.rst

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Overview
2+
========
3+
4+
The OpenTelemetry C++ API enables developers to instrument their
5+
applications and libraries in order to make them ready to create and
6+
emit telemetry data. The OpenTelemetry C++ API exclusively focuses on
7+
instrumentation and does not address concerns like exporting, sampling,
8+
and aggregating telemetry data. Those concerns are addressed by the
9+
OpenTelemetry C++ SDK. This architecture enables developers to
10+
instrument applications and libraries with the OpenTelemetry C++ API
11+
while being completely agnostic of how telemetry data is exported and
12+
processed.
13+
14+
Library design
15+
--------------
16+
17+
The OpenTelemetry C++ API is provided as a header-only library and
18+
supports all recent versions of the C++ standard, down to C++11.
19+
20+
A single application might dynamically or statically link to different
21+
libraries that were compiled with different compilers, while several of
22+
the linked libraries are instrumented with OpenTelemetry. OpenTelemetry
23+
C++ supports those scenarios by providing a stable ABI. This is achieved
24+
by a careful API design, and most notably by providing ABI stable
25+
versions of classes from the standard library. All those classes are
26+
provided in the ``opentelemetry::nostd`` namespace.

0 commit comments

Comments
 (0)