mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Auto merge of #12048 - weihanglo:mdman, r=epage
chore: move build-man workflow away from shell
This commit is contained in:
commit
393ce5b416
@ -1,3 +1,4 @@
|
||||
[alias]
|
||||
unpublished = "run --package xtask-unpublished --"
|
||||
build-man = "run --package xtask-build-man --"
|
||||
stale-label = "run --package xtask-stale-label --"
|
||||
unpublished = "run --package xtask-unpublished --"
|
||||
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -3712,6 +3712,10 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xtask-build-man"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "xtask-stale-label"
|
||||
version = "0.0.0"
|
||||
|
@ -3,24 +3,25 @@
|
||||
|
||||
set -e
|
||||
|
||||
cd src/doc
|
||||
cargo_man="src/doc"
|
||||
mdman_man="crates/mdman/doc"
|
||||
|
||||
changes=$(git status --porcelain -- .)
|
||||
changes=$(git status --porcelain -- $cargo_man $mdman_man)
|
||||
if [ -n "$changes" ]
|
||||
then
|
||||
echo "git directory must be clean before running this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./build-man.sh
|
||||
cargo build-man
|
||||
|
||||
changes=$(git status --porcelain -- .)
|
||||
changes=$(git status --porcelain -- $cargo_man $mdman_man)
|
||||
if [ -n "$changes" ]
|
||||
then
|
||||
echo "Detected changes of man pages in src/doc:"
|
||||
echo "Detected changes of man pages:"
|
||||
echo "$changes"
|
||||
echo
|
||||
echo "Please run './build-man.sh' in the src/doc directory to rebuild the"
|
||||
echo "man pages, and commit the changes."
|
||||
echo 'Please run `cargo build-man` to rebuild the man pages'
|
||||
echo "and commit the changes."
|
||||
exit 1
|
||||
fi
|
||||
|
459
crates/mdman/Cargo.lock
generated
459
crates/mdman/Cargo.lock
generated
@ -1,459 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"byte-tools",
|
||||
"byteorder",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39858aa5bac06462d4dd4b9164848eb81ffc4aa5c479746393598fd193afa227"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86dbc8a0746b08f363d2e00da48e6c9ceb75c198ac692d2715fcbb5bee74c87d"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"quick-error",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplit"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
|
||||
[[package]]
|
||||
name = "mdman"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"handlebars",
|
||||
"pretty_assertions",
|
||||
"pulldown-cmark",
|
||||
"same-file",
|
||||
"serde_json",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "output_vt100"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
||||
dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
|
||||
dependencies = [
|
||||
"maplit",
|
||||
"pest",
|
||||
"sha-1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pretty_assertions"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
|
||||
dependencies = [
|
||||
"ctor",
|
||||
"diff",
|
||||
"output_vt100",
|
||||
"yansi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"memchr",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[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.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest",
|
||||
"fake-simd",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||
dependencies = [
|
||||
"matches",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"matches",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cargo run -- -t md -o doc/out doc/*.md
|
||||
cargo run -- -t txt -o doc/out doc/*.md
|
||||
cargo run -- -t man -o doc/out doc/*.md
|
@ -6,7 +6,7 @@
|
||||
.SH "NAME"
|
||||
mdman \- Converts markdown to a man page
|
||||
.SH "SYNOPSIS"
|
||||
\fBmdman\fR [\fIoptions\fR] \fB\-t\fR \fItype\fR \fB\-o\fR \fIoutdir\fR \fIsources...\fR
|
||||
\fBmdman\fR [\fIoptions\fR] \fB\-t\fR \fItype\fR \fB\-o\fR \fIoutdir\fR \fIsources\[u2026]\fR
|
||||
.SH "DESCRIPTION"
|
||||
Converts a markdown file to a man page.
|
||||
.sp
|
||||
@ -83,7 +83,7 @@ Outputs with the \fB\&.md\fR extension.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+02'\fBtxt\fR \[em] A text file, rendered for situations where a man page viewer isn't
|
||||
\h'-04'\(bu\h'+02'\fBtxt\fR \[em] A text file, rendered for situations where a man page viewer isn\[cq]t
|
||||
available. Outputs with the \fB\&.txt\fR extension.
|
||||
.RE
|
||||
.RE
|
||||
@ -107,7 +107,7 @@ matching \fB\-\-man\fR entry, then a relative link to a file named \fIname\fR\fB
|
||||
be used.
|
||||
.RE
|
||||
.sp
|
||||
\fIsources...\fR
|
||||
\fIsources\[u2026]\fR
|
||||
.RS 4
|
||||
The source input filename, may be specified multiple times.
|
||||
.RE
|
||||
|
@ -61,7 +61,7 @@ man page:
|
||||
<code>.1</code>) matching the man page section.</li>
|
||||
<li><code>md</code> — A markdown file, after all handlebars processing has been finished.
|
||||
Outputs with the <code>.md</code> extension.</li>
|
||||
<li><code>txt</code> — A text file, rendered for situations where a man page viewer isn't
|
||||
<li><code>txt</code> — A text file, rendered for situations where a man page viewer isn’t
|
||||
available. Outputs with the <code>.txt</code> extension.</li>
|
||||
</ul></dd>
|
||||
|
||||
@ -82,7 +82,7 @@ matching <code>--man</code> entry, then a relative link to a file named <em>name
|
||||
be used.</dd>
|
||||
|
||||
|
||||
<dt class="option-term" id="option-mdman-sources..."><a class="option-anchor" href="#option-mdman-sources..."></a><em>sources...</em></dt>
|
||||
<dt class="option-term" id="option-mdman-sources…"><a class="option-anchor" href="#option-mdman-sources…"></a><em>sources…</em></dt>
|
||||
<dd class="option-desc">The source input filename, may be specified multiple times.</dd>
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ NAME
|
||||
mdman - Converts markdown to a man page
|
||||
|
||||
SYNOPSIS
|
||||
mdman [options] -t type -o outdir sources...
|
||||
mdman [options] -t type -o outdir sources…
|
||||
|
||||
DESCRIPTION
|
||||
Converts a markdown file to a man page.
|
||||
@ -65,7 +65,7 @@ OPTIONS
|
||||
finished. Outputs with the .md extension.
|
||||
|
||||
o txt — A text file, rendered for situations where a man page
|
||||
viewer isn't available. Outputs with the .txt extension.
|
||||
viewer isn’t available. Outputs with the .txt extension.
|
||||
|
||||
-o outdir
|
||||
Specifies the directory where to save the output.
|
||||
@ -81,7 +81,7 @@ OPTIONS
|
||||
does not have a matching --man entry, then a relative link to a file
|
||||
named name.md will be used.
|
||||
|
||||
sources...
|
||||
sources…
|
||||
The source input filename, may be specified multiple times.
|
||||
|
||||
EXAMPLES
|
||||
|
7
crates/xtask-build-man/Cargo.toml
Normal file
7
crates/xtask-build-man/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "xtask-build-man"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
108
crates/xtask-build-man/src/main.rs
Normal file
108
crates/xtask-build-man/src/main.rs
Normal file
@ -0,0 +1,108 @@
|
||||
//! ```text
|
||||
//! NAME
|
||||
//! build-man
|
||||
//!
|
||||
//! SYNOPSIS
|
||||
//! build-man
|
||||
//!
|
||||
//! DESCRIPTION
|
||||
//! Build the man pages for packages `mdman` and `cargo`.
|
||||
//! For more, read their doc comments.
|
||||
//! ```
|
||||
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
build_mdman()?;
|
||||
build_cargo()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Builds the man pages for `mdman`.
|
||||
fn build_mdman() -> io::Result<()> {
|
||||
cwd_to_workspace_root()?;
|
||||
|
||||
let src_paths = &["crates/mdman/doc/mdman.md".into()];
|
||||
let dst_path = "crates/mdman/doc/out";
|
||||
let outs = [("md", dst_path), ("txt", dst_path), ("man", dst_path)];
|
||||
|
||||
build_man("mdman", src_paths, &outs, &[])
|
||||
}
|
||||
|
||||
/// Builds the man pages for Cargo.
|
||||
///
|
||||
/// The source for the man pages are located in src/doc/man/ in markdown format.
|
||||
/// These also are handlebars templates, see crates/mdman/README.md for details.
|
||||
///
|
||||
/// The generated man pages are placed in the src/etc/man/ directory. The pages
|
||||
/// are also expanded into markdown (after being expanded by handlebars) and
|
||||
/// saved in the src/doc/src/commands/ directory. These are included in the
|
||||
/// Cargo book, which is converted to HTML by mdbook.
|
||||
fn build_cargo() -> io::Result<()> {
|
||||
// Find all `src/doc/man/cargo-*.md`
|
||||
let src_paths = {
|
||||
let mut src_paths = Vec::new();
|
||||
for entry in fs::read_dir("src/doc/man")? {
|
||||
let entry = entry?;
|
||||
let file_name = entry.file_name();
|
||||
let file_name = file_name.to_str().unwrap();
|
||||
if file_name.starts_with("cargo-") && file_name.ends_with(".md") {
|
||||
src_paths.push(entry.path());
|
||||
}
|
||||
}
|
||||
src_paths
|
||||
};
|
||||
let outs = [
|
||||
("md", "src/doc/src/commands"),
|
||||
("txt", "src/doc/man/generated_txt"),
|
||||
("man", "src/etc/man"),
|
||||
];
|
||||
let args = [
|
||||
"--url",
|
||||
"https://doc.rust-lang.org/cargo/commands/",
|
||||
"--man",
|
||||
"rustc:1=https://doc.rust-lang.org/rustc/index.html",
|
||||
"--man",
|
||||
"rustdoc:1=https://doc.rust-lang.org/rustdoc/index.html",
|
||||
];
|
||||
build_man("cargo", &src_paths[..], &outs, &args)
|
||||
}
|
||||
|
||||
/// Change to workspace root.
|
||||
///
|
||||
/// Assumed this xtask is located in `[WORKSPACE]/crates/xtask-build-man`.
|
||||
fn cwd_to_workspace_root() -> io::Result<()> {
|
||||
let pkg_root = std::env!("CARGO_MANIFEST_DIR");
|
||||
let ws_root = format!("{pkg_root}/../..");
|
||||
std::env::set_current_dir(ws_root)
|
||||
}
|
||||
|
||||
/// Builds the man pages.
|
||||
fn build_man(
|
||||
pkg_name: &str,
|
||||
src_paths: &[PathBuf],
|
||||
outs: &[(&str, &str)],
|
||||
extra_args: &[&str],
|
||||
) -> io::Result<()> {
|
||||
for (format, dst_path) in outs {
|
||||
eprintln!("Start converting `{format}` for package `{pkg_name}`...");
|
||||
let mut cmd = Command::new(std::env!("CARGO"));
|
||||
cmd.args(["run", "--package", "mdman", "--"])
|
||||
.args(["-t", format, "-o", dst_path])
|
||||
.args(src_paths)
|
||||
.args(extra_args);
|
||||
|
||||
let status = cmd.status()?;
|
||||
if !status.success() {
|
||||
eprintln!("failed to build the man pages for package `{pkg_name}`");
|
||||
eprintln!("failed command: `{cmd:?}`");
|
||||
process::exit(status.code().unwrap_or(1));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
@ -50,11 +50,7 @@ directory) to three different formats:
|
||||
3. Plain text (needed for embedded man pages on platforms without man such as
|
||||
Windows), saved in [`src/doc/man/generated_txt/`](man/generated_txt).
|
||||
|
||||
To rebuild the man pages, run the script `build-man.sh` in the `src/doc` directory.
|
||||
|
||||
```console
|
||||
$ ./build-man.sh
|
||||
```
|
||||
To rebuild the man pages, run `cargo build-man` inside the workspace.
|
||||
|
||||
### SemVer chapter tests
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script builds the Cargo man pages.
|
||||
#
|
||||
# The source for the man pages are located in src/doc/man/ in markdown format.
|
||||
# These also are handlebars templates, see crates/mdman/README.md for details.
|
||||
#
|
||||
# The generated man pages are placed in the src/etc/man/ directory. The pages
|
||||
# are also expanded into markdown (after being expanded by handlebars) and
|
||||
# saved in the src/doc/src/commands/ directory. These are included in the
|
||||
# Cargo book, which is converted to HTML by mdbook.
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
OPTIONS="--url https://doc.rust-lang.org/cargo/commands/ \
|
||||
--man rustc:1=https://doc.rust-lang.org/rustc/index.html \
|
||||
--man rustdoc:1=https://doc.rust-lang.org/rustdoc/index.html"
|
||||
|
||||
cargo run -p mdman -- \
|
||||
-t md -o src/commands man/cargo*.md \
|
||||
$OPTIONS
|
||||
|
||||
cargo run -p mdman -- \
|
||||
-t txt -o man/generated_txt man/cargo*.md \
|
||||
$OPTIONS
|
||||
|
||||
cargo run -p mdman -- \
|
||||
-t man -o ../etc/man man/cargo*.md \
|
||||
$OPTIONS
|
Loading…
x
Reference in New Issue
Block a user