Skip to content

Commit c7ecb48

Browse files
authored
Display the optional steps in the Pipelines autodoc #1822 (#1830)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 1695f17 commit c7ecb48

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ v35.4.0 (unreleased)
1414
- Resolve and load dependencies from SPDX SBOMs.
1515
https://github.com/aboutcode-org/scancode.io/issues/1145
1616

17+
- Display the optional steps in the Pipelines autodoc.
18+
https://github.com/aboutcode-org/scancode.io/issues/1822
19+
1720
v35.3.0 (2025-08-20)
1821
--------------------
1922

docs/conf.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,23 @@
8181

8282
# user starts in light mode (Default Mode)
8383
default_dark_mode = False
84+
85+
86+
# Display the optional steps in the Pipelines autodoc.
87+
def autodoc_process_docstring(app, what, name, obj, options, lines):
88+
"""
89+
Sphinx autodoc extension hook to insert `@optional_step` groups
90+
into the generated documentation.
91+
92+
If a function or method has been decorated with ``@optional_step``,
93+
the decorator attaches a ``.groups`` attribute to the object.
94+
This hook inspects that attribute during autodoc processing and prepends
95+
a short note at the top of the function’s docstring.
96+
"""
97+
if hasattr(obj, "groups"):
98+
groups_str = " ".join(f":guilabel:`{group}`" for group in sorted(obj.groups))
99+
lines[:0] = [f"**Optional step:** {groups_str}", ""]
100+
101+
102+
def setup(app):
103+
app.connect("autodoc-process-docstring", autodoc_process_docstring)

0 commit comments

Comments
 (0)