Skip to content
This repository was archived by the owner on Dec 22, 2025. It is now read-only.

Commit d737976

Browse files
authored
refactor: deps and docs (#1)
* chore: update deps and docs * chore: remove extar optionalDeps in package.json * chore: update yarn install
1 parent 471a715 commit d737976

File tree

7 files changed

+98
-10
lines changed

7 files changed

+98
-10
lines changed

.yarn/install-state.gz

-3 Bytes
Binary file not shown.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.dependencies]
66
html5ever = "0.27.0"
77
indexmap = "2.2.6"
8-
kuchikiki = { git = "https://github.com/xusd320/kuchikiki.git", rev = "c671c7b" }
8+
kuchikiki = { git = "https://github.com/xusd320/kuchikiki.git", rev = "f1b69c1" }
99

1010
[profile.release]
1111
lto = true

README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ Clone this node to a new instance, including its all descendants.
8282

8383
[index.d.ts:92](https://github.com/umijs/niddle/blob/main/index.d.ts#L92)
8484

85+
##### constructor()
86+
87+
> **constructor**(): `void`
88+
89+
The node object, cann't be instantiated in javascript. So call the constructor will throw an error
90+
91+
###### Returns
92+
93+
`void`
94+
95+
###### Defined in
96+
97+
[index.d.ts:96](https://github.com/umijs/niddle/blob/main/index.d.ts#L96)
98+
8599
##### getAttribute()
86100

87101
> **getAttribute**(`name`): `string`
@@ -340,9 +354,11 @@ Remove an attribute of this node by name
340354

341355
##### select()
342356

357+
###### select(selectors)
358+
343359
> **select**(`selectors`): [`NodeRepr`](README.md#noderepr)
344360
345-
Select the the fist node that match the given selector, like document.querySelector.
361+
Select the the fist node that match the given css selector, like document.querySelector.
346362

347363
###### Parameters
348364

@@ -358,11 +374,65 @@ Select the the fist node that match the given selector, like document.querySelec
358374

359375
[index.d.ts:68](https://github.com/umijs/niddle/blob/main/index.d.ts#L68)
360376

377+
###### select(selectors)
378+
379+
> **select**(`selectors`): [`NodeRepr`](README.md#noderepr)
380+
381+
###### Parameters
382+
383+
| Parameter | Type |
384+
| ------ | ------ |
385+
| `selectors` | `"html"` |
386+
387+
###### Returns
388+
389+
[`NodeRepr`](README.md#noderepr)
390+
391+
###### Defined in
392+
393+
[index.d.ts:97](https://github.com/umijs/niddle/blob/main/index.d.ts#L97)
394+
395+
###### select(selectors)
396+
397+
> **select**(`selectors`): [`NodeRepr`](README.md#noderepr)
398+
399+
###### Parameters
400+
401+
| Parameter | Type |
402+
| ------ | ------ |
403+
| `selectors` | `"head"` |
404+
405+
###### Returns
406+
407+
[`NodeRepr`](README.md#noderepr)
408+
409+
###### Defined in
410+
411+
[index.d.ts:98](https://github.com/umijs/niddle/blob/main/index.d.ts#L98)
412+
413+
###### select(selectors)
414+
415+
> **select**(`selectors`): [`NodeRepr`](README.md#noderepr)
416+
417+
###### Parameters
418+
419+
| Parameter | Type |
420+
| ------ | ------ |
421+
| `selectors` | `"body"` |
422+
423+
###### Returns
424+
425+
[`NodeRepr`](README.md#noderepr)
426+
427+
###### Defined in
428+
429+
[index.d.ts:99](https://github.com/umijs/niddle/blob/main/index.d.ts#L99)
430+
361431
##### selectAll()
362432

363433
> **selectAll**(`selectors`): [`NodeRepr`](README.md#noderepr)[]
364434
365-
Select all nodes that match the given selector, like document.querySelectorAll.
435+
Select all nodes that match the given css selector, like document.querySelectorAll.
366436

367437
###### Parameters
368438

crates/niddle_napi/src/node_repr/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use super::NodeRepr;
88

99
#[napi]
1010
impl NodeRepr {
11-
/// Select the the fist node that match the given selector, like document.querySelector.
11+
/// Select the the fist node that match the given css selector, like document.querySelector.
1212
#[napi]
1313
pub fn select(&self, selectors: String) -> Option<NodeRepr> {
1414
self.0.select_first(&selectors).ok().map(Into::into)
1515
}
1616

17-
/// Select all nodes that match the given selector, like document.querySelectorAll.
17+
/// Select all nodes that match the given css selector, like document.querySelectorAll.
1818
#[napi]
1919
pub fn select_all(&self, selectors: String) -> Vec<NodeRepr> {
2020
self

index.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ export declare class NodeRepr {
6464
removeAttribute(name: string): void
6565
/** Remove all attributes of this node */
6666
removeAllAttributes(): void
67-
/** Select the the fist node that match the given selector, like document.querySelector. */
67+
/** Select the the fist node that match the given css selector, like document.querySelector. */
6868
select(selectors: string): NodeRepr | null
69-
/** Select all nodes that match the given selector, like document.querySelectorAll. */
69+
/** Select all nodes that match the given css selector, like document.querySelectorAll. */
7070
selectAll(selectors: string): Array<NodeRepr>
7171
/** Get all children nodes of this node. */
7272
getChildren(): Array<NodeRepr>
@@ -91,3 +91,10 @@ export declare class NodeRepr {
9191
/** Clone this node to a new instance, including its all descendants. */
9292
cloneRecursive(): NodeRepr
9393
}
94+
export declare interface NodeRepr {
95+
/** The node object, cann't be instantiated in javascript. So call the constructor will throw an error */
96+
constructor(): void;
97+
select(selectors: "html"): NodeRepr;
98+
select(selectors: "head"): NodeRepr;
99+
select(selectors: "body"): NodeRepr;
100+
}

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
]
3131
}
3232
},
33+
"keywords": [
34+
"htmlparser",
35+
"jquery",
36+
"selector",
37+
"scraper",
38+
"parser",
39+
"dom",
40+
"html",
41+
"rust",
42+
"napi"
43+
],
3344
"license": "MIT",
3445
"devDependencies": {
3546
"@napi-rs/cli": "^2.18.4",
@@ -53,14 +64,14 @@
5364
"artifacts": "napi artifacts",
5465
"build": "napi build --platform --release --cargo-name niddle_napi",
5566
"build:debug": "napi build --platform --cargo-name niddle_napi",
56-
"prepublishOnly": "yarn patchdts && napi prepublish -t npm",
67+
"prepublishOnly": "yarn patchdts && yarn docs && napi prepublish -t npm",
5768
"universal": "napi universal",
5869
"version": "napi version",
5970
"test": "ava",
6071
"patchdts": "cat ./patch.d.ts >> ./index.d.ts",
6172
"benchmark": "node ./benchmark/benchmark.mjs",
6273
"prepare": "husky install",
63-
"docs": "npx typedoc ./index.d.ts && mv ./docs/README.md ./README.md"
74+
"docs": "npx typedoc && mv ./docs/README.md ./README.md"
6475
},
6576
"repository": "https://github.com/umijs/niddle",
6677
"packageManager": "yarn@4.3.1",

0 commit comments

Comments
 (0)