Skip to content

gh-108514: Add config & transform to hide old versionmodified in docs #108522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
# Minimum version of sphinx required
needs_sphinx = '3.2'

# Hide versionadded and versionchanged in the output older than this version
min_version_show_changes = '3.6'

# Ignore any .rst files in the includes/ directory;
# they're embedded in pages but not rendered individually.
# Ignore any .rst files in the venv/ directory.
Expand Down
15 changes: 15 additions & 0 deletions Doc/tools/extensions/pyspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,21 @@ def patch_pairindextypes(app, _env) -> None:
pairindextypes.clear()


def hide_old_versionmodified(app, doctree, fromdocname):
"""Remove versionmodified nodes (added/changed) older than the minimum."""
min_version = app.config.min_version_show_changes
if not min_version:
return
min_version = [int(part) for part in min_version.split(".")]
for node in list(doctree.findall(addnodes.versionmodified)):
if node['type'] in ('versionadded', 'versionchanged'):
node_version = [int(part) for part in node['version'].split(".")]
if node_version < min_version:
node.parent.remove(node)


def setup(app):
app.add_config_value('min_version_show_changes', '', 'html')
app.add_role('issue', issue_role)
app.add_role('gh', gh_issue_role)
app.add_role('source', source_role)
Expand All @@ -717,6 +731,7 @@ def setup(app):
app.add_directive('miscnews', MiscNews)
app.connect('env-check-consistency', patch_pairindextypes)
app.connect('doctree-resolved', process_audit_events)
app.connect('doctree-resolved', hide_old_versionmodified)
app.connect('env-merge-info', audit_events_merge)
app.connect('env-purge-doc', audit_events_purge)
return {'version': '1.0', 'parallel_read_safe': True}