pub struct Cell { /* private fields */ }Expand description
A table cell.
Use Cell::header for <th>; colspan/rowspan map to the matching HTML attributes.
Cell content is escaped unless you pass SummaryText::html.
§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::header("Name"), Cell::new("value")]]);
assert!(s.stringify().contains(r#"<th colspan="1" rowspan="1">Name</th>"#));Implementations§
Source§impl Cell
impl Cell
Sourcepub fn new(data: impl Into<SummaryText>) -> Self
pub fn new(data: impl Into<SummaryText>) -> Self
A <td> cell.
§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::new("x")]]);
assert_eq!(s.stringify(), "<table><tr><td colspan=\"1\" rowspan=\"1\">x</td></tr></table>\n");Examples found in repository?
examples/demo.rs (line 68)
13fn main() {
14 log::info(format!(
15 "in GitHub Actions: {} | CI: {} | step-debug: {}",
16 env::is_github_actions(),
17 env::is_ci(),
18 log::is_debug()
19 ));
20
21 let ctx = actions_rs::Context::new();
22 log::info(format!(
23 "repo={:?} ref={:?} sha={:?}",
24 ctx.repository(),
25 ctx.ref_name(),
26 ctx.sha()
27 ));
28
29 // Located annotation with a line range — should print:
30 // ::warning title=demo,file=src/lib.rs,line=10,endLine=12::heads up
31 Annotation::new()
32 .file("src/lib.rs")
33 .line(10)
34 .end_line(12)
35 .title("demo")
36 .warning("heads up: this span looks suspicious");
37
38 // Escaping check: newline in data, colon/comma in a property.
39 Annotation::new()
40 .title("type: mismatch, really")
41 .error("line one\nline two");
42
43 let total = log::group("expensive step", || {
44 log::info("...working...");
45 2 + 2
46 });
47 log::info(format!("group returned {total}"));
48
49 actions_rs::warning!("formatted macro: {} items left", 7);
50
51 output::set_output("answer", 42).expect("set_output");
52 match output::export_var("DEMO_FLAG", true) {
53 Ok(()) => {}
54 Err(actions_rs::Error::UnavailableFileCommand {
55 var: "GITHUB_ENV", ..
56 }) => {
57 log::info("GITHUB_ENV unset; skipping export_var in local demo");
58 }
59 Err(err) => panic!("export_var: {err}"),
60 }
61
62 let mut summary = Summary::new();
63 summary
64 .heading("Demo Report", 2)
65 .raw("Built by the `demo` example.", true)
66 .table([
67 vec![Cell::header("Check"), Cell::header("Result")],
68 vec![Cell::new("clippy"), Cell::new("pass")],
69 vec![Cell::new("tests"), Cell::new("36 pass")],
70 ])
71 .code_block("cargo test", Some("sh"));
72 summary.write().expect("write summary");
73 log::info("summary written (if GITHUB_STEP_SUMMARY was set)");
74}Sourcepub fn header(data: impl Into<SummaryText>) -> Self
pub fn header(data: impl Into<SummaryText>) -> Self
A <th> header cell.
§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::header("Col")]]);
assert_eq!(s.stringify(), "<table><tr><th colspan=\"1\" rowspan=\"1\">Col</th></tr></table>\n");Examples found in repository?
examples/demo.rs (line 67)
13fn main() {
14 log::info(format!(
15 "in GitHub Actions: {} | CI: {} | step-debug: {}",
16 env::is_github_actions(),
17 env::is_ci(),
18 log::is_debug()
19 ));
20
21 let ctx = actions_rs::Context::new();
22 log::info(format!(
23 "repo={:?} ref={:?} sha={:?}",
24 ctx.repository(),
25 ctx.ref_name(),
26 ctx.sha()
27 ));
28
29 // Located annotation with a line range — should print:
30 // ::warning title=demo,file=src/lib.rs,line=10,endLine=12::heads up
31 Annotation::new()
32 .file("src/lib.rs")
33 .line(10)
34 .end_line(12)
35 .title("demo")
36 .warning("heads up: this span looks suspicious");
37
38 // Escaping check: newline in data, colon/comma in a property.
39 Annotation::new()
40 .title("type: mismatch, really")
41 .error("line one\nline two");
42
43 let total = log::group("expensive step", || {
44 log::info("...working...");
45 2 + 2
46 });
47 log::info(format!("group returned {total}"));
48
49 actions_rs::warning!("formatted macro: {} items left", 7);
50
51 output::set_output("answer", 42).expect("set_output");
52 match output::export_var("DEMO_FLAG", true) {
53 Ok(()) => {}
54 Err(actions_rs::Error::UnavailableFileCommand {
55 var: "GITHUB_ENV", ..
56 }) => {
57 log::info("GITHUB_ENV unset; skipping export_var in local demo");
58 }
59 Err(err) => panic!("export_var: {err}"),
60 }
61
62 let mut summary = Summary::new();
63 summary
64 .heading("Demo Report", 2)
65 .raw("Built by the `demo` example.", true)
66 .table([
67 vec![Cell::header("Check"), Cell::header("Result")],
68 vec![Cell::new("clippy"), Cell::new("pass")],
69 vec![Cell::new("tests"), Cell::new("36 pass")],
70 ])
71 .code_block("cargo test", Some("sh"));
72 summary.write().expect("write summary");
73 log::info("summary written (if GITHUB_STEP_SUMMARY was set)");
74}Trait Implementations§
Source§impl From<SummaryText> for Cell
impl From<SummaryText> for Cell
Source§fn from(text: SummaryText) -> Self
fn from(text: SummaryText) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Cell
impl RefUnwindSafe for Cell
impl Send for Cell
impl Sync for Cell
impl Unpin for Cell
impl UnsafeUnpin for Cell
impl UnwindSafe for Cell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more