Add navigation consistency checking script

This commit is contained in:
Score_Under 2021-04-07 19:11:56 +01:00
parent 9981efc9d1
commit d8e6925f31
No known key found for this signature in database
GPG Key ID: A99742B6A92A14E8
17 changed files with 89 additions and 0 deletions

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Biochemical Dysphoria" title: "How Gender Dysphoria Manifests: Biochemical Dysphoria"
linkTitle: "Biochemical Dysphoria"
description: "The very real and biological factors of Gender Dysphoria that cause mental disturbance." description: "The very real and biological factors of Gender Dysphoria that cause mental disturbance."
preBody: '_disclaimer' preBody: '_disclaimer'
classes: classes:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "What is the Cause of Gender Incongruence" title: "What is the Cause of Gender Incongruence"
linkTitle: "Causes of Gender Dysphoria"
description: "It's the hormones, baby." description: "It's the hormones, baby."
preBody: '_disclaimer' preBody: '_disclaimer'
classes: classes:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "Disorders of Sex Development: Gender is not Chromosomal" title: "Disorders of Sex Development: Gender is not Chromosomal"
linkTitle: "Chromosomes"
description: "DNA is more what you'd call guidelines, than actual rules." description: "DNA is more what you'd call guidelines, than actual rules."
preBody: '_disclaimer' preBody: '_disclaimer'
classes: classes:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "In Conclusion" title: "In Conclusion"
linkTitle: "Conclusion"
description: "Enough with the gatekeeping already." description: "Enough with the gatekeeping already."
siblings: siblings:
prev: /gdb/second-puberty-fem prev: /gdb/second-puberty-fem

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "Diagnosing Gender Dysphoria" title: "Diagnosing Gender Dysphoria"
linkTitle: "Clinical Diagnoses"
description: "It's clinical." description: "It's clinical."
preBody: '_disclaimer' preBody: '_disclaimer'
classes: classes:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Euphoria" title: "How Gender Dysphoria Manifests: Euphoria"
linkTitle: "Gender Euphoria"
description: "In order for there to be shadow there must be light." description: "In order for there to be shadow there must be light."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Existential Dysphoria" title: "How Gender Dysphoria Manifests: Existential Dysphoria"
linkTitle: "Existential Dysphoria"
description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance." description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance."
classes: classes:
- gdb - gdb

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "A Brief History of Gender Dysphoria" title: "A Brief History of Gender Dysphoria"
linkTitle: "The History of Gender Dysphoria"
description: "The origins of Gender Dysphoria and the current meaning today." description: "The origins of Gender Dysphoria and the current meaning today."
classes: classes:
- gdb - gdb

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "Hormones: How do they work" title: "Hormones: How do they work"
linkTitle: "How Hormones Work"
description: "It's nothing like magnets." description: "It's nothing like magnets."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "Impostor Syndrome, but make it Trans" title: "Impostor Syndrome, but make it Trans"
linkTitle: "Impostor Syndrome"
description: "Am I really trans?" description: "Am I really trans?"
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "Managed Dysphoria: Gender in Disguise" title: "Managed Dysphoria: Gender in Disguise"
linkTitle: "Managed Dysphoria"
description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance." description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Physical Dysphoria" title: "How Gender Dysphoria Manifests: Physical Dysphoria"
linkTitle: "Physical Dysphoria"
description: "Body discomfort is only one of the many ways Gender Dysphoria manifests." description: "Body discomfort is only one of the many ways Gender Dysphoria manifests."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Presentational Dysphoria" title: "How Gender Dysphoria Manifests: Presentational Dysphoria"
linkTitle: "Presentational Dysphoria"
description: "Hoodies and sweatpants never go out of style." description: "Hoodies and sweatpants never go out of style."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Sexual Dysphoria" title: "How Gender Dysphoria Manifests: Sexual Dysphoria"
linkTitle: "Sexual Dysphoria"
description: "Sometimes a Cigar doesn't want to be smoked." description: "Sometimes a Cigar doesn't want to be smoked."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Social Dysphoria" title: "How Gender Dysphoria Manifests: Social Dysphoria"
linkTitle: "Social Dysphoria"
description: "Pronouns and Deadnames and Gendering, oh my." description: "Pronouns and Deadnames and Gendering, oh my."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

View File

@ -1,6 +1,7 @@
--- ---
date: "2020-01-26T20:41:55.827Z" date: "2020-01-26T20:41:55.827Z"
title: "How Gender Dysphoria Manifests: Societal Dysphoria" title: "How Gender Dysphoria Manifests: Societal Dysphoria"
linkTitle: "Societal Dysphoria"
description: "Because a Role is a Role, and a Toll is a Toll, and it's a heavy toll to live the wrong role." description: "Because a Role is a Role, and a Toll is a Toll, and it's a heavy toll to live the wrong role."
preBody: '_disclaimer' preBody: '_disclaimer'
siblings: siblings:

73
tools/navigation.py Executable file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env python3
import os
import glob
import yaml
def get_all_pages():
return [file for file in glob.glob("gdb/*.md")
if not file.endswith("/index.md")]
def fix_web_path(page):
return '/' + page[:-3]
def parse_page_data(page):
with open(page) as fd:
return next(yaml.safe_load_all(fd))
def most_appropriate_title(data):
return data.get("linkTitle") or data['title']
def traverse_siblings(pages, start, sibling='next'):
page = start
while page in pages:
yield page
page = pages[page]['siblings'].get(sibling)
def create_intro_toc(pages, start, offset=2):
for num, page in enumerate(traverse_siblings(pages, start)):
data = pages[page]
title = most_appropriate_title(data)
print(f"{num + offset}. [{title}]({page})\n")
def create_navbar(pages, start):
longest_link = max(map(len, traverse_siblings(pages, start))) + 2
for page in traverse_siblings(pages, start):
data = pages[page]
title = most_appropriate_title(data)
linksq = f"'{page}'"
linkdq = f'"{page}"'
print(f' <a href={linkdq:{longest_link}s} class="{{{{#is meta.url {linksq:{longest_link}s}}}}}active {{{{/is}}}}dropdown-item">{title}</a>')
def check_nav_consistency(pages, first):
for page in traverse_siblings(pages, first):
siblings = pages[page]['siblings']
for sibling in 'prev', 'next':
sibling_data = pages.get(siblings.get(sibling))
if sibling_data:
sibling_title = most_appropriate_title(sibling_data)
link_title = siblings[sibling + 'Caption']
if sibling_title != link_title:
print(f"{page}: caption mismatch for {sibling}: expected {sibling_title!r}, got {link_title!r}")
def main():
os.chdir("../public")
pages = {fix_web_path(file): parse_page_data(file) for file in get_all_pages()}
*_, first = traverse_siblings(pages, next(iter(pages)), sibling="prev")
create_intro_toc(pages, first)
create_navbar(pages, first)
check_nav_consistency(pages, first)
return 0
if __name__ == '__main__':
main()