Skip to content

Commit

Permalink
fix(lib): fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Jul 26, 2024
1 parent 0719c1a commit 8d2a3cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ $ nix run nixpkgs#termsnap -- --columns 80 --lines 36 -- ls --color=always -l
$ nix run nixpkgs#termsnap -- --interactive --out ./interactive-bash.svg -- bash
```

The above takes Termsnap from the nixpkgs repository. To use the most up to
date version on this repository's main branch, substitute `nixpkgs#termsnap` by
`github:tomcur/termsnap`.

## A note on fonts

The SVG generated by Termsnap makes assumptions about the metrics of the font
Expand Down
16 changes: 9 additions & 7 deletions termsnap-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! SVG files.
//!
//! ```rust
//! use termsnap_lib::{Term, VoidPtyWriter};
//! use termsnap_lib::{FontMetrics, Term, VoidPtyWriter};
//!
//! // Create a new terminal emulator and process some bytes.
//! let mut term = Term::new(24, 80, VoidPtyWriter);
Expand All @@ -20,7 +20,7 @@
//! assert_eq!(&format!("{}", screen.get(0, 10).unwrap().fg), "#859900");
//!
//! // Render the screen to SVG.
//! println!("{}", screen.to_svg(&[]));
//! println!("{}", screen.to_svg(&[], FontMetrics::DEFAULT));
//! ```

#![forbid(unsafe_code)]
Expand Down Expand Up @@ -67,11 +67,13 @@ impl FontMetrics {
/// or Menlo. If this is not accurate, it will be noticeable as overlap or gaps between box
/// drawing characters.
///
/// ```
/// units_per_em: 1000
/// advance: 600.0
/// line_height: 1200.0
/// descent: 300.0
/// ```norun
/// FontMetrics {
/// units_per_em: 1000,
/// advance: 600.0,
/// line_height: 1200.0,
/// descent: 300.0,
/// }
/// ```
pub const DEFAULT: FontMetrics = FontMetrics {
units_per_em: 1000,
Expand Down

0 comments on commit 8d2a3cb

Please sign in to comment.