cargo-json-docs 0.5.0
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.
- package/LICENCE +21 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/item.d.ts +100 -0
- package/dist/item.d.ts.map +1 -0
- package/dist/item.js +589 -0
- package/dist/item.js.map +1 -0
- package/dist/json.d.ts +81 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +226 -0
- package/dist/json.js.map +1 -0
- package/dist/lib.d.ts +21 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +36 -0
- package/dist/lib.js.map +1 -0
- package/package.json +26 -0
- package/readme.md +95 -0
- package/src/errors.ts +31 -0
- package/src/item.ts +658 -0
- package/src/json.ts +274 -0
- package/src/lib.ts +30 -0
- package/src/types.d.ts +84 -0
- package/test/item.test.d.ts +2 -0
- package/test/item.test.d.ts.map +1 -0
- package/test/item.test.js +107 -0
- package/test/item.test.js.map +1 -0
- package/test/item.test.ts +128 -0
- package/test/json.test.d.ts +2 -0
- package/test/json.test.d.ts.map +1 -0
- package/test/json.test.js +24 -0
- package/test/json.test.js.map +1 -0
- package/test/json.test.ts +29 -0
- package/test/test_crate/Cargo.lock +74 -0
- package/test/test_crate/Cargo.toml +7 -0
- package/test/test_crate/src/lib.rs +50 -0
- package/test/test_crate/src/module_a.rs +16 -0
- package/test/test_crate/src/module_b/inner_b.rs +10 -0
- package/test/test_crate/src/module_b.rs +1 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import { DocumentationSource } from '../src/json';
|
|
3
|
+
test('can get modification time', () => {
|
|
4
|
+
const source = new DocumentationSource('test/test_crate');
|
|
5
|
+
const modTime = source.lastModified();
|
|
6
|
+
expect(modTime).toBeInstanceOf(Date);
|
|
7
|
+
expect(modTime.getTime()).toBeGreaterThan(0);
|
|
8
|
+
});
|
|
9
|
+
test('can determine if generation is needed', () => {
|
|
10
|
+
const source = new DocumentationSource('test/test_crate');
|
|
11
|
+
const needsGen = source.shouldGenerate();
|
|
12
|
+
expect(typeof needsGen).toBe('boolean');
|
|
13
|
+
});
|
|
14
|
+
test('can generate JSON', () => {
|
|
15
|
+
const source = new DocumentationSource('test/test_crate');
|
|
16
|
+
source.generateJson();
|
|
17
|
+
let json = source.getJson();
|
|
18
|
+
expect(json).toBeDefined();
|
|
19
|
+
expect(json.index).toBeDefined();
|
|
20
|
+
// Should not be stale
|
|
21
|
+
const needsGenAfter = source.shouldGenerate();
|
|
22
|
+
expect(needsGenAfter).toBe(false);
|
|
23
|
+
}, 10000); // Allow up to 10 seconds for generation
|
|
24
|
+
//# sourceMappingURL=json.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.test.js","sourceRoot":"","sources":["json.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACnC,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IACtC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;IAC/C,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACzC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC3B,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,CAAC,YAAY,EAAE,CAAC;IAEtB,IAAI,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjC,sBAAsB;IACtB,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IAC9C,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,wCAAwC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { DocumentationSource } from '../src/json';
|
|
4
|
+
|
|
5
|
+
test('can get modification time', () => {
|
|
6
|
+
const source = new DocumentationSource('test/test_crate');
|
|
7
|
+
const modTime = source.lastModified();
|
|
8
|
+
expect(modTime).toBeInstanceOf(Date);
|
|
9
|
+
expect(modTime.getTime()).toBeGreaterThan(0);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('can determine if generation is needed', () => {
|
|
13
|
+
const source = new DocumentationSource('test/test_crate');
|
|
14
|
+
const needsGen = source.shouldGenerate();
|
|
15
|
+
expect(typeof needsGen).toBe('boolean');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('can generate JSON', () => {
|
|
19
|
+
const source = new DocumentationSource('test/test_crate');
|
|
20
|
+
source.generateJson();
|
|
21
|
+
|
|
22
|
+
let json = source.getJson();
|
|
23
|
+
expect(json).toBeDefined();
|
|
24
|
+
expect(json.index).toBeDefined();
|
|
25
|
+
|
|
26
|
+
// Should not be stale
|
|
27
|
+
const needsGenAfter = source.shouldGenerate();
|
|
28
|
+
expect(needsGenAfter).toBe(false);
|
|
29
|
+
}, 10000); // Allow up to 10 seconds for generation
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "proc-macro2"
|
|
7
|
+
version = "1.0.105"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"unicode-ident",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "quote"
|
|
16
|
+
version = "1.0.43"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"proc-macro2",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "serde"
|
|
25
|
+
version = "1.0.228"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"serde_core",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "serde_core"
|
|
34
|
+
version = "1.0.228"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
37
|
+
dependencies = [
|
|
38
|
+
"serde_derive",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "serde_derive"
|
|
43
|
+
version = "1.0.228"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"proc-macro2",
|
|
48
|
+
"quote",
|
|
49
|
+
"syn",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "syn"
|
|
54
|
+
version = "2.0.114"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
|
|
57
|
+
dependencies = [
|
|
58
|
+
"proc-macro2",
|
|
59
|
+
"quote",
|
|
60
|
+
"unicode-ident",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[[package]]
|
|
64
|
+
name = "test_crate"
|
|
65
|
+
version = "0.1.0"
|
|
66
|
+
dependencies = [
|
|
67
|
+
"serde",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "unicode-ident"
|
|
72
|
+
version = "1.0.22"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// function
|
|
2
|
+
pub fn add(left: u64, right: u64) -> u64 {
|
|
3
|
+
left + right
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// re-export
|
|
7
|
+
pub use serde::{Serialize, Deserialize};
|
|
8
|
+
|
|
9
|
+
pub mod nested_module {
|
|
10
|
+
pub use serde::ser::*;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
pub struct TestStructPlain {
|
|
14
|
+
pub field1: u32,
|
|
15
|
+
pub field2: String,
|
|
16
|
+
}
|
|
17
|
+
impl TestStructPlain {
|
|
18
|
+
pub fn new(field1: u32, field2: String) -> Self {
|
|
19
|
+
Self { field1, field2 }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
impl TestStructPlain {
|
|
23
|
+
pub fn method_plain(&self) -> String {
|
|
24
|
+
format!("field1: {}, field2: {}", self.field1, self.field2)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pub struct TestStructTuple(pub u32, pub String);
|
|
29
|
+
impl TestStructTuple {
|
|
30
|
+
pub fn new(field1: u32, field2: String) -> Self {
|
|
31
|
+
Self(field1, field2)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
pub const TEST_CONST: u32 = 42;
|
|
36
|
+
pub type TestTypeAlias = u64;
|
|
37
|
+
|
|
38
|
+
mod module_a;
|
|
39
|
+
pub use module_a::TestEnum;
|
|
40
|
+
|
|
41
|
+
pub mod module_b;
|
|
42
|
+
|
|
43
|
+
#[macro_export]
|
|
44
|
+
macro_rules! test_macro {
|
|
45
|
+
($name:ident) => {
|
|
46
|
+
pub fn $name() -> String {
|
|
47
|
+
stringify!($name).to_string()
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pub enum TestEnum {
|
|
2
|
+
VariantOne,
|
|
3
|
+
VariantTwo(u32),
|
|
4
|
+
VariantThree { name: String, value: u64 },
|
|
5
|
+
}
|
|
6
|
+
impl TestEnum {
|
|
7
|
+
pub fn describe(&self) -> String {
|
|
8
|
+
match self {
|
|
9
|
+
TestEnum::VariantOne => "This is Variant One".to_string(),
|
|
10
|
+
TestEnum::VariantTwo(v) => format!("This is Variant Two with value {}", v),
|
|
11
|
+
TestEnum::VariantThree { name, value } => {
|
|
12
|
+
format!("This is Variant Three with name {} and value {}", name, value)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pub mod inner_b;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"target": "es2020",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
"exactOptionalPropertyTypes": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
|
|
20
|
+
"typeRoots": ["./src", "./node_modules/@types"]
|
|
21
|
+
},
|
|
22
|
+
"include": ["src"]
|
|
23
|
+
}
|