test: Move codegen to tests

This commit is contained in:
Ed Page 2022-08-01 14:45:58 -05:00
parent ec1ef6a78c
commit a8599f6a19
29 changed files with 283 additions and 714 deletions

View file

@ -1,56 +0,0 @@
name: codegen
on:
pull_request:
paths:
- 'Cargo.lock'
- '**/assets/**'
- '**/codegen/**'
- '**/verify/**'
- '**/*codegen.rs'
push:
branches:
- master
paths:
- 'Cargo.lock'
- '**/assets/**'
- '**/codegen/**'
- '**/verify/**'
- '**/*codegen.rs'
schedule:
- cron: '9 9 9 * *'
jobs:
codegen:
name: Verify Code-gen
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.59.0 # MSRV
profile: minimal
override: true
components: rustfmt
- uses: Swatinem/rust-cache@v1
- name: Verify typos-dict
run: |
cargo run --package typos-dict-codegen -- --output crates/typos-dict/src/dict_codegen.rs --check
- name: Verify typos-vars
run: |
cargo run --package typos-vars-codegen -- --output crates/typos-vars/src/vars_codegen.rs --check
- name: Verify typos-dict-verify
run: |
cargo run --package typos-dict-verify -- --input crates/typos-dict/assets/words.csv --output crates/typos-dict/assets/words.csv --check
- name: Verify codespell-dict
run: |
cargo run --package codespell-codegen -- --output crates/codespell-dict/src/dict_codegen.rs --check
- name: Verify misspell-dict
run: |
cargo run --package misspell-codegen -- --output crates/misspell-dict/src/dict_codegen.rs --check
- name: Verify wikipedia-dict
run: |
cargo run --package wikipedia-codegen -- --output crates/wikipedia-dict/src/dict_codegen.rs --check
- name: Verify varcon-dict
run: |
cargo run --package varcon-codegen -- --output crates/varcon/src/codegen.rs --check

246
Cargo.lock generated
View file

