From 1b442ebf7fde0be1634e756f812c7e53fb87d930 Mon Sep 17 00:00:00 2001 From: Vytautas Stankevicius Date: Mon, 18 Dec 2023 13:34:10 +0200 Subject: [PATCH] Create mdbook-open-gh-issue from mdbook-open-on-gh --- .github/workflows/deploy.yml | 2 +- Cargo.lock | 36 +++++++++------ Cargo.toml | 17 ++++--- README.md | 34 +++++++------- ...-open-on-gh.rs => mdbook-open-gh-issue.rs} | 32 +++++++------ src/lib.rs | 46 +++++++++++-------- 6 files changed, 95 insertions(+), 72 deletions(-) rename src/bin/{mdbook-open-on-gh.rs => mdbook-open-gh-issue.rs} (54%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aa7ecf3..f69f852 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,7 +7,7 @@ on: - "*" env: - CRATE_NAME: mdbook-open-on-gh + CRATE_NAME: mdbook-open-gh-issue jobs: # Build sources for every OS diff --git a/Cargo.lock b/Cargo.lock index 015d275..4f38cc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "14c3242926edf34aec4ac3a77108ad4854bffaa2e4ddc1824124ce59231302d5" dependencies = [ "cfg-if", "crossbeam-utils", @@ -282,9 +282,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -293,22 +293,21 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" dependencies = [ "cfg-if", ] @@ -888,13 +887,14 @@ dependencies = [ ] [[package]] -name = "mdbook-open-on-gh" -version = "2.4.2" +name = "mdbook-open-gh-issue" +version = "0.1.0" dependencies = [ "clap", "env_logger", "log", "mdbook", + "semver", "serde_json", "toml", ] @@ -1355,6 +1355,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + [[package]] name = "serde" version = "1.0.193" @@ -1566,18 +1572,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 1747fee..66afc73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,17 +1,22 @@ [package] -name = "mdbook-open-on-gh" -version = "2.4.2" -authors = ["Jan-Erik Rediger "] +name = "mdbook-open-gh-issue" +version = "0.1.0" +authors = ["Vytautas Stankevičius "] description = "mdbook preprocessor to add a open-on-github link on every page" license = "MPL-2.0" -homepage = "https://github.com/badboy/mdbook-open-on-gh" -repository = "https://github.com/badboy/mdbook-open-on-gh" +homepage = "https://github.com/vytstank/mdbook-open-gh-issue" +repository = "https://github.com/vytstank/mdbook-open-gh-issue" +documentation = "https://github.com/slowsage/mdbook-pagetoc" +readme = "README.md" +keywords = ["mdbook"] +exclude = [".github/"] edition = "2018" [dependencies] mdbook = "0.4.36" -env_logger = "0.10.0" +env_logger = "0.10" log = "0.4" clap = { version = "4.1.0", features = ["cargo"] } serde_json = "1.0" toml = "0.5.11" +semver = "1.0.20" diff --git a/README.md b/README.md index d73152a..5438610 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# mdbook-open-on-gh +# mdbook-open-gh-issue -A preprocessor for [mdbook][] to add a open-on-github link on every page. +A preprocessor for [mdbook][] to add a "open github issue link" on every page. [mdbook]: https://github.com/rust-lang/mdBook -It adds an "Edit this file on GitHub" link on the bottom of every page, linking directly to the source file. +It adds an "Open issue on GitHub for this file" link on the bottom of every page, linking directly to the source file. It uses the configured `git-repository-url` as the base. ## Installation @@ -12,43 +12,43 @@ It uses the configured `git-repository-url` as the base. If you want to use only this preprocessor, install the tool: ``` -cargo install mdbook-open-on-gh +cargo install mdbook-open-gh-issue ``` Add it as a preprocessor to your `book.toml`: ``` -[preprocessor.open-on-gh] -command = "mdbook-open-on-gh" +[preprocessor.open-gh-issue] +command = "mdbook-open-gh-issue" renderer = ["html"] ``` ## Configuration -`mdbook-open-on-gh` is configured using additional options under `[output.html]`: - +`mdbook-open-gh-issue` is configured using additional options under `[output.html]`: ```toml [output.html] # Required: Your repository URL used in the link. git-repository-url = "https://github.com/$user/$project" -# Your git branch. Defaults to `main` -git-branch = "main" - # The text to use in the footer. # The link text is marked by `[]` -open-on-text = "Found a bug? [Edit this page on GitHub.]" +gh-issue-text = "Outdated info? [Open issue on GitHub.]" + +# The issue template to use. Defaults to "issue-template.yaml" +# New issue will get "file" parameter set to the current page. +gh-issue-template = "issue-template.yaml" ``` To style the footer add a custom CSS file for your HTML output: ```toml [output.html] -additional-css = ["open-in.css"] +additional-css = ["gh-issue-open.css"] ``` -And in `open-in.css` style the `