"""Two reference pages: the Glossary (/glossary/) and the Method (/method/). The glossary is read from glossary.toml. The method page is generated from the definitions in docs/schema.md and from the records: how many have each figure, and how the measured lengths of the tracks compare with the published ones. """ import collections import os import re import statistics from . import common, datafiles, elevation, facets, hike, pagekit, words from .markup import Markup, esc GLOSSARY = "/glossary/" METHOD = "/method/" # Glossary --------------------------------------------------------------------------- def terms(repo_root): return datafiles.glossary(repo_root) def terms_for(path, repo_root): """The glossary terms that point at a page: [(term id, term)].""" return [(t["id"], t["term"]) for t in terms(repo_root) if path in t.get("see", [])] def terms_nav(path, repo_root): """A line of links to the glossary entries for a page, or "".""" found = terms_for(path, repo_root) if not found: return "" links = " · ".join(f'{esc(t)}' for i, t in found) return f'' def glossary_page(repo_root, labels, site): """(title, description, body, terms) for /glossary/. labels: {path: link text} for every page built, so that a term links only to a page that exists.""" ts = terms(repo_root) if not ts: return None entries = "" for t in ts: see = [(p, labels[p]) for p in t.get("see", []) if p in labels] see_html = (" See: " + ", ".join(f'{esc(label)}' for p, label in see) + ".") if see else "" src = (f' Source: {esc(t["source_url"])}.') if t.get("source_url") else "" entries += (f'
A trail’s length here is the end-to-end length of its canonical path: one walk from one end to the other, taking one branch at a split, leaving out side trails and counting no stretch twice. It is the figure the trail’s holder or author gives for that walk, and each record says where it comes from. A trail that cannot be walked from end to end today is not listed. The lists and pages show the length in miles with kilometres after.
Some holders also publish a larger figure for a whole system, or a planned total. A record keeps it apart as the whole system, with what it counts, and no list, length band or time estimate uses it. {n_system} of the {n} records have one. A trail that can be walked through but is partly unbuilt keeps the holder’s end-to-end route as its length and gives the built length beside it. {n_built} of the {n} records give one.
Where a track is included, its length is measured along the track as a geodesic length and compared with the published figure. The difference is the measured length minus the published length, as a percent of the published length. Track ends within 100 metres are joined, and the number of parts left is shown.
Across the {len(ver)} measured tracks, the middle difference is {mid:.1f} percent.
{pagekit.table(["Measured against published", "Tracks", "Share"], rows, caption="How the measured tracks compare", numeric=(1, 2))}A track that differs by more than {limit:.0f} percent needs a reason in its record, such as a trail that is partly unbuilt, a published length that is a planned one, or side trails counted in the figure. {gaps} of the {len(ver)} measured tracks give one. A track that covers only part of a trail is marked as partial, and its measured length is not its trail’s length.
{no_track} records have no track included. Their length is the published figure alone, and nothing has been measured.
{esc(_sentence(meaning.get("days", "").replace(" [fewest, most],", "")))} {stated} of the {n} records have a time a source states. For the others the page estimates it from the length, at {round(words.km_to_mi(a))} to {round(words.km_to_mi(b))} miles ({a} to {b} km) a day, or {round(words.km_to_mi(c))} to {round(words.km_to_mi(d_))} miles ({c} to {d_} km) a day where much of the trail is cross-country. An estimate is labelled as one wherever it is shown.
Climb is the total ascent along the track.{(" It uses " + esc(model) + ", sampled every " + words.fmt_int(spacing) + " metres, with " + esc(smoothing[:1].lower() + smoothing[1:]) + ".") if model and spacing else ""} {esc(limits_text)}
A climb is ranked or shown in a list only where its track covers the whole trail: a track that covers part of the trail, or more than the trail, would mislead.
{esc(_sentence(meaning.get("season", "")))} {esc(_sentence(meaning.get("high_point_m", "").split(" May be given")[0]))} Not every record has them, so a page built from them says how many records it covers.
Every fact is read on a page that the record names. See the sources, the record schema and the glossary.