Parcourir la source

Ability to display orphan fragments

master
David Larlet il y a 1 an
Parent
révision
ed213aa943
Aucune clé connue n'a été trouvée dans la base pour cette signature
1 fichiers modifiés avec 13 ajouts et 5 suppressions
  1. 13
    5
      site.py

+ 13
- 5
site.py Voir le fichier

@@ -124,11 +124,19 @@ class Page:


@cli
def fragment(title: str):
"""Create a new fragment and open it in iA Writer."""
fragment_path = DAVID / "2020" / "fragments" / f"{title}.md"
open(fragment_path, "w+").write(f"## {title}")
os.popen(f'open -a "iA Writer" "{fragment_path}"')
def orphans():
"""Print out fragments not linked to any page."""
linked_fragments = []
for file_path in each_markdown_from(DAVID / "2020"):
for line in open(file_path).readlines():
if line.startswith(".. include:: fragments/"):
linked_fragments.append(line[len(".. include:: fragments/") : -1])
all_fragments = []
for file_path in each_markdown_from(DAVID / "2020" / "fragments"):
all_fragments.append(file_path[len("david/2020/fragments/") :])
for fragment_filename in set(all_fragments) - set(linked_fragments):
# Prepending path for easy command+click from fish.
print(DAVID / "2020" / "fragments" / fragment_filename)


@cli

Chargement…
Annuler
Enregistrer