@ -39,9 +39,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.58"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
checksum = "c91f1f46651137be86f3a2b9a8359f9ab421d04d941c62b5982e1ca21113adf9"
[[package]]
name = "assert_fs"
@ -76,9 +76,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.65"
version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
dependencies = [
"addr2line",
"cc",
@ -115,18 +115,15 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
[[package]]
name = "bytes"
version = "1.1.0"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
[[package]]
name = "cast"
version = "0.2.7"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a"
dependencies = [
"rustc_version",
]
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
@ -168,16 +165,6 @@ dependencies = [
"textwrap 0.15.0",
]
[[package]]
name = "clap-verbosity-flag"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2474445ef3370e4844f9082eef2f80e4abaf7d985781afd78b89b58e2f69a14"
dependencies = [
"clap 3.2.16",
"log",
]
[[package]]
name = "clap-verbosity-flag"
version = "1.0.1"
@ -222,22 +209,14 @@ dependencies = [
"normalize-line-endings",
]
[[package]]
name = "codespell-codegen"
version = "0.4.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"dictgen",
"itertools",
"unicase",
]
[[package]]
name = "codespell-dict"
version = "0.4.0"
dependencies = [
"codegenrs",
"dictgen",
"itertools",
"snapbox",
"unicase",
]
@ -295,9 +274,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "criterion"
version = "0.3.5"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
dependencies = [
"atty",
"cast",
@ -321,9 +300,9 @@ dependencies = [
[[package]]
name = "criterion-plot"
version = "0.4.4"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57"
checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876"
dependencies = [
"cast",
"itertools",
@ -331,9 +310,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.5"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
dependencies = [
"cfg-if",
"crossbeam-utils",
@ -341,9 +320,9 @@ dependencies = [
[[package]]
name = "crossbeam-deque"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
dependencies = [
"cfg-if",
"crossbeam-epoch",
@ -352,9 +331,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
version = "0.9.9"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"
checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
dependencies = [
"autocfg",
"cfg-if",
@ -366,9 +345,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.10"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
dependencies = [
"cfg-if",
"once_cell",
@ -592,18 +571,15 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "fastrand"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [
"instant",
]
@ -639,9 +615,9 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.26.1"
version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
[[package]]
name = "glob"
@ -681,9 +657,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
[[package]]
name = "hashbrown"
version = "0.12.1"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "heck"
@ -797,9 +773,9 @@ checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
[[package]]
name = "js-sys"
version = "0.3.58"
version = "0.3.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27"
checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
dependencies = [
"wasm-bindgen",
]
@ -871,24 +847,16 @@ dependencies = [
"adler",
]
[[package]]
name = "misspell-codegen"
version = "0.4.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"dictgen",
"itertools",
"regex",
"unicase",
]
[[package]]
name = "misspell-dict"
version = "0.4.0"
dependencies = [
"codegenrs",
"dictgen",
"itertools",
"log",
"regex",
"snapbox",
"unicase",
]
@ -929,9 +897,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.28.4"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [
"memchr",
]
@ -960,9 +928,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "6.1.0"
version = "6.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
[[package]]
name = "os_type"
@ -1014,9 +982,9 @@ dependencies = [
[[package]]
name = "plotters"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a"
checksum = "9428003b84df1496fb9d6eeee9c5f8145cb41ca375eb0dad204328888832811f"
dependencies = [
"num-traits",
"plotters-backend",
@ -1027,15 +995,15 @@ dependencies = [
[[package]]
name = "plotters-backend"
version = "0.3.2"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c"
checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
[[package]]
name = "plotters-svg"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9"
checksum = "e0918736323d1baff32ee0eade54984f6f201ad7e97d5cfb5d6ab4a358529615"
dependencies = [
"plotters-backend",
]
@ -1105,9 +1073,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.40"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b"
dependencies = [
"unicode-ident",
]
@ -1177,9 +1145,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.2.13"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
]
@ -1260,9 +1228,9 @@ checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
[[package]]
name = "serde"
version = "1.0.140"
version = "1.0.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500"
dependencies = [
"serde_derive",
]
@ -1279,9 +1247,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.140"
version = "1.0.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f"
dependencies = [
"proc-macro2",
"quote",
@ -1313,9 +1281,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
[[package]]
name = "similar"
version = "2.1.0"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3"
checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803"
[[package]]
name = "siphasher"
@ -1325,9 +1293,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "snapbox"
version = "0.2.10"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "767a1d5da232b6959cd1bd5c9e8db8a7cce09c3038e89deedb49a549a2aefd93"
checksum = "dc9f6603988128836d0ed032a28fac5fb049958e21578e9aed2ed05f69bb562a"
dependencies = [
"concolor",
"content_inspector",
@ -1345,9 +1313,9 @@ dependencies = [
[[package]]
name = "snapbox-macros"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c01dea7e04cbb27ef4c86e9922184608185f7cd95c1763bc30d727cda4a5e930"
checksum = "8a253e6f894cfa440cba00600a249fa90869d8e0ec45ab274a456e043a0ce8f2"
[[package]]
name = "static_assertions"
@ -1484,9 +1452,9 @@ dependencies = [
[[package]]
name = "trycmd"
version = "0.13.4"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4185126cc904642173a54c185083f410c86d1202ada6761aacf7c40829f13"
checksum = "62a09d4fff814904dc04bf60dc19fd7ed41715e3e00dd423eb1c5636a942e2a4"
dependencies = [
"glob",
"humantime",
@ -1531,7 +1499,7 @@ dependencies = [
"atty",
"bstr",
"clap 3.2.16",
"clap-verbosity-flag 1.0.1",
"clap-verbosity-flag",
"concolor",
"concolor-clap",
"content_inspector",
@ -1571,32 +1539,13 @@ dependencies = [
name = "typos-dict"
version = "0.8.4"
dependencies = [
"dictgen",
"log",
"unicase",
]
[[package]]
name = "typos-dict-codegen"
version = "1.3.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"csv",
"dictgen",
"itertools",
"unicase",
]
[[package]]
name = "typos-dict-verify"
version = "1.3.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"csv",
"edit-distance",
"itertools",
"log",
"snapbox",
"unicase",
"varcon",
]
@ -1605,23 +1554,11 @@ dependencies = [
name = "typos-vars"
version = "0.8.2"
dependencies = [
"dictgen",
"log",
"unicase",
"varcon-core",
]
[[package]]
name = "typos-vars-codegen"
version = "1.3.0"
dependencies = [
"clap 3.2.16",
"clap-verbosity-flag 0.4.1",
"codegenrs",
"dictgen",
"env_logger",
"itertools",
"log",
"snapbox",
"typos",
"unicase",
"varcon",
@ -1680,9 +1617,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
[[package]]
name = "unicode-segmentation"
@ -1715,15 +1652,8 @@ dependencies = [
name = "varcon"
version = "0.6.2"
dependencies = [
"varcon-core",
]
[[package]]
name = "varcon-codegen"
version = "1.3.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"snapbox",
"varcon-core",
]
@ -1769,9 +1699,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@ -1779,13 +1709,13 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a"
checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
@ -1794,9 +1724,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa"
checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -1804,9 +1734,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048"
checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
dependencies = [
"proc-macro2",
"quote",
@ -1817,36 +1747,28 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be"
checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
[[package]]
name = "web-sys"
version = "0.3.58"
version = "0.3.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90"
checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "wikipedia-codegen"
version = "0.4.0"
dependencies = [
"clap 3.2.16",
"codegenrs",
"dictgen",
"itertools",
"unicase",
]
[[package]]
name = "wikipedia-dict"
version = "0.4.0"
dependencies = [
"codegenrs",
"dictgen",
"itertools",
"snapbox",
"unicase",
]

View file

@ -1,13 +1,6 @@
[workspace]
members = [
"crates/typos",
"crates/typos-dict", "crates/typos-dict/codegen", "crates/typos-dict/verify",
"crates/typos-vars", "crates/typos-vars/codegen",
"crates/dictgen",
"crates/codespell-dict", "crates/codespell-dict/codegen",
"crates/misspell-dict", "crates/misspell-dict/codegen",
"crates/wikipedia-dict", "crates/wikipedia-dict/codegen",
"crates/varcon", "crates/varcon/codegen", "crates/varcon-core",
"crates/*",
]
[package]

View file

@ -25,3 +25,10 @@ release = false
[dependencies]
unicase = "2.5"
dictgen = { version = "^0.2", path = "../dictgen" }
snapbox = { version = "0.3.0", features = ["path"] }
[dev-dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
dictgen = { version = "^0.2", path = "../dictgen", features = ["codegen"] }

View file

@ -1,22 +0,0 @@
[package]
name = "codespell-codegen"
version = "0.4.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
dictgen = { version = "^0.2", path = "../../dictgen", features = ["codegen"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by codespell-codegen
// This file is @generated crates/codespell-dict/tests/codegen.rs
pub static WORD_DICTIONARY: dictgen::DictTable<&[&str]> = dictgen::DictTable {
keys: &[

View file

@ -1,6 +1,29 @@
use clap::Parser;
pub const DICT: &str = include_str!("../assets/dictionary.txt");
pub const DICT: &str = include_str!("../../assets/dictionary.txt");
#[test]
fn codegen() {
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::assert_eq_path("./src/dict_codegen.rs", &content);
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(file, "// This file is @generated {}", file!()).unwrap();
writeln!(file).unwrap();
let dict = parse_dict(DICT);
dictgen::generate_table(
file,
"WORD_DICTIONARY",
"&[&str]",
dict.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
fn parse_dict(raw: &str) -> impl Iterator<Item = (&str, Vec<&str>)> {
raw.lines().map(|s| {
@ -22,49 +45,3 @@ fn parse_dict(raw: &str) -> impl Iterator<Item = (&str, Vec<&str>)> {
(typo, corrections)
})
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
)
.unwrap();
writeln!(file).unwrap();
let dict = parse_dict(DICT);
dictgen::generate_table(
file,
"WORD_DICTIONARY",
"&[&str]",
dict.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -26,3 +26,11 @@ release = false
unicase = "2.5"
log = "0.4"
dictgen = { version = "^0.2", path = "../dictgen" }
snapbox = { version = "0.3.0", features = ["path"] }
[dev-dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
regex = "1"
dictgen = { version = "^0.2", path = "../dictgen", features = ["codegen"] }

View file

@ -1,23 +0,0 @@
[package]
name = "misspell-codegen"
version = "0.4.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
regex = "1"
dictgen = { version = "^0.2", path = "../../dictgen", features = ["codegen"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by misspell-codegen
// This file is @generated by crates/misspell-dict/tests/codegen.rs
pub static MAIN_DICTIONARY: dictgen::DictTable<&[&str]> = dictgen::DictTable {
keys: &[

View file

@ -1,8 +1,53 @@
use std::collections::HashMap;
use clap::Parser;
pub const DICT: &str = include_str!("../assets/words.go");
pub const DICT: &str = include_str!("../../assets/words.go");
#[test]
fn codegen() {
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::assert_eq_path("./src/dict_codegen.rs", content);
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(file, "// This file is @generated by {}", file!()).unwrap();
writeln!(file).unwrap();
let Words {
main,
american,
british,
} = parse_dict(DICT);
dictgen::generate_table(
file,
"MAIN_DICTIONARY",
"&[&str]",
main.into_iter().map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
dictgen::generate_table(
file,
"AMERICAN_DICTIONARY",
"&[&str]",
american
.into_iter()
.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
dictgen::generate_table(
file,
"BRITISH_DICTIONARY",
"&[&str]",
british.into_iter().map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
struct Words<'s> {
main: HashMap<&'s str, Vec<&'s str>>,
@ -54,71 +99,3 @@ fn parse_dict(raw: &str) -> Words {
british,
}
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
)
.unwrap();
writeln!(file).unwrap();
let Words {
main,
american,
british,
} = parse_dict(DICT);
dictgen::generate_table(
file,
"MAIN_DICTIONARY",
"&[&str]",
main.into_iter().map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
dictgen::generate_table(
file,
"AMERICAN_DICTIONARY",
"&[&str]",
american
.into_iter()
.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
dictgen::generate_table(
file,
"BRITISH_DICTIONARY",
"&[&str]",
british.into_iter().map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -22,3 +22,13 @@ include = [
unicase = "2.5"
log = "0.4"
dictgen = { version = "^0.2", path = "../dictgen" }
snapbox = { version = "0.3.0", features = ["path"] }
[dev-dependencies]
csv = "1.1"
itertools = "0.10"
edit-distance = "2.1"
unicase = "2.5"
codegenrs = "2.0"
dictgen = { version = "^0.2", path = "../dictgen", features = ["codegen"] }
varcon = { version = "^0.6", path = "../varcon" }

View file

@ -1,23 +0,0 @@
[package]
name = "typos-dict-codegen"
version = "1.3.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../../../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
csv = "1.1"
itertools = "0.10"
unicase = "2.5"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
dictgen = { version = "^0.2", path = "../../dictgen", features = ["codegen"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by typos-dict-codegen
// This file is @generated by crates/typos-dict/tests/codegen.rs
#![allow(clippy::unreadable_literal)]
pub static WORD_TRIE: dictgen::DictTrie<&'static [&'static str]> = dictgen::DictTrie {

View file

@ -1,14 +1,17 @@
use clap::Parser;
const DICT: &[u8] = include_bytes!("../assets/words.csv");
const DICT: &[u8] = include_bytes!("../../assets/words.csv");
#[test]
fn codegen() {
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::assert_eq_path("./src/dict_codegen.rs", content);
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
)
.unwrap();
writeln!(file, "// This file is @generated by {}", file!()).unwrap();
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
writeln!(file).unwrap();
@ -36,29 +39,3 @@ fn generate<W: std::io::Write>(file: &mut W) {
)
.unwrap();
}
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -3,10 +3,20 @@ use std::collections::HashMap;
use std::collections::HashSet;
use unicase::UniCase;
use clap::Parser;
type Dict = BTreeMap<UniCase<String>, Vec<String>>;
#[test]
fn verify() {
let asset_path = "assets/words.csv";
let data = std::fs::read(asset_path).unwrap();
let mut content = vec![];
generate(&mut content, &data);
let content = String::from_utf8(content).unwrap();
snapbox::assert_eq_path(asset_path, content);
}
fn generate<W: std::io::Write>(file: &mut W, dict: &[u8]) {
let mut rows = Dict::new();
csv::ReaderBuilder::new()
@ -127,30 +137,3 @@ fn find_best_match<'c>(
matches.sort_unstable();
matches.into_iter().next().map(|(_, r)| r)
}
#[derive(Debug, Parser)]
struct Options {
#[clap(short('i'), long, parse(from_os_str))]
input: std::path::PathBuf,
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let data = std::fs::read(&options.input).unwrap();
let mut content = vec![];
generate(&mut content, &data);
let content = String::from_utf8(content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -1,24 +0,0 @@
[package]
name = "typos-dict-verify"
version = "1.3.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../../../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
csv = "1.1"
unicase = "2.5"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
varcon = { version = "^0.6", path = "../../varcon" }
itertools = "0.10"
edit-distance = "2.1"

View file

@ -23,3 +23,13 @@ unicase = "2.5"
log = "0.4"
dictgen = { version = "^0.2", path = "../dictgen" }
varcon-core = { version = "^2.0", path = "../varcon-core", features = ["flags"] }
snapbox = { version = "0.3.0", features = ["path"] }
[dev-dependencies]
varcon = { version = "^0.6", path = "../varcon", features = ["flags"] }
varcon-core = { version = "^2.0", path = "../varcon-core", features = ["flags"] }
typos = { version = "^0.10", path = "../typos" }
unicase = "2.5"
codegenrs = "2.0"
itertools = "0.10"
dictgen = { version = "^0.2", path = "../dictgen", features = ["codegen"] }

View file

@ -1,28 +0,0 @@
[package]
name = "typos-vars-codegen"
version = "1.3.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../../../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
varcon = { version = "^0.6", path = "../../varcon", features = ["flags"] }
varcon-core = { version = "^2.0", path = "../../varcon-core", features = ["flags"] }
typos = { version = "^0.10", path = "../../typos" }
unicase = "2.5"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
clap-verbosity-flag = "0.4"
log = "0.4"
env_logger = "0.9"
itertools = "0.10"
dictgen = { version = "^0.2", path = "../../dictgen", features = ["codegen"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by typos-vars-codegen
// This file is @generated by crates/typos-vars/tests/codegen.rs
#![allow(clippy::unreadable_literal, clippy::type_complexity)]
pub type Variants = &'static [&'static str];

View file

@ -2,7 +2,15 @@ use std::collections::BTreeMap;
use std::collections::HashSet;
use std::io::Write;
use clap::Parser;
#[test]
fn codegen() {
let mut content = vec![];
generate_variations(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::assert_eq_path("./src/vars_codegen.rs", content);
}
static CATEGORIES: [varcon::Category; 4] = [
varcon::Category::American,
@ -17,12 +25,7 @@ static CATEGORIES: [varcon::Category; 4] = [
fn generate_variations<W: std::io::Write>(file: &mut W) {
let entries = entries();
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
)
.unwrap();
writeln!(file, "// This file is @generated by {}", file!(),).unwrap();
writeln!(
file,
"#![allow(clippy::unreadable_literal, clippy::type_complexity)]",
@ -272,57 +275,3 @@ fn ignore_variant(variant: &varcon_core::Variant) -> bool {
//
// varcon needs
// all entries by name
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
#[clap(flatten)]
pub(crate) verbose: clap_verbosity_flag::Verbosity,
}
fn init_logging(level: Option<log::Level>) {
if let Some(level) = level {
let mut builder = env_logger::Builder::new();
builder.filter(None, level.to_level_filter());
if level == log::LevelFilter::Trace {
builder.format_timestamp_secs();
} else {
builder.format(|f, record| {
writeln!(
f,
"[{}] {}",
record.level().to_string().to_lowercase(),
record.args()
)
});
}
builder.init();
}
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let mut options = Options::parse();
options.verbose.set_default(Some(log::Level::Info));
init_logging(options.verbose.log_level());
let mut content = vec![];
generate_variations(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -24,4 +24,9 @@ all = ["flags"]
flags = ["varcon-core/flags"]
[dependencies]
snapbox = { version = "0.3.1", features = ["path"] }
varcon-core = { version = "^2.0", path = "../varcon-core" }
[dev-dependencies]
codegenrs = "2.0"
varcon-core = { version = "^2.0", path = "../varcon-core", features = ["parser"] }

View file

@ -1,20 +0,0 @@
[package]
name = "varcon-codegen"
version = "1.3.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../../../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
varcon-core = { version = "^2.0", path = "../../varcon-core", features = ["parser"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by varcon-codegen
// This file is @generated by crates/varcon/tests/codegen.rs
#![allow(clippy::unreadable_literal)]
use crate::*;

View file

@ -1,6 +1,17 @@
use clap::Parser;
const DICT: &[u8] = include_bytes!("../assets/varcon.txt");
const DICT: &[u8] = include_bytes!("../../assets/varcon.txt");
#[test]
fn codegen() {
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::Assert::new()
.normalize_paths(false)
.action_env(snapbox::DEFAULT_ACTION_ENV)
.eq_path("./src/codegen.rs", content);
}
fn generate<W: std::io::Write>(file: &mut W) {
let dict = String::from_utf8_lossy(DICT);
@ -8,8 +19,8 @@ fn generate<W: std::io::Write>(file: &mut W) {
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
"// This file is @generated by {}",
file!().replace('\\', "/")
)
.unwrap();
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
@ -70,29 +81,3 @@ fn generate<W: std::io::Write>(file: &mut W) {
}
writeln!(file, "];").unwrap();
}
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}

View file

@ -25,3 +25,10 @@ release = false
[dependencies]
unicase = "2.5"
dictgen = { version = "^0.2", path = "../dictgen" }
snapbox = { version = "0.3.0", features = ["path"] }
[dev-dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
dictgen = { version = "^0.2", path = "../dictgen", features = ["codegen"] }

View file

@ -1,22 +0,0 @@
[package]
name = "wikipedia-codegen"
version = "0.4.0"
authors = ["Ed Page <eopage@gmail.com>"]
description = "Source Code Spelling Correction"
repository = "https://github.com/crate-ci/typos"
readme = "../README.md"
categories = ["text-processing"]
license = "MIT"
edition = "2021"
rust-version = "1.59.0" # MSRV
publish = false
[package.metadata.release]
release = false
[dependencies]
unicase = "2.5"
itertools = "0.10"
codegenrs = "2.0"
clap = { version = "3.2", features = ["derive"] }
dictgen = { version = "^0.2", path = "../../dictgen", features = ["codegen"] }

View file

@ -1,4 +1,4 @@
// This file is code-genned by wikipedia-codegen
// This file is @generated by crates/wikipedia-dict/tests/codegen.rs
pub static WORD_DICTIONARY: dictgen::DictTable<&[&str]> = dictgen::DictTable {
keys: &[

View file

@ -1,6 +1,29 @@
use clap::Parser;
pub const DICT: &str = include_str!("../assets/dictionary.txt");
pub const DICT: &str = include_str!("../../assets/dictionary.txt");
#[test]
fn codegen() {
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
snapbox::assert_eq_path("./src/dict_codegen.rs", content);
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(file, "// This file is @generated by {}", file!()).unwrap();
writeln!(file).unwrap();
let dict = parse_dict(DICT);
dictgen::generate_table(
file,
"WORD_DICTIONARY",
"&[&str]",
dict.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
fn parse_dict(raw: &str) -> impl Iterator<Item = (&str, Vec<&str>)> {
raw.lines().map(|s| {
@ -22,49 +45,3 @@ fn parse_dict(raw: &str) -> impl Iterator<Item = (&str, Vec<&str>)> {
(typo, corrections)
})
}
fn generate<W: std::io::Write>(file: &mut W) {
writeln!(
file,
"// This file is code-genned by {}",
env!("CARGO_PKG_NAME")
)
.unwrap();
writeln!(file).unwrap();
let dict = parse_dict(DICT);
dictgen::generate_table(
file,
"WORD_DICTIONARY",
"&[&str]",
dict.map(|kv| (kv.0, format!("&{:?}", kv.1))),
)
.unwrap();
}
#[derive(Debug, Parser)]
struct Options {
#[clap(flatten)]
codegen: codegenrs::CodeGenArgs,
#[clap(flatten)]
rustmft: codegenrs::RustfmtArgs,
}
fn run() -> Result<i32, Box<dyn std::error::Error>> {
let options = Options::parse();
let mut content = vec![];
generate(&mut content);
let content = String::from_utf8(content)?;
let content = options.rustmft.reformat(&content)?;
options.codegen.write_str(&content)?;
Ok(0)
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}