Skip to content

Commit 6a723f5

Browse files
committed
Removed tectonic show metadata
1 parent ab108d3 commit 6a723f5

4 files changed

Lines changed: 18 additions & 190 deletions

File tree

crates/docmodel/src/document.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ pub struct Document {
4949
/// this will be a subdirectory of `src_dir` named `build`.
5050
build_dir: PathBuf,
5151

52-
/// Arbitrary document metadata.
53-
/// This has no effect on tectonic's build process.
54-
/// Rather, allows users to add easily-accessible information to their documents.
55-
///
56-
/// Tectonic's `show metadata` command displays this information.
57-
pub metadata: Option<toml::Value>,
58-
5952
/// The document name. This will be used to name build artifacts and the
6053
/// like, and so should be relatively filesystem-friendly. It does not
6154
/// need to be the same as the document title.
@@ -110,7 +103,6 @@ impl Document {
110103
build_dir: build_dir.into(),
111104
name: doc.doc.name,
112105
bundle_loc: doc.doc.bundle,
113-
metadata: doc.doc.metadata,
114106
outputs,
115107
})
116108
}
@@ -132,7 +124,7 @@ impl Document {
132124
doc: syntax::DocSection {
133125
name: self.name.clone(),
134126
bundle: self.bundle_loc.clone(),
135-
metadata: None,
127+
metadata: serde::de::IgnoredAny{},
136128
},
137129
outputs,
138130
};
@@ -297,7 +289,6 @@ impl Document {
297289
name,
298290
bundle_loc,
299291
outputs: crate::document::default_outputs(),
300-
metadata: None,
301292
})
302293
}
303294
}
@@ -339,7 +330,9 @@ mod syntax {
339330
pub struct DocSection {
340331
pub name: String,
341332
pub bundle: String,
342-
pub metadata: Option<toml::Value>,
333+
334+
#[serde(skip_serializing)]
335+
pub metadata: serde::de::IgnoredAny,
343336
}
344337

345338
#[derive(Debug, Deserialize, Serialize)]

docs/src/ref/tectonic-toml.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ the file are detailed below.
1717
name = <string> # the document name
1818
bundle = <url or filesystem path> # the source of the TeX bundle
1919

20+
# The doc.metadata table may contain arbitrary data.
21+
# It does not affect Tectonic in any way.
22+
[doc.metadata]
23+
pubish = false
24+
arr = [1, 2, [6, 7]]
25+
26+
27+
2028
[[output]] # one or more output specifications
2129
name = <string> # the output's name
2230
type = <"pdf"> # the output's type
@@ -50,6 +58,12 @@ or a directory of support files. This mode of operation is discouraged because
5058
it limits reproducibility. URLs with a `file:` protocol are also treated
5159
identically to filesystem paths.
5260

61+
### `doc.metadata`
62+
63+
Arbitrary metadata, not read by Tectonic. This table allows us to
64+
save parameters for external scripts without creating an extra file.
65+
66+
5367
### `output`
5468

5569
A list of dictionaries defining different outputs to be created from the

docs/src/v2cli/show.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/bin/tectonic/v2cli.rs

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -726,23 +726,18 @@ enum ShowCommands {
726726
#[structopt(name = "user-cache-dir")]
727727
/// Print the location of the default per-user cache directory
728728
UserCacheDir(ShowUserCacheDirCommand),
729-
730-
/// Show metadata from the current environment
731-
Metadata(ShowMetadataCommand),
732729
}
733730

734731
impl ShowCommand {
735732
fn customize(&self, cc: &mut CommandCustomizations) {
736733
match &self.command {
737734
ShowCommands::UserCacheDir(c) => c.customize(cc),
738-
ShowCommands::Metadata(c) => c.customize(cc),
739735
}
740736
}
741737

742738
fn execute(self, config: PersistentConfig, status: &mut dyn StatusBackend) -> Result<i32> {
743739
match self.command {
744740
ShowCommands::UserCacheDir(c) => c.execute(config, status),
745-
ShowCommands::Metadata(c) => c.execute(config, status),
746741
}
747742
}
748743
}
@@ -762,111 +757,3 @@ impl ShowUserCacheDirCommand {
762757
Ok(0)
763758
}
764759
}
765-
766-
#[derive(Debug, Eq, PartialEq, StructOpt)]
767-
struct ShowMetadataCommand {
768-
#[structopt(help = "The metadata key to get")]
769-
key: String,
770-
}
771-
772-
773-
fn get_metadata(meta: &toml::Value, mut parts: core::str::Split<&str>) -> Option<String> {
774-
match meta {
775-
toml::Value::String(_)
776-
| toml::Value::Boolean(_)
777-
| toml::Value::Integer(_)
778-
| toml::Value::Float(_)
779-
| toml::Value::Datetime(_) => {
780-
if parts.next().is_some() {
781-
// None of these types may be indexed further
782-
return None;
783-
}
784-
785-
return Some(match meta {
786-
toml::Value::String(s) => s.clone(),
787-
toml::Value::Datetime(d) => format!("{}", d),
788-
_ => format!("{}", meta),
789-
});
790-
}
791-
792-
toml::Value::Array(a) => {
793-
match parts.next() {
794-
None => return None,
795-
Some(s) => {
796-
if s == "len" {
797-
// Magic key to get array length.
798-
// Allows easy iteration.
799-
return Some(format!("{}", a.len()));
800-
} else {
801-
let i: usize = match s.parse() {
802-
Ok(i) => i,
803-
Err(_) => return None,
804-
};
805-
806-
let meta = match a.get(i) {
807-
Some(v) => v,
808-
None => return None,
809-
};
810-
811-
return get_metadata(meta, parts);
812-
}
813-
}
814-
}
815-
}
816-
817-
toml::Value::Table(t) => {
818-
match parts.next() {
819-
None => return None,
820-
Some(s) => {
821-
let meta = match t.get(s) {
822-
Some(v) => v,
823-
None => return None,
824-
};
825-
826-
return get_metadata(meta, parts);
827-
}
828-
}
829-
}
830-
};
831-
}
832-
833-
834-
835-
impl ShowMetadataCommand {
836-
fn customize(&self, cc: &mut CommandCustomizations) {
837-
cc.always_stderr = true;
838-
}
839-
840-
fn execute(self, _config: PersistentConfig, _status: &mut dyn StatusBackend) -> Result<i32> {
841-
// `tectonic show metadata` should be as shell-script-friendly as possible.
842-
// It should either print a value or return an error code, and produce NO OTHER OUTPUT.
843-
//
844-
// We return code 1 if `key` doesn't exist
845-
// We return code 2 if we can't open a workspace.
846-
847-
let meta = match Workspace::open_from_environment() {
848-
Ok(ws) => {
849-
let doc = ws.first_document();
850-
let meta = doc.metadata.clone();
851-
if meta.is_none() {
852-
return Ok(1);
853-
}
854-
meta.unwrap()
855-
}
856-
857-
Err(_) => {
858-
return Ok(2);
859-
}
860-
};
861-
862-
let parts = self.key.split(".");
863-
864-
let meta = get_metadata(&meta, parts);
865-
if meta.is_none() {
866-
return Ok(1);
867-
}
868-
869-
println!("{}", meta.unwrap());
870-
Ok(0)
871-
}
872-
}

0 commit comments

Comments
 (0)