Skip to content

Commit 9d90db4

Browse files
chimchim89xrmx
andauthored
Fix duplicate docstring attributes caused by napoleon and autodoc (open-telemetry#4920)
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent 915356e commit 9d90db4

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@
202202
"exclude-members": ",".join(_exclude_members),
203203
}
204204

205+
# Napoleon configuration to avoid duplication with autodoc for dataclass fields
206+
# Use ivar (instance variable) style for documenting attributes
207+
napoleon_use_ivar = True
208+
205209
# -- Options for HTML output -------------------------------------------------
206210

207211
# The theme to use for HTML and HTML Help pages. See the documentation for

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exemplar/exemplar.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Exemplar:
2626
was recorded, for example the span and trace ID of the active span when the
2727
exemplar was recorded.
2828
29-
Attributes
29+
Attributes:
3030
trace_id: (optional) The trace associated with a recording
3131
span_id: (optional) The span associated with a recording
3232
time_unix_nano: The time of the observation
@@ -38,11 +38,6 @@ class Exemplar:
3838
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar
3939
"""
4040

41-
# TODO Fix doc - if using valid Google `Attributes:` key, the attributes are duplicated
42-
# one will come from napoleon extension and the other from autodoc extension. This
43-
# will raise an sphinx error of duplicated object description
44-
# See https://github.com/sphinx-doc/sphinx/issues/8664
45-
4641
filtered_attributes: Attributes
4742
value: Union[int, float]
4843
time_unix_nano: int

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,14 @@ class Measurement:
2525
"""
2626
Represents a data point reported via the metrics API to the SDK.
2727
28-
Attributes
28+
Attributes:
2929
value: Measured value
3030
time_unix_nano: The time the API call was made to record the Measurement
3131
instrument: The instrument that produced this `Measurement`.
3232
context: The active Context of the Measurement at API call time.
3333
attributes: Measurement attributes
3434
"""
3535

36-
# TODO Fix doc - if using valid Google `Attributes:` key, the attributes are duplicated
37-
# one will come from napoleon extension and the other from autodoc extension. This
38-
# will raise an sphinx error of duplicated object description
39-
# See https://github.com/sphinx-doc/sphinx/issues/8664
40-
4136
value: Union[int, float]
4237
time_unix_nano: int
4338
instrument: Instrument

0 commit comments

Comments
 (0)