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
File details
Details for the file sphinxcontrib_screenshot-0.1.2.tar.gz
.
File metadata
- Download URL: sphinxcontrib_screenshot-0.1.2.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 835e6644e0238f913913ea129c3899456e329ef920a911ffd7bf736614eea1a7 |
|
MD5 | 4a4f72d259624d657186024a5cf8886b |
|
BLAKE2b-256 | 015d29e7e8a5fe01fdce84a4cb507581f963d3c0e3a1e4f7d46f6f2b57ddc08d |
File details
Details for the file sphinxcontrib_screenshot-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: sphinxcontrib_screenshot-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4660974d2def5bd914c107d4ad2b56aa2dadcd19e033441cd65a3cceb4a2b6aa |
|
MD5 | 2de7aabbbe25f87679b8b1b824192449 |
|
BLAKE2b-256 | 385f19f624f18f1906deafa3e1e719d5576f00c1a4364e735cb45302ee1aad14 |