mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Fixup TOC script sluggification and documentation
This commit is contained in:
@@ -26,7 +26,7 @@ from scriptCommon import catchPath
|
||||
minTocEntries = 4
|
||||
|
||||
headingExcludeDefault = [1,3,4,5] # use level 2 headers for at default
|
||||
headingExcludeRelease = [2,3,4,5] # use level 1 headers for release-notes.md
|
||||
headingExcludeRelease = [1,3,4,5] # use level 1 headers for release-notes.md
|
||||
|
||||
documentsDefault = os.path.join(os.path.relpath(catchPath), 'docs/*.md')
|
||||
releaseNotesName = 'release-notes.md'
|
||||
@@ -91,18 +91,20 @@ def dashifyHeadline(line):
|
||||
level = len(stripped_right) - len(stripped_both)
|
||||
stripped_wspace = stripped_both.strip()
|
||||
|
||||
# character replacements
|
||||
replaced_colon = stripped_wspace.replace('.', '')
|
||||
replaced_slash = replaced_colon.replace('/', '')
|
||||
rem_nonvalids = ''.join([c if c in VALIDS
|
||||
else '-' for c in replaced_slash])
|
||||
# GitHub's sluggification works in an interesting way
|
||||
# 1) '+', '/', '(', ')' and so on are just removed
|
||||
# 2) spaces are converted into '-' directly
|
||||
# 3) multiple -- are not collapsed
|
||||
|
||||
lowered = rem_nonvalids.lower()
|
||||
dashified = re.sub(r'(-)\1+', r'\1', lowered) # remove duplicate dashes
|
||||
dashified = dashified.strip('-') # strip dashes from start and end
|
||||
|
||||
# exception '&' (double-dash in github)
|
||||
dashified = dashified.replace('-&-', '--')
|
||||
dashified = ''
|
||||
for c in stripped_wspace:
|
||||
if c in VALIDS:
|
||||
dashified += c.lower()
|
||||
elif c.isspace():
|
||||
dashified += '-'
|
||||
else:
|
||||
# Unknown symbols are just removed
|
||||
continue
|
||||
|
||||
return [stripped_wspace, dashified, level]
|
||||
|
||||
|
Reference in New Issue
Block a user