Add new SVG-based screencast (#693)

This is taken from https://github.com/sharkdp/fd, so all credits
go to the original authors.

The demo was a bit dated. We've since added more features and
changed the output. On top of that, the gif was a bit blurry.

The new version is in SVG and the commands can be scripted, so
we can change them with a PR and render them through CI.

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
Matthias 2022-08-10 17:35:50 +02:00 committed by GitHub
parent 435eadd96b
commit 601adcefd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 2 deletions

View file

@ -33,3 +33,7 @@ run: ## Run project locally
.PHONY: docs
docs: ## Generate and show documentation
cargo doc --open
.PHONY: screencast
screencast: ## Create a screencast for the docs
svg-term --command 'assets/screencast.sh' --out 'assets/screencast.svg' --width 100 --padding 10 --window

View file

@ -12,7 +12,7 @@ reStructuredText, or any other text file or website!
Available as a command-line utility, a library and a [GitHub Action](https://github.com/lycheeverse/lychee-action).
![Lychee demo](./assets/lychee.gif)
![Lychee demo](./assets/screencast.svg)
## Installation

60
assets/screencast.sh Normal file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env bash
#
# Adapted from
# https://github.com/marionebl/svg-term-cli
# https://github.com/sharkdp/fd/blob/master/doc/screencast.sh
#
# Designed to be executed via svg-term from the lychee root directory:
# svg-term --command="bash assets/screencast.sh" --out assets/screencast.svg --padding=10
# Then run this (workaround for https://github.com/sharkdp/fd/issues/1003):
# sed -i '' 's/<text/<text font-size="1.67"/g' assets/screencast.svg
set -e
set -u
PROMPT=""
# Always use latest version of lychee for screencast
alias lychee="cargo run --"
enter() {
INPUT=$1
DELAY=1
prompt
sleep "$DELAY"
type "$INPUT"
sleep 0.5
printf '%b' "\\n"
eval "$INPUT"
type "\\n"
}
prompt() {
printf '%b ' "$PROMPT" | pv -q
}
type() {
printf '%b' "$1" | pv -qL $((10+(-2 + RANDOM%5)))
}
main() {
IFS='%'
enter "lychee README.md"
enter "lychee --verbose --format=json fixtures/TEST.html"
enter "lychee --no-progress --format detailed https://example.com"
enter "lychee --dump --include github -- './**/*.md'"
prompt
sleep 3
echo ""
unset IFS
}
main

1
assets/screencast.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 114 KiB

1
fixtures/TEST.html vendored
View file

@ -10,7 +10,6 @@
>
</li>
<li><a href="https://hello-rust.show/10/">Hello Rust</a></li>
<li><a href="20/">Hello Rust</a></li>
</ul>
</body>
</html>