update
This commit is contained in:
parent
26ea87b295
commit
cffd853114
|
|
@ -145,6 +145,47 @@ dependencies = [
|
||||||
"strsim",
|
"strsim",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete"
|
||||||
|
version = "4.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete_command"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "183495371ea78d4c9ff638bfc6497d46fed2396e4f9c50aebc1278a4a9919a3d"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
|
"clap_complete_fig",
|
||||||
|
"clap_complete_nushell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete_fig"
|
||||||
|
version = "4.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "54b3e65f91fabdd23cac3d57d39d5d938b4daabd070c335c006dccb866a61110"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete_nushell"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d02bc8b1a18ee47c4d2eec3fb5ac034dc68ebea6125b1509e9ccdffcddce66e"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.4"
|
version = "4.5.4"
|
||||||
|
|
@ -476,6 +517,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete_command",
|
||||||
"crossterm 0.27.0",
|
"crossterm 0.27.0",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"markdown",
|
"markdown",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ default-run = "req"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.83"
|
anyhow = "1.0.83"
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
|
clap_complete_command = "0.5.1"
|
||||||
crossterm = "0.27.0"
|
crossterm = "0.27.0"
|
||||||
indexmap = { version = "2.2.6", features = ["serde"] }
|
indexmap = { version = "2.2.6", features = ["serde"] }
|
||||||
markdown = "1.0.0-alpha.17"
|
markdown = "1.0.0-alpha.17"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ mkdir -p out
|
||||||
cargo build
|
cargo build
|
||||||
cargo run -q -- schema > out/schema.json
|
cargo run -q -- schema > out/schema.json
|
||||||
cargo run -q -- demo > out/demo.yml
|
cargo run -q -- demo > out/demo.yml
|
||||||
cargo run -q -- md req.yml > out/requirements.md
|
cargo run -q -- md requirements.yml > out/requirements.md
|
||||||
cargo run -q -- html req.yml > out/requirements.html
|
cargo run -q -- html requirements.yml > out/requirements.html
|
||||||
cargo run -q -- check req.yml test_result.txt > out/text_result.md
|
cargo run -q -- check requirements.yml test_result.txt > out/text_result.md
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ pub struct Project {
|
||||||
serialize_with = "serialize_version",
|
serialize_with = "serialize_version",
|
||||||
deserialize_with = "deserialize_version"
|
deserialize_with = "deserialize_version"
|
||||||
)]
|
)]
|
||||||
|
#[schemars(with = "String", regex(pattern = r"^\d\.\d\.\d$"))]
|
||||||
pub version: Version,
|
pub version: Version,
|
||||||
#[serde(serialize_with = "my_trim")]
|
#[serde(serialize_with = "my_trim")]
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
|
@ -138,5 +139,5 @@ pub struct Project {
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn demo_project() -> Project {
|
pub fn demo_project() -> Project {
|
||||||
serde_yaml::from_str(include_str!("../req.yml")).expect("Should never happen!")
|
serde_yaml::from_str(include_str!("../requirements.yml")).expect("Should never happen!")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -1,6 +1,6 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::{CommandFactory, Parser, Subcommand};
|
||||||
use indexmap::{
|
use indexmap::{
|
||||||
map::{Keys, Values},
|
map::{Keys, Values},
|
||||||
IndexMap,
|
IndexMap,
|
||||||
|
|
@ -39,7 +39,7 @@ fn check_requirements(
|
||||||
requirements: &IndexMap<String, Requirement>,
|
requirements: &IndexMap<String, Requirement>,
|
||||||
allowed_requirements: &Regex,
|
allowed_requirements: &Regex,
|
||||||
) {
|
) {
|
||||||
for (id, _) in dbg!(requirements) {
|
for (id, _) in requirements {
|
||||||
if allowed_requirements.is_match(id) {
|
if allowed_requirements.is_match(id) {
|
||||||
if test_results.contains(&format!("{}: failed", id.trim())) {
|
if test_results.contains(&format!("{}: failed", id.trim())) {
|
||||||
output.insert(id.trim().to_string(), false);
|
output.insert(id.trim().to_string(), false);
|
||||||
|
|
@ -163,7 +163,7 @@ fn add_topics(output: &mut Vec<String>, topics: &IndexMap<String, Topic>, level:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Subcommand)]
|
||||||
enum Command {
|
enum Command {
|
||||||
/// Outputs the JSON schema for the input data
|
/// Outputs the JSON schema for the input data
|
||||||
Schema,
|
Schema,
|
||||||
|
|
@ -191,6 +191,12 @@ enum Command {
|
||||||
#[arg(required=true, num_args=1..)]
|
#[arg(required=true, num_args=1..)]
|
||||||
test_results: Vec<PathBuf>,
|
test_results: Vec<PathBuf>,
|
||||||
},
|
},
|
||||||
|
/// Generate shell completions
|
||||||
|
Completions {
|
||||||
|
/// The shell to generate the completions for
|
||||||
|
#[arg(value_enum)]
|
||||||
|
shell: clap_complete_command::Shell,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
|
|
@ -295,10 +301,14 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
Command::Html { requirements } => {
|
Command::Html { requirements } => {
|
||||||
let output = to_markdown(requirements, false)?;
|
let output = to_markdown(requirements, false)?;
|
||||||
|
let template = include_str!("../template.html");
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
markdown::to_html_with_options(&output, &markdown::Options::gfm())
|
template.replace(
|
||||||
|
"{{content}}",
|
||||||
|
&markdown::to_html_with_options(&output, &markdown::Options::gfm())
|
||||||
.map_err(|e| anyhow::anyhow!("{e}"))?
|
.map_err(|e| anyhow::anyhow!("{e}"))?
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Command::Schema => {
|
Command::Schema => {
|
||||||
|
|
@ -322,7 +332,11 @@ fn main() -> anyhow::Result<()> {
|
||||||
let output = output.join("\n");
|
let output = output.join("\n");
|
||||||
println!("{output}");
|
println!("{output}");
|
||||||
}
|
}
|
||||||
|
Command::Completions { shell } => {
|
||||||
|
shell.generate(&mut Args::command(), &mut std::io::stdout());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
/* General body styling */
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
|
padding: 20px;
|
||||||
|
max-width: 1000px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Heading styles */
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
color: #0056b3;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
border-bottom: 2px solid #eee;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
color: #004494;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
color: #003073;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
color: #002652;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 1em;
|
||||||
|
/* Ensures that subtopic headings don't scale down too much */
|
||||||
|
font-weight: bold;
|
||||||
|
/* Adds emphasis to make subtopic headings stand out */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RFC keywords styling */
|
||||||
|
p {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong em {
|
||||||
|
color: #d63447;
|
||||||
|
/* Bright red for MUST, SHOULD, etc. */
|
||||||
|
font-style: normal;
|
||||||
|
/* Override italic style from em */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Link styling */
|
||||||
|
a {
|
||||||
|
color: #007bff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List styling for better readability */
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul>li:not(:has(> p))::before {
|
||||||
|
content: "• ";
|
||||||
|
color: #007bff;
|
||||||
|
/* Matching the link color */
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul>li:not(:has(> ul))>p::before {
|
||||||
|
content: "• ";
|
||||||
|
color: #007bff;
|
||||||
|
/* Matching the link color */
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Nested lists to indicate hierarchy */
|
||||||
|
ul ul {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Version and requirements emphasis */
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Special styling for configuration sections */
|
||||||
|
h2 {
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Config and Definitions section styling */
|
||||||
|
ul ul li {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Detailed requirement items */
|
||||||
|
li strong em {
|
||||||
|
display: inline-block;
|
||||||
|
/* Ensures consistent alignment */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{{content}}
|
||||||
|
</body>
|
||||||
Loading…
Reference in New Issue