feat(config): on-save autoregen family — links/tags/diary-index (P2)
Added per-wiki auto_generate_links, auto_generate_tags, auto_diary_index (default false, like upstream), wired into the did_save hook mirroring auto_toc: - auto_generate_links / auto_generate_tags rebuild the Generated Links / Generated Tags section ONLY when it already exists (new links_rebuild_edit / tag_links_rebuild_edit, like toc_rebuild_edit) — never inserts one into a page that lacks it. - auto_diary_index regenerates the diary index page when a dated diary entry (not the index itself) is saved, via diary_generate_index_edit (handles the index file open / on-disk / absent). auto_tags is recorded as an intentional divergence: nuwiki re-indexes tags on every change, so the tag metadata is always fresh (no on-disk file to update). Tests: links_rebuild_edit_only_acts_when_section_present, tag_links_rebuild_edit_only_acts_when_index_present, config round-trip + defaults. README/doc/lua comment updated. fmt/clippy clean; 0 Rust failures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -305,6 +305,39 @@ fn build_toc_text_with_no_headings_is_just_the_heading() {
|
||||
assert_eq!(out, "= Contents =\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn links_rebuild_edit_only_acts_when_section_present() {
|
||||
let pages = vec!["Home".to_string(), "About".to_string()];
|
||||
let uri = Url::from_file_path("/w/Home.wiki").unwrap();
|
||||
let without = "= Home =\nbody\n";
|
||||
assert!(
|
||||
ops::links_rebuild_edit(
|
||||
without,
|
||||
&parse(without),
|
||||
&uri,
|
||||
"Home",
|
||||
&pages,
|
||||
true,
|
||||
"Generated Links",
|
||||
1
|
||||
)
|
||||
.is_none(),
|
||||
"must not insert a links section into a page that lacks one"
|
||||
);
|
||||
let with = "= Generated Links =\n- [[old]]\n";
|
||||
assert!(ops::links_rebuild_edit(
|
||||
with,
|
||||
&parse(with),
|
||||
&uri,
|
||||
"Home",
|
||||
&pages,
|
||||
true,
|
||||
"Generated Links",
|
||||
1
|
||||
)
|
||||
.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_section_range_stops_at_same_level_sibling() {
|
||||
// A non-level-1 generated section (e.g. a level-2 tags index) must not
|
||||
|
||||
Reference in New Issue
Block a user