docs: establish marqdo-lint architecture and examples

This commit is contained in:
cflmy committed 2026-11-23 16:47:53 +08:00
1 parent 326c9bb119
commit 68b14db095
19 files changed
+1338

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
/target/
/.cache/
/dist/
/bin/
**/*.analysis.json.tmp
**/*.ast.json.tmp
Generated
+849
View File
@@ -0,0 +1,849 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "assert_cmd"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aa3a22042e45de04255c7bf3626e239f450200fd0493c1e382263544b20aea6"
dependencies = [
"anstyle",
"bstr",
"libc",
"predicates",
"predicates-core",
"predicates-tree",
"wait-timeout",
]
[[package]]
name = "autocfg"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]]
name = "bitflags"
version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "bstr"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a680398c10c7bc0488067c4612226ea905a85f607134b69f3068d505d58c4214"
dependencies = [
"memchr",
"regex-automata",
"serde_core",
]
[[package]]
name = "caseless"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8"
dependencies = [
"unicode-normalization",
]
[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
name = "clap"
version = "4.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "844c5c0b65be192cb68d570cca1b21a6444431d24e39c084dc0336177015337c"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c174f11f949b9ca8c60580925e282b9cbd5454750e506f08648b2038080cd7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79"
[[package]]
name = "colorchoice"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "comrak"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d981d666dca19afb3cc090dc7c381560cb8ba76582dda6e2c14686ff39fd547f"
dependencies = [
"caseless",
"entities",
"finl_unicode",
"memchr-n",
"phf",
"phf_codegen",
"rustc-hash",
"smallvec",
"typed-arena",
]
[[package]]
name = "cpufeatures"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "difflib"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "entities"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
[[package]]
name = "equivalent"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
[[package]]
name = "errno"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "fastrand"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
[[package]]
name = "fearless_simd"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "629c9d6b6f30b5604089e0980f4d924a013aacb1654a6cdf5d3d852224f68651"
[[package]]
name = "fearless_simd_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e91d94c6885390b81782d7ee60fd6583b33907333a8b340de25ccf468353315"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "finl_unicode"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ded33109e99472f809cb7495544506eea45e366725dacf2a383e184f660456"
[[package]]
name = "float-cmp"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
dependencies = [
"num-traits",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "getrandom"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"libc",
"r-efi",
]
[[package]]
name = "hashbrown"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "indexmap"
version = "2.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itoa"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "libc"
version = "0.2.191"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "marqdo-lint"
version = "0.1.0"
dependencies = [
"assert_cmd",
"clap",
"comrak",
"predicates",
"serde",
"serde_json",
"sha2",
"similar",
"tempfile",
"thiserror",
"toml",
"unicode-general-category",
"unicode-normalization",
"walkdir",
]
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "memchr-n"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f48c6352cc1185740af256ccc396af598d2366bfd90a34f5afe48744bf06a5b5"
dependencies = [
"fearless_simd",
"fearless_simd_macros",
]
[[package]]
name = "normalize-line-endings"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "phf"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
dependencies = [
"phf_shared",
"serde",
]
[[package]]
name = "phf_codegen"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41b585a510fb76fdebead6897982ef2a03a21d8e6cbcca904999742a4afc6ffe"
dependencies = [
"phf_generator",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
dependencies = [
"fastrand",
"phf_shared",
]
[[package]]
name = "phf_shared"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
dependencies = [
"siphasher",
]
[[package]]
name = "predicates"
version = "3.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ada8f2932f28a27ee7b70dd6c1c39ea0675c55a36879ab92f3a715eaa1e63cfe"
dependencies = [
"anstyle",
"difflib",
"float-cmp",
"normalize-line-endings",
"predicates-core",
"regex",
]
[[package]]
name = "predicates-core"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cad38746f3166b4031b1a0d39ad9f954dd291e7854fcc0eed52ee41a0b50d144"
[[package]]
name = "predicates-tree"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0de1b847b39c8131db0467e9df1ff60e6d0562ab8e9a16e568ad0fdb372e2f2"
dependencies = [
"predicates-core",
"termtree",
]
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "regex"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
[[package]]
name = "rustc-hash"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
[[package]]
name = "rustix"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "serde"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "serde_spanned"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
dependencies = [
"serde",
]
[[package]]
name = "sha2"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "similar"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
[[package]]
name = "siphasher"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
[[package]]
name = "smallvec"
version = "1.16.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom",
"once_cell",
"rustix",
"windows-sys",
]
[[package]]
name = "termtree"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
[[package]]
name = "thiserror"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tinyvec"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
[[package]]
name = "toml"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"toml_write",
"winnow",
]
[[package]]
name = "toml_write"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "typed-arena"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "unicode-general-category"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7"
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[[package]]
name = "unicode-normalization"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d"
dependencies = [
"tinyvec",
]
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "wait-timeout"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
dependencies = [
"libc",
]
[[package]]
name = "walkdir"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "winapi-util"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "winnow"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
dependencies = [
"memchr",
]
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+24
View File
@@ -0,0 +1,24 @@
[package]
name = "marqdo-lint"
version = "0.1.0"
edition = "2021"
rust-version = "1.89"
description = "面向 Marqdo 可执行文档的独立可读性检查工具"
[dependencies]
clap = { version = "4.5", features = ["derive"] }
comrak = { version = "=1.0.0", default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
sha2 = "0.10"
similar = "2"
tempfile = "3"
thiserror = "2"
toml = "0.8"
unicode-general-category = "0.6"
unicode-normalization = "0.1"
walkdir = "2"
[dev-dependencies]
assert_cmd = "2"
predicates = "3"
+34
View File
@@ -0,0 +1,34 @@
# marqdo-lint
`marqdo-lint` 是面向 Marqdo `.mq.md` 可执行文档的独立可读性检查工具。它把真实 Markdown AST 与公开 Analysis v2 对齐,检查分支、循环、叙述和说明的阅读质量,而不重新解释语言语义。
## 当前基线
- Marqdo 3.0.0-rc.1,核心审阅提交 `f7a5a7b0163bf5229ed09adfffd892f9899e6667`
- Markdown Profile `marqdo.md.v1`
- Analysis v2 与 CLI Tool v1
- Rust 1.89 或更新版本
## 构建
```bash
cargo build --locked
```
运行测试时需要兼容的冻结核心,并通过 `MARQDO_BIN` 指定其绝对路径。工具只调用公开的 `inspect --ast --json` 和 `check --emit`,不链接核心私有 crate。
## 目标命令
```bash
marqdo-lint index.mq.md
marqdo-lint . --profile recommended --format json
marqdo-lint explain MQD-BRANCH-001
marqdo-lint rules
marqdo-lint index.mq.md --fix safe
```
打包后可通过 Tool v1 安装为 `marqdo lint`。完整设计、规则和安全边界见 `docs/`。
## 发布状态
当前按 0.1.0 候选实现。核心仓库内示例的应用试跑不等于“两个独立应用仓库”发布门禁,最终限制以 `docs/VALIDATION.md` 为准。
+29
View File
@@ -0,0 +1,29 @@
# 架构
`marqdo-lint` 将同一份 Markdown 源码投影为三个只读视图,再建立仅供 Lint 使用的结构对齐:
```text
SourceSnapshot ── MarkdownTree ──┐
│ ├─ RuleContext ─ Rules ─ Diagnostics
└──── ExecutionProjection ┘ │
└──── ReadableControlTree
```
## 模块职责
- `input`:调用公开 CLI、校验协议、读取真实 AST/Analysis,并在 AST 不可用时提供严格同配置的文档级 comrak 降级。
- `model`:保存精确字节、半开 byte span、标题段、列表项、执行载体和静态语义节点。
- `alignment`:通过 span、文档顺序和语义嵌套对齐执行与阅读结构;关联不唯一时停止相关判断。
- `rules`:稳定 ID、元数据与纯检测逻辑。规则不各自调用 CLI,也不分别实现输出。
- `metrics`:函数级叙述比例和解释覆盖,不把文字长度当成正确性证明。
- `diagnostics`:统一 human/JSON 渲染、排序、失败阈值和退出码。
- `config`:profile、规则覆盖和带原因的文件级抑制。
- `fix`:只处理可证明等价的局部空白,写回前比较规范化 AST 与语义指纹。
## 不变量
1. Analysis 决定真实执行结构,Markdown AST 决定视觉容器;二者都不能由行首正则替代。
2. Knowledge、表格、代码围栏、数学、链接资源和其他惰性区域不产生执行语句。
3. `ReadableControlTree` 不是解释器,不求值、不绑定新调用,也不补全语言没有提供的语义字段。
4. 所有诊断由同一规则上下文产生,human 与 JSON 不各跑一套检测。
5. 自动修复先验证再写回;任何歧义都保持原文件不变。
+35
View File
@@ -0,0 +1,35 @@
# Marqdo 可读执行文档作者指南
## 先让阅读结构与执行结构互相对应
Marqdo 的执行语义来自载体内的 `if`、`else`、`while`、`end`、`return` 等关键字。`1.`、`-` 和 `>` 只是 Markdown 容器。推荐风格是在有序列表项开头直接写 `if`/`else`,在无序列表项开头直接写 `while`,让读者看到的层级与解释器执行层级一致。
```markdown
1. `if 是否会员`:会员采用整数九折计算。
**最终价格 = 原价 * 9 // 10**
2. `else`:其他用户保持原价。
**最终价格 = 原价**
`end`
```
不要把整个分支装入一个名为“开始判断”的列表项,也不要在列表项之后很远才写真正的控制语句。当前语言没有 `elif`,多条件链应使用真实的嵌套 `else` 与 `if`。
## 在 Exec 中自然解释
普通叙述直接写在 `@exec` 中,不需要 `# comment`,也不必包进 `@knowledge`。说明应提供目的、算法理由、处理顺序、结果和边界,而不是复述“下一步执行下一步”。
Exec 中的粗体、斜体和行内代码都是执行载体。`这是 **特别重要** 的处理` 不会把“特别重要”当普通强调;需要自由富文本时,应使用独立的 Knowledge 单元。
## 控制边界和小节
H3+ 是函数内的阅读章节,不创建新函数。一个控制块及其 `end` 必须位于同一 heading 执行段,不能通过插入标题跨段闭合。
分支组的 `end` 推荐放在有序列表之后;循环的 `end` 推荐留在对应无序列表项末尾。所有嵌套以真实 CommonMark AST 为准,不能只按空格数量猜测。
## 自动修复边界
列表重排、载体移动、载体类型替换、标题调整和控制语句迁移都属于人工修改。Lint 的安全修复不会替作者执行这些操作。
+22
View File
@@ -0,0 +1,22 @@
# 协议基线
本仓库是独立的 `marqdo-lint` 实现,不是 Marqdo 核心的一部分。
| 项目 | 固定值 |
|---|---|
| 核心审阅提交 | `f7a5a7b0163bf5229ed09adfffd892f9899e6667` |
| 核心产品版本 | `3.0.0-rc.1` |
| Markdown Profile | `marqdo.md.v1`,comrak `=1.0.0` |
| Analysis | `marqdo.analysis`,schema version 2 |
| 外部工具 | `marqdo.cli-tool`,schema version 1 |
| Lint 输出 | `marqdo.lint`,schema version 1 |
实现只读取源码并调用 `marqdo inspect --ast --json`、`marqdo check --emit`。不得链接核心私有 crate,不得使用 `inspect --ir` 代替公开 Analysis,也不得根据旧版列表规则推断控制流。
验收使用从上述提交构建并冻结的核心二进制。PATH 中较早的核心不能代替该二进制。核心二进制、源码提交和所有验证输入的摘要记录在验证报告中。
## 失败状态
- `complete`:公开 Analysis 可用,语义关联规则可以运行。
- `analysis_incomplete`:语言检查失败或语义关联不唯一。工具保留核心诊断,只运行有充分依据的文档级规则,不把该状态当成没有违规。
- 协议不兼容、配置错误和工具 I/O 错误属于工具失败,不伪装成风格诊断。
+23
View File
@@ -0,0 +1,23 @@
# @knowledge 反例
## @exec 计算会员价格
根据用户的会员身份计算最终支付金额。
`params(原价: Int, 是否会员: Bool)`
1. 首先判断用户是否有会员资格。
`if 是否会员`
**最终价格 = 原价 * 9 // 10**
`else`
**最终价格 = 原价**
`end`
返回最终应付金额。
*return 最终价格*
+24
View File
@@ -0,0 +1,24 @@
# @knowledge 定价示例
## @exec 计算会员价格
根据用户的会员身份计算最终支付金额。会员享受九折优惠,
非会员维持原价。采用整数运算,避免金额处理中的浮点误差。
`params(原价: Int, 是否会员: Bool)`
1. `if 是否会员`:会员享受九折优惠。
为保持金额计算的确定性,先乘以九,再进行整数除法。
**最终价格 = 原价 * 9 // 10**
2. `else`:其余用户保留原价。
**最终价格 = 原价**
`end`
计算结束后返回以最小货币单位表示的最终应付金额。
*return 最终价格*
+24
View File
@@ -0,0 +1,24 @@
# @knowledge 定价文档
## @exec 计算折后价格
按[折扣设计](#折扣设计)计算金额。输入和输出都使用最小货币单位。
`params(原价: Int, 分子: Int, 分母: Int)`
先乘后除可以保持整数计算的确定性;调用者必须提供非零分母。
**折后价格 = 原价 * 分子 // 分母**
返回整数折后价格,除法向下截断。
*return 折后价格*
## @knowledge 折扣设计
这里可以自由使用**加粗**、*斜体*和 `code` 解释设计,不会产生执行语句。
| 约束 | 原因 |
|---|---|
| 使用最小货币单位 | 避免浮点金额误差 |
| 先乘后除 | 明确整数截断位置 |
+32
View File
@@ -0,0 +1,32 @@
# @knowledge 库存示例
## @exec 检查库存并累计可用量
只在仓库启用时统计库存;对每个未统计条目进行累计。
位置从零下标开始,返回最小计量单位的总量。
`params(仓库启用: Bool, 数量列表: List)`
**总量 = 0**
**位置 = 0**
1. `if 仓库启用`:仅在启用状态下统计库存。
- `while 位置 < 长度(数量列表)`:按位置依次统计,到达列表末尾时终止。
**总量 = 总量 + 数量列表[位置]**
**位置 = 位置 + 1**
`end`
2. `else`:仓库未启用时,总量保持为零。
不执行任何库存统计。
`end`
返回累计总量;本函数不会修改库存来源。
*return 总量*
+30
View File
@@ -0,0 +1,30 @@
use std::{fs, path::Path};
use comrak::{markdown_to_html, Options};
fn main() {
let manifest = Path::new(env!("CARGO_MANIFEST_DIR"));
let fixtures = [
("examples/good/branches.mq.md", "examples/rendered/branches.html"),
("examples/bad/branch-single-item.mq.md", "examples/rendered/branch-single-item.html"),
("examples/nested/inventory.mq.md", "examples/rendered/inventory.html"),
("examples/knowledge/discount.mq.md", "examples/rendered/discount.html"),
];
let mut options = Options::default();
options.extension.table = true;
options.extension.strikethrough = true;
options.extension.tasklist = true;
options.extension.math_dollars = true;
options.extension.math_dollars_block = true;
options.extension.front_matter_delimiter = Some("---".to_string());
for (source, target) in fixtures {
let source_path = manifest.join(source);
let markdown = fs::read_to_string(&source_path).expect("读取渲染 Fixture");
let body = markdown_to_html(&markdown, &options);
let html = format!("<!doctype html>\n<html lang=\"zh-CN\">\n<meta charset=\"utf-8\">\n<title>Marqdo Lint Review Fixture</title>\n<body>\n{body}</body>\n</html>\n");
let target = manifest.join(target);
fs::create_dir_all(target.parent().expect("Fixture 父目录")).expect("创建渲染目录");
fs::write(target, html).expect("写入渲染 Fixture");
}
}
+23
View File
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>Marqdo Lint Review Fixture</title>
<body>
<h1>@knowledge 反例</h1>
<h2>@exec 计算会员价格</h2>
<p>根据用户的会员身份计算最终支付金额。</p>
<p><code>params(原价: Int, 是否会员: Bool)</code></p>
<ol>
<li>
<p>首先判断用户是否有会员资格。</p>
<p><code>if 是否会员</code></p>
<p><strong>最终价格 = 原价 * 9 // 10</strong></p>
<p><code>else</code></p>
<p><strong>最终价格 = 原价</strong></p>
<p><code>end</code></p>
</li>
</ol>
<p>返回最终应付金额。</p>
<p><em>return 最终价格</em></p>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>Marqdo Lint Review Fixture</title>
<body>
<h1>@knowledge 定价示例</h1>
<h2>@exec 计算会员价格</h2>
<p>根据用户的会员身份计算最终支付金额。会员享受九折优惠,
非会员维持原价。采用整数运算,避免金额处理中的浮点误差。</p>
<p><code>params(原价: Int, 是否会员: Bool)</code></p>
<ol>
<li>
<p><code>if 是否会员</code>:会员享受九折优惠。</p>
<p>为保持金额计算的确定性,先乘以九,再进行整数除法。</p>
<p><strong>最终价格 = 原价 * 9 // 10</strong></p>
</li>
<li>
<p><code>else</code>:其余用户保留原价。</p>
<p><strong>最终价格 = 原价</strong></p>
</li>
</ol>
<p><code>end</code></p>
<p>计算结束后返回以最小货币单位表示的最终应付金额。</p>
<p><em>return 最终价格</em></p>
</body>
</html>
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>Marqdo Lint Review Fixture</title>
<body>
<h1>@knowledge 定价文档</h1>
<h2>@exec 计算折后价格</h2>
<p>按<a href="#%E6%8A%98%E6%89%A3%E8%AE%BE%E8%AE%A1">折扣设计</a>计算金额。输入和输出都使用最小货币单位。</p>
<p><code>params(原价: Int, 分子: Int, 分母: Int)</code></p>
<p>先乘后除可以保持整数计算的确定性;调用者必须提供非零分母。</p>
<p><strong>折后价格 = 原价 * 分子 // 分母</strong></p>
<p>返回整数折后价格,除法向下截断。</p>
<p><em>return 折后价格</em></p>
<h2>@knowledge 折扣设计</h2>
<p>这里可以自由使用<strong>加粗</strong>、<em>斜体</em>和 <code>code</code> 解释设计,不会产生执行语句。</p>
<table>
<thead>
<tr>
<th>约束</th>
<th>原因</th>
</tr>
</thead>
<tbody>
<tr>
<td>使用最小货币单位</td>
<td>避免浮点金额误差</td>
</tr>
<tr>
<td>先乘后除</td>
<td>明确整数截断位置</td>
</tr>
</tbody>
</table>
</body>
</html>
+34
View File
@@ -0,0 +1,34 @@
<!doctype html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>Marqdo Lint Review Fixture</title>
<body>
<h1>@knowledge 库存示例</h1>
<h2>@exec 检查库存并累计可用量</h2>
<p>只在仓库启用时统计库存;对每个未统计条目进行累计。
位置从零下标开始,返回最小计量单位的总量。</p>
<p><code>params(仓库启用: Bool, 数量列表: List)</code></p>
<p><strong>总量 = 0</strong></p>
<p><strong>位置 = 0</strong></p>
<ol>
<li>
<p><code>if 仓库启用</code>:仅在启用状态下统计库存。</p>
<ul>
<li>
<p><code>while 位置 &lt; 长度(数量列表)</code>:按位置依次统计,到达列表末尾时终止。</p>
<p><strong>总量 = 总量 + 数量列表[位置]</strong></p>
<p><strong>位置 = 位置 + 1</strong></p>
<p><code>end</code></p>
</li>
</ul>
</li>
<li>
<p><code>else</code>:仓库未启用时,总量保持为零。</p>
<p>不执行任何库存统计。</p>
</li>
</ol>
<p><code>end</code></p>
<p>返回累计总量;本函数不会修改库存来源。</p>
<p><em>return 总量</em></p>
</body>
</html>
+3
View File
@@ -0,0 +1,3 @@
pub mod rules;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
+3
View File
@@ -0,0 +1,3 @@
fn main() {
println!("marqdo-lint {}", marqdo_lint::VERSION);
}
+82
View File
@@ -0,0 +1,82 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Severity {
Info,
Warning,
Error,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum FixSafety {
Manual,
SafeOnly,
NotApplicable,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RuleSpec {
pub id: &'static str,
pub default_severity: Severity,
pub summary: &'static str,
pub reason: &'static str,
pub suggestion: &'static str,
pub evidence: &'static str,
pub fix_safety: FixSafety,
}
macro_rules! rule {
($id:literal, $severity:ident, $summary:literal, $reason:literal, $suggestion:literal, $evidence:literal, $fix:ident) => {
RuleSpec {
id: $id,
default_severity: Severity::$severity,
summary: $summary,
reason: $reason,
suggestion: $suggestion,
evidence: $evidence,
fix_safety: FixSafety::$fix,
}
};
}
pub const CATALOG: &[RuleSpec] = &[
rule!("MQD-DOC-001", Warning, "公开函数缺少入口目的说明", "读者无法在语句开始前确认函数目标。", "在首个执行载体前说明函数做什么及产生什么结果。", "Exec H2 与首个执行载体之间的普通文本节点。", Manual),
rule!("MQD-DOC-002", Info, "缺少结果或异常边界说明", "读者难以确认返回单位、失败结果或不可用情形。", "在返回语句附近说明结果与限制。", "函数末尾 Exec 段的普通叙述和 return 节点。", Manual),
rule!("MQD-DOC-003", Warning, "复杂函数叙述比例低于阈值", "执行载荷缺少必要叙述,阅读负担过高。", "解释关键控制和设计理由,不堆砌空洞文字。", "函数 Exec 段的 N/E 代码点计数及语句规模。", Manual),
rule!("MQD-DOC-004", Info, "长函数章节组织不合适", "长函数缺少业务阶段,或章节过碎影响连续阅读。", "按自然业务阶段组织 H3+ 阅读章节。", "函数语句规模和 Exec H3+ 分段分布。", Manual),
rule!("MQD-BRANCH-001", Warning, "一个编号项包含整段分支", "读者看不到互相对等的分支臂。", "把 if 与 else 分别放入同一有序列表的相邻兄弟项。", "IR Branch 与 AST Item 子树中的 if/else 载体。", Manual),
rule!("MQD-BRANCH-002", Warning, "分支头不在有序列表项开头", "视觉分支与实际执行分支不一致。", "让 if/else 成为对应有序项的首个执行载体。", "IR 控制节点、最近 Item 和项内首个载体。", Manual),
rule!("MQD-BRANCH-003", Warning, "分支臂不属于同一列表的相邻项", "读者无法把条件臂与默认臂作为一组扫描。", "将 if/else 放入同一有序列表的相邻兄弟 Item。", "匹配 Branch 的 if/else 载体及其 List 祖先。", Manual),
rule!("MQD-BRANCH-004", Info, "非平凡分支缺少说明", "条件表达式本身不能解释业务意义。", "在分支项头后说明判断意义和该臂作用。", "分支 Item 中控制载体之外的普通叙述。", Manual),
rule!("MQD-LOOP-001", Warning, "循环头不在无序列表项开头", "读者看不到循环体的视觉边界。", "让 while 成为无序列表项的首个执行载体。", "IR Loop、最近 Item、List ordered 属性及首个载体。", Manual),
rule!("MQD-LOOP-002", Info, "循环缺少处理或终止说明", "读者需要自行推断每轮工作和终止条件。", "在循环项附近说明处理对象与终止方式。", "循环 Item 的普通叙述与 Loop 条件。", Manual),
rule!("MQD-LOOP-003", Warning, "执行嵌套与列表嵌套不一致", "视觉层级会误导实际控制范围。", "按真实 AST 调整嵌套项,使控制体属于对应容器。", "语义控制树与 Markdown Item 祖先链对照。", Manual),
rule!("MQD-CTRL-001", Warning, "end 与控制块视觉边界脱节", "读者难以判断控制块在哪里关闭。", "把分支 end 放在列表后,把循环 end 放在对应循环项末尾。", "唯一匹配的 end 载体及其控制节点和 Item 祖先。", Manual),
rule!("MQD-PROSE-001", Warning, "解释文字混入意外执行载体", "粗体、斜体和行内代码在 Exec 中可能执行而非强调。", "改成普通叙述,或把富文本移到 Knowledge。", "Exec AST 载体、周边叙述及核心载荷诊断。", Manual),
rule!("MQD-PROSE-002", Info, "显式副作用缺少临近说明", "读者无法确认授权、失败情形和后果。", "在副作用载体附近说明效果与约束。", "Analysis 可证明的调用绑定或内存写入及邻近叙述。", Manual),
rule!("MQD-PARAM-001", Info, "公开输入缺少含义或约束", "调用者难以确认参数单位、范围和用途。", "在签名前后解释公开输入。", "显式 params 与相邻普通叙述的确定性覆盖检查。", Manual),
rule!("MQD-STYLE-001", Info, "执行载体不符合推荐视觉约定", "一致的载体风格有助于扫描赋值和返回。", "可为 return 使用斜体、普通赋值使用粗体;不得借此改变语义。", "载体 AST 类型与已确认的语句类型。", Manual),
rule!("MQD-KNOW-001", Warning, "Knowledge/Exec 切分破坏连续阅读", "过度切分会割裂说明,跨段控制则无法正确闭合。", "简单说明留在 Exec;控制块在同一 heading 段闭合。", "heading 模式序列及核心控制边界诊断。", Manual),
rule!("MQD-SAFETY-001", Error, "自动修复无法证明语义等价", "不确定的写回可能改变程序行为。", "拒绝写回并按人工建议修改。", "修复前后规范化 AST、载荷序列和 Analysis 指纹比较。", NotApplicable),
];
pub fn find(id: &str) -> Option<&'static RuleSpec> {
CATALOG.iter().find(|rule| rule.id == id)
}
#[cfg(test)]
mod tests {
use super::*;
use std::collections::BTreeSet;
#[test]
fn catalog_has_stable_unique_ids() {
let ids: BTreeSet<_> = CATALOG.iter().map(|rule| rule.id).collect();
assert_eq!(CATALOG.len(), 18);
assert_eq!(ids.len(), CATALOG.len());
assert!(ids.contains("MQD-BRANCH-001"));
assert!(ids.contains("MQD-SAFETY-001"));
}
}