From c0ba0af023439f964a7704ff7dc4dcce74cc68ce Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Wed, 26 Jun 2024 20:45:52 +0800 Subject: [PATCH] fix: sort gendoc replacements --- docs/gendoc.py | 35 ++++++++++++++++++----------------- docs/src/configuration.md | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/gendoc.py b/docs/gendoc.py index a48b869d..19dde06a 100644 --- a/docs/gendoc.py +++ b/docs/gendoc.py @@ -13,7 +13,7 @@ GENDOC_REGEX = re.compile("{{gendoc (.+)}}") KEYS_REGEX = re.compile(r"{{keys (.+)}}") -API_REGEX = re.compile(r"{{api ([a-z0-9/]+)}}") +API_REGEX = re.compile(r"{{api ([a-z0-9/-]+)}}") class Symbol(NamedTuple): @@ -219,22 +219,6 @@ def transform_chapter(chapter) -> None: ) ) - for ref in KEYS_REGEX.finditer(content): - args = ref.group(1) - if len(args) == 0: - continue - - replace.append( - ( - ref.start(0), - ref.end(0), - render_keys( - bindings, - args.split(" "), - ), - ) - ) - for ref in API_REGEX.finditer(content): name = ref.group(1) if len(name) == 0: @@ -259,6 +243,23 @@ def transform_chapter(chapter) -> None: ) ) + for ref in KEYS_REGEX.finditer(content): + args = ref.group(1) + if len(args) == 0: + continue + + replace.append( + ( + ref.start(0), + ref.end(0), + render_keys( + bindings, + args.split(" "), + ), + ) + ) + + replace = sorted(replace, key=lambda a: a[1]) for start, end, text in reversed(replace): content = content[:start] + text + content[end:] diff --git a/docs/src/configuration.md b/docs/src/configuration.md index 525b5440..fa9dd59b 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -24,7 +24,7 @@ On startup, `cy` will search for and execute the first file containing Janet sou 1. `$HOME/.config/cyrc.janet` 1. `$HOME/.config/.cy.janet` -For now, there is no way to reload your configuration; if you make changes to your configuration file, you'll need to restart cy. +You can reload your configuration at runtime using {{api action/reload-config}}, which by default is bound to ctrl+ar. Your `cy` configuration can contain any valid Janet statement, but `cy` also provides additions to the standard library in the form of [an API](./api.md) for controlling every aspect of how `cy` works.