Skip to content

Commit

Permalink
fix: sort gendoc replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Jun 26, 2024
1 parent 35786db commit c0ba0af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions docs/gendoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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:]

Expand Down
2 changes: 1 addition & 1 deletion docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kbd>ctrl+a</kbd><kbd>r</kbd>.

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.

Expand Down

0 comments on commit c0ba0af

Please sign in to comment.