A Shpinx extension to embed webpage screenshots.
Project description
sphinxcontrib-screenshot
A Sphinx extension to embed website screenshots.
Install
pip install sphinxcontrib-screenshot
playwright install
Usage
Add sphinxcontrib.screenshot
to your conf.py
.
extensions = ["sphinxcontrib.screenshot"]
Then use the screenshot
directive in your Sphinx source file.
.. screenshot:: http://www.example.com
You can also specify the screen size for the screenshot with width
and height
parameters.
.. screenshot:: http://www.example.com
:width: 1280
:height: 960
You can include a caption for the screenshot's figure
directive.
.. screenshot:: http://www.example.com
:caption: This is a screenshot for www.example.com
You can describe the interaction that you want to have with the webpage before taking a screenshot in JavaScript.
.. screenshot:: http://www.example.com
document.querySelector('button').click();
Pro tips
sphinxcontrib-screenshot
supports URLs with the HTTP and HTTPS protocols.
To take screenshots of local files and build the document while running a local server for them, you can use the NPM library concurrently in the following way:
Build the document
npx --yes concurrently -k --success=first "make html" "python3 -m http.server 3000 --directory=examples"
Watch and build the document
npx --yes concurrently -k "make livehtml" "python3 -m http.server 3000 --directory=examples"
Notes
This extension uses Playwright to capture a screenshot of the specified website only. No data is sent to any other external server; the request is limited to the specified website. Be cautious: avoid including sensitive information (such as authentication data) in the directive content.
Contributing
See CONTRIBUTING.md
for details.
License
Apache 2.0; see LICENSE
for details.
Disclaimer
This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sphinxcontrib_screenshot-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2404618c505aa887518c14a2c7dc4e669967477db3c06c29dcb83b5401ae4c |
|
MD5 | 5dbcb7f4a2db2a03042a10089aa6a831 |
|
BLAKE2b-256 | 90dd5ae7f480fdd495cc0a2f32556a74c9d3a08647c5c8aa29f002e9fb2150b2 |
Hashes for sphinxcontrib_screenshot-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26694ededf6bda01b8ebebe330e91bd67d3b7c37e7ced44097071bcd32b73129 |
|
MD5 | 979b1dc52e2db89b080e32cdf47423df |
|
BLAKE2b-256 | 6776e72e8f49d158c018644f409ebfc1a220bce0172b716e8e5d0a444072c6e8 |