rgapi 0.1.25__tar.gz → 0.1.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rgapi-0.1.25 → rgapi-0.1.26}/Cargo.lock +11 -18
- {rgapi-0.1.25 → rgapi-0.1.26}/Cargo.toml +1 -1
- {rgapi-0.1.25 → rgapi-0.1.26}/DEV.md +2 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/PKG-INFO +1 -1
- {rgapi-0.1.25 → rgapi-0.1.26}/src/lib.rs +1 -1
- {rgapi-0.1.25 → rgapi-0.1.26}/src/nb.rs +32 -1
- {rgapi-0.1.25 → rgapi-0.1.26}/.github/workflows/ci.yml +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/.gitignore +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/LICENSE +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/README.md +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/_config.yml +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/_layouts/default.html +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/pyproject.toml +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/python/rgapi/__init__.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/python/rgapi/_cli.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/python/rgapi/block.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/python/rgapi/nb.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/python/rgapi/skill.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/rustfmt.toml +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/src/block.rs +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/src/python.rs +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/src/search.rs +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/src/walk.rs +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/tests/test_async.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/tests/test_rgapi.py +0 -0
- {rgapi-0.1.25 → rgapi-0.1.26}/tools/bench.py +0 -0
|
@@ -36,9 +36,9 @@ checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
|
|
|
36
36
|
|
|
37
37
|
[[package]]
|
|
38
38
|
name = "crc32fast"
|
|
39
|
-
version = "1.5.
|
|
39
|
+
version = "1.5.2"
|
|
40
40
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
41
|
-
checksum = "
|
|
41
|
+
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
|
42
42
|
dependencies = [
|
|
43
43
|
"cfg-if",
|
|
44
44
|
]
|
|
@@ -70,9 +70,9 @@ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
|
70
70
|
|
|
71
71
|
[[package]]
|
|
72
72
|
name = "encoding_rs"
|
|
73
|
-
version = "0.8.
|
|
73
|
+
version = "0.8.41"
|
|
74
74
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
-
checksum = "
|
|
75
|
+
checksum = "7b5ef0006ac9ab233c38522f5ae99cae3625151de8f706cacee1cba4b8e2832a"
|
|
76
76
|
dependencies = [
|
|
77
77
|
"cfg-if",
|
|
78
78
|
"core_detect",
|
|
@@ -199,24 +199,23 @@ dependencies = [
|
|
|
199
199
|
|
|
200
200
|
[[package]]
|
|
201
201
|
name = "multiversion"
|
|
202
|
-
version = "0.
|
|
202
|
+
version = "0.9.0"
|
|
203
203
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
-
checksum = "
|
|
204
|
+
checksum = "b4ca4bea16ffc3f443cf7d866912118196bfef4c6a1556ca00f9f9b00bb43f7c"
|
|
205
205
|
dependencies = [
|
|
206
206
|
"multiversion-macros",
|
|
207
|
-
"target-features",
|
|
208
207
|
]
|
|
209
208
|
|
|
210
209
|
[[package]]
|
|
211
210
|
name = "multiversion-macros"
|
|
212
|
-
version = "0.
|
|
211
|
+
version = "0.9.0"
|
|
213
212
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
214
|
-
checksum = "
|
|
213
|
+
checksum = "0d416831a7317ef4b08bee00b69cbbb9c8763da7959a7026244d6266869f9c83"
|
|
215
214
|
dependencies = [
|
|
216
215
|
"proc-macro2",
|
|
217
216
|
"quote",
|
|
218
|
-
"
|
|
219
|
-
"
|
|
217
|
+
"rustversion",
|
|
218
|
+
"syn 3.0.5",
|
|
220
219
|
]
|
|
221
220
|
|
|
222
221
|
[[package]]
|
|
@@ -331,7 +330,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
|
331
330
|
|
|
332
331
|
[[package]]
|
|
333
332
|
name = "rgapi"
|
|
334
|
-
version = "0.1.
|
|
333
|
+
version = "0.1.26"
|
|
335
334
|
dependencies = [
|
|
336
335
|
"crc32fast",
|
|
337
336
|
"globset",
|
|
@@ -436,12 +435,6 @@ dependencies = [
|
|
|
436
435
|
"unicode-ident",
|
|
437
436
|
]
|
|
438
437
|
|
|
439
|
-
[[package]]
|
|
440
|
-
name = "target-features"
|
|
441
|
-
version = "0.1.6"
|
|
442
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
443
|
-
checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5"
|
|
444
|
-
|
|
445
438
|
[[package]]
|
|
446
439
|
name = "target-lexicon"
|
|
447
440
|
version = "0.13.5"
|
|
@@ -50,4 +50,6 @@ Path results are `FileEntry` rows: a `str` subclass carrying the walk root, so p
|
|
|
50
50
|
|
|
51
51
|
Rust callers can consume a `StreamIter` with `cancel_and_join()` to cancel, drain queued results, and wait for the walk's workers to finish. `Drop` remains nonblocking. Since filesystem calls already in progress must return before joining completes, keep `cancel_and_join()` off async executors.
|
|
52
52
|
|
|
53
|
+
Notebook hierarchy uses `heading_level(source)`, `section_range(levels, idx)` and `ancestor_indices(levels, idx)`. Callers supply zero for non-heading cells. Heading detection skips blank lines and lines starting with `#|`, then checks the first remaining line against `^#{1,6} \w`. It does not search past ordinary text. Section ranges include the addressed cell and end before the next equal-or-higher heading; non-headings select themselves. Ancestors exclude the addressed cell and are returned outermost first. These are calculations over the supplied levels, without retained outline state. Rustygate uses them for its cell selectors.
|
|
54
|
+
|
|
53
55
|
This package intentionally has no CLI. Python is the interface.
|
|
@@ -9,7 +9,7 @@ mod walk;
|
|
|
9
9
|
mod python;
|
|
10
10
|
|
|
11
11
|
pub use block::{BlockIter, SearchBlock, block_iter};
|
|
12
|
-
pub use nb::{NbCell, NbIter, NbOptions, nb_iter, nb_search, nb_search_file};
|
|
12
|
+
pub use nb::{NbCell, NbIter, NbOptions, ancestor_indices, heading_level, nb_iter, nb_search, nb_search_file, section_range};
|
|
13
13
|
pub use search::{MatchSpan, RgIter, RgOptions, SearchKind, SearchLine, compile_regex, rg, rg_iter, search_path, search_text};
|
|
14
14
|
pub use walk::{FindIter, FindOptions, StreamIter, find, find_iter};
|
|
15
15
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
use std::collections::{BTreeMap, HashMap};
|
|
2
2
|
use std::path::{Path, PathBuf};
|
|
3
|
-
use std::sync::Arc;
|
|
3
|
+
use std::sync::{Arc, LazyLock};
|
|
4
4
|
use std::sync::atomic::Ordering;
|
|
5
5
|
|
|
6
|
+
use grep_matcher::Matcher;
|
|
6
7
|
use grep_regex::RegexMatcher;
|
|
7
8
|
use ignore::{DirEntry, WalkState};
|
|
8
9
|
use serde::Deserialize;
|
|
@@ -11,6 +12,36 @@ use crate::RgApiError;
|
|
|
11
12
|
use crate::search::{SearchLine, compile_regex, search_text};
|
|
12
13
|
use crate::walk::{PathFilters, StreamIter, entry_err, file_root_flags, normalize_root, rel_path, spawn_walk};
|
|
13
14
|
|
|
15
|
+
static HEADING_RE: LazyLock<RegexMatcher> = LazyLock::new(|| RegexMatcher::new(r"^#{1,6} \w").unwrap());
|
|
16
|
+
|
|
17
|
+
/// Heading level of the first nonblank line after skipping `#|` directives; zero unless it matches `^#{1,6} \w`.
|
|
18
|
+
pub fn heading_level(source: &str) -> usize {
|
|
19
|
+
let line = source.lines().find(|l| !l.trim().is_empty() && !l.starts_with("#|")).unwrap_or("");
|
|
20
|
+
if !HEADING_RE.is_match(line.as_bytes()).unwrap_or(false) { return 0; }
|
|
21
|
+
line.bytes().take_while(|&b| b == b'#').count()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// A heading and its descendants; a non-heading selects itself. Zero levels represent non-heading cells.
|
|
25
|
+
pub fn section_range(levels: &[usize], idx: usize) -> std::ops::Range<usize> {
|
|
26
|
+
if levels[idx] == 0 { return idx..idx + 1; }
|
|
27
|
+
let end = (idx + 1..levels.len()).find(|&i| levels[i] > 0 && levels[i] <= levels[idx]).unwrap_or(levels.len());
|
|
28
|
+
idx..end
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Enclosing heading indices, outermost first, excluding the addressed cell.
|
|
32
|
+
pub fn ancestor_indices(levels: &[usize], idx: usize) -> Vec<usize> {
|
|
33
|
+
let mut level = if levels[idx] == 0 { 7 } else { levels[idx] };
|
|
34
|
+
let mut parents = Vec::new();
|
|
35
|
+
for i in (0..idx).rev() {
|
|
36
|
+
if levels[i] > 0 && levels[i] < level {
|
|
37
|
+
parents.push(i);
|
|
38
|
+
level = levels[i];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
parents.reverse();
|
|
42
|
+
parents
|
|
43
|
+
}
|
|
44
|
+
|
|
14
45
|
#[derive(Debug, Clone)]
|
|
15
46
|
pub struct NbOptions {
|
|
16
47
|
pub root: PathBuf,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|