From 6b62d199b51581d5478da8f0cb167b855c7cd699 Mon Sep 17 00:00:00 2001 From: Michael Kerscher Date: Wed, 14 Aug 2024 12:08:51 +0200 Subject: [PATCH] mdbook-slide-evaluator: add an example on how to run a local chromedriver --- mdbook-slide-evaluator/README.md | 43 +++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/mdbook-slide-evaluator/README.md b/mdbook-slide-evaluator/README.md index 8bade4b9d4e7..84062af8a3ab 100644 --- a/mdbook-slide-evaluator/README.md +++ b/mdbook-slide-evaluator/README.md @@ -4,10 +4,47 @@ can focus on the worst violations first. # How to run -## start a selenium docker container +## start a webdriver compatible browser + +### Alternative: Docker + +start a +[selenium docker container](https://github.com/SeleniumHQ/docker-selenium?tab=readme-ov-file#quick-start) +and mount the book folder into the container at /book/ + +``` +$ docker run -d -p 4444:4444 -p 7900:7900 --volume /path/to/my/workspace/comprehensive-rust/book:/book --shm-size="2g" selenium/standalone-chromium:latest +``` + +As the tool is running with a different base directory, you can use a relative +directory e.g. ../book/ like + +``` +$ cargo run -- ../book +``` + +### Alternative: Local webdriver browser with webdriver-manager + +use [webdriver-manager](https://pypi.org/project/webdriver-manager/) to install +a e.g. a chromedriver onto your system with: + +``` +$ pip install selenium webdriver-manager +$ python3 +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.chrome.options import Options +from webdriver_manager.chrome import ChromeDriverManager + +driver = webdriver.Chrome(service=Service(ChromeDriverManager().install(), port=4444)) +# end the session when you are done. +``` + +You can provide the absolute path here as the browser has the same view on the +filesystem: ``` -docker run -d -p 4444:4444 -p 7900:7900 --volume /path/to/my/workspace/comprehensive-rust/book:/book --shm-size="2g" selenium/standalone-chromium:latest +$ cargo run -- /path/to/my/workspace/comprehensive-rust/book ``` ## run mdbook-slide-size @@ -17,7 +54,7 @@ evaluate this manually. The tool always recursively grabs all *.html files from the given directory and processes it. ``` -cargo run --screenshot-dir screenshots ../book/html/ +cargo run -- --screenshot-dir screenshots ../book/html/ ``` # Roadmap