Skip to content

Commit 2dad0f8

Browse files
committed
docmodel: define HTML options for build output
1 parent 1b50d4f commit 2dad0f8

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

crates/docmodel/src/document.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,18 @@ impl Document {
178178

179179
let mut p = self.build_dir.clone();
180180
p.push(&profile.name);
181-
p.push(&profile.name);
182-
p.set_extension(match profile.target_type {
183-
BuildTargetType::Pdf => "pdf",
184-
});
181+
182+
match profile.target_type {
183+
BuildTargetType::Pdf => {
184+
p.push(&profile.name);
185+
p.set_extension("pdf");
186+
}
187+
188+
BuildTargetType::Html => {
189+
p.push("index.html");
190+
}
191+
}
192+
185193
p
186194
}
187195
}
@@ -218,6 +226,9 @@ pub struct OutputProfile {
218226
/// The output target type of a document build.
219227
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
220228
pub enum BuildTargetType {
229+
/// Output a tree of HTML files
230+
Html,
231+
221232
/// Output to the Portable Document Format (PDF).
222233
Pdf,
223234
}
@@ -394,18 +405,21 @@ mod syntax {
394405

395406
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
396407
pub enum BuildTargetType {
408+
Html,
397409
Pdf,
398410
}
399411

400412
impl BuildTargetType {
401413
pub fn from_runtime(rt: &super::BuildTargetType) -> Self {
402414
match rt {
415+
super::BuildTargetType::Html => BuildTargetType::Html,
403416
super::BuildTargetType::Pdf => BuildTargetType::Pdf,
404417
}
405418
}
406419

407420
pub fn to_runtime(self) -> super::BuildTargetType {
408421
match self {
422+
BuildTargetType::Html => super::BuildTargetType::Html,
409423
BuildTargetType::Pdf => super::BuildTargetType::Pdf,
410424
}
411425
}
@@ -417,6 +431,7 @@ mod syntax {
417431
S: Serializer,
418432
{
419433
serializer.serialize_str(match *self {
434+
BuildTargetType::Html => "html",
420435
BuildTargetType::Pdf => "pdf",
421436
})
422437
}
@@ -428,8 +443,14 @@ mod syntax {
428443
{
429444
let s = String::deserialize(deserializer)?;
430445
Ok(match s.as_str() {
446+
"html" => BuildTargetType::Html,
431447
"pdf" => BuildTargetType::Pdf,
432-
other => return Err(<D as Deserializer>::Error::unknown_variant(other, &["pdf"])),
448+
other => {
449+
return Err(<D as Deserializer>::Error::unknown_variant(
450+
other,
451+
&["html", "pdf"],
452+
))
453+
}
433454
})
434455
}
435456
}

0 commit comments

Comments
 (0)