Skip to content
Open
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
21 changes: 12 additions & 9 deletions collection_prep/cmd/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def update_deprecation_notice(documentation):

def update_documentation(bodypart):
"""
Update the docuementation of the module
Update the documentation of the module

:param bodypart: The DOCUMENTATION section of the module
"""
Expand All @@ -91,14 +91,17 @@ def update_documentation(bodypart):
update_deprecation_notice(documentation)

# remove version added
documentation.pop("version_added", None)
desc_idx = [
idx
for idx, key in enumerate(documentation.keys())
if key == "description"
]
# insert version_added after the description
documentation.insert(desc_idx[0] + 1, key="version_added", value="1.0.0")
version_added = documentation.pop("version_added", None)
if version_added is not None:
desc_idx = [
idx
for idx, key in enumerate(documentation.keys())
if key == "description"
]
# insert version_added after the description
documentation.insert(desc_idx[0] + 1, key="version_added", value=version_added)
else:
logging.warning("Field 'version_added' not found.")
repl = ruamel.yaml.dump(documentation, None, ruamel.yaml.RoundTripDumper)

# remove version added from anywhere else in the docstring if preceded by 1+ spaces
Expand Down