MCPcopy Create free account
hub / github.com/Kitware/VTK / create_release_index

Function create_release_index

Documentation/docs/vtk_documentation.py:298–370  ·  view source on GitHub ↗

Populate basedir with release files X.Y.md with X,Y being the major and minor versions respectively. it returns a string holding the toctree of the index file to be injected in basedir/index.md

(basedir)

Source from the content-addressed store, hash-verified

296
297
298def create_release_index(basedir):
299 """Populate basedir with release files X.Y.md with X,Y being the major and minor versions respectively.
300 it returns a string holding the toctree of the index file to be injected in basedir/index.md
301 """
302 # get x.y.0 releases skipping rc's
303 command = r"git tag --sort=version:refname --format '%(refname:strip=2) %(creatordate:format:%Y-%m-%d)' | grep -v 'rc' | grep 'v[0-9]*\.[0-9]*\.0'"
304 result = subprocess.run(command, shell=True, capture_output=True, text=True)
305 tags = str(result.stdout).split("\n")[:-1] # drop last empty line
306 tags = tags[4:] # skip release for which we do not have release notes
307 files = []
308 for entry in tags:
309 tag, date = entry.split(" ")
310 short_tag = tag[1:] # strip 'v'
311 short_tag = short_tag.rsplit(".", 1)[0] # drop last '.0'
312 if tag in HISTORICAL_RELEASE_URLS:
313 content = CONTENT_TEMPLATE.format(
314 version=short_tag, url=HISTORICAL_RELEASE_URLS[tag], date=date
315 )
316 files.append(f"{short_tag}.md")
317 create_release_file(
318 path=os.path.join(basedir, f"{short_tag}.md"), content=content
319 )
320 else: # look for release note markdown
321 release_file_path = f"../release/{short_tag}.md"
322 if os.path.exists(release_file_path):
323 stripped_release_path = os.path.join("../release", f"_{short_tag}-stripped.md")
324 write_stripped_release_file(release_file_path, stripped_release_path)
325 with open(stripped_release_path, "r") as release_file:
326 release_file_content = release_file.read()
327 author_notes = []
328 short_tag_dir = f"../release/{short_tag}"
329 if os.path.exists(short_tag_dir):
330 for (dirpath, dirname, filenames) in os.walk(short_tag_dir):
331 dest_short_tag_dir = f"{basedir}/{short_tag}/"
332 if not os.path.exists(dest_short_tag_dir):
333 os.makedirs(dest_short_tag_dir)
334 for fn in filenames:
335 # Copy the note file if is referenced from included "{short_tag}.md"
336 full_fn = f"{short_tag}/{fn}"
337 if full_fn in release_file_content:
338 src = os.path.join("../release", full_fn)
339 dst = os.path.join(dest_short_tag_dir, fn)
340 shutil.copy(src, dst)
341 author_notes.append(full_fn.removesuffix(".md"))
342 with open(src, "r") as note_file:
343 note_content = note_file.read()
344 for img_version, img_file in extract_image_links(note_content):
345 src_img = os.path.join("../release/imgs", img_version, img_file)
346 dst_img_dir = os.path.join("release_details/imgs", img_version)
347 os.makedirs(dst_img_dir, exist_ok=True)
348 shutil.copy(src_img, os.path.join(dst_img_dir, img_file))
349 else:
350 print(f"Warning: '{short_tag}/{fn}' is not referenced from '{release_file_path}'")
351 content = CONTENT_TEMPLATE2.format(version=short_tag, date=date, author_notes="\n".join(sorted(author_notes)).strip())
352 create_release_file(
353 path=os.path.join(basedir, f"{short_tag}.md"), content=content
354 )
355 files.append(f"{short_tag}.md")

Callers

nothing calls this directly

Calls 12

strFunction · 0.85
create_release_fileFunction · 0.85
extract_image_linksFunction · 0.85
existsMethod · 0.80
printFunction · 0.50
runMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
readMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected