sphinxcontrib-screenshot 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sphinxcontrib-screenshot might be problematic. Click here for more details.

@@ -116,6 +116,7 @@ class ScreenshotDirective(SphinxDirective, Figure):
116
116
  'headers': directives.unchanged,
117
117
  'locale': str,
118
118
  'timezone': str,
119
+ 'device-scale-factor': directives.positive_int,
119
120
  }
120
121
  pool = ThreadPoolExecutor()
121
122
 
@@ -125,7 +126,7 @@ class ScreenshotDirective(SphinxDirective, Figure):
125
126
  interactions: str, generate_pdf: bool,
126
127
  color_scheme: ColorScheme, full_page: bool,
127
128
  context_builder: ContextBuilder, headers: dict,
128
- locale: typing.Optional[str],
129
+ device_scale_factor: int, locale: typing.Optional[str],
129
130
  timezone: typing.Optional[str]):
130
131
  """Takes a screenshot with Playwright's Chromium browser.
131
132
 
@@ -145,6 +146,8 @@ class ScreenshotDirective(SphinxDirective, Figure):
145
146
  full_page (bool): Take a full page screenshot.
146
147
  context: A method to build the Playwright context.
147
148
  headers (dict): Custom request header.
149
+ device_scale_factor (int): The device scale factor for the screenshot.
150
+ This can be thought of as DPR (device pixel ratio).
148
151
  locale (str, optional): User locale for the request.
149
152
  timezone (str, optional): User timezone for the request.
150
153
  """
@@ -160,7 +163,10 @@ class ScreenshotDirective(SphinxDirective, Figure):
160
163
  (url, context_builder.__name__))
161
164
  else:
162
165
  context = browser.new_context(
163
- color_scheme=color_scheme, locale=locale, timezone_id=timezone)
166
+ color_scheme=color_scheme,
167
+ locale=locale,
168
+ timezone_id=timezone,
169
+ device_scale_factor=device_scale_factor)
164
170
 
165
171
  page = context.new_page()
166
172
  page.set_default_timeout(10000)
@@ -247,7 +253,9 @@ class ScreenshotDirective(SphinxDirective, Figure):
247
253
  self.env.config.screenshot_default_timezone)
248
254
  context = self.options.get('context', '')
249
255
  headers = self.options.get('headers', '')
250
-
256
+ device_scale_factor = self.options.get(
257
+ 'device-scale-factor',
258
+ self.env.config.screenshot_default_device_scale_factor)
251
259
  request_headers = {**self.env.config.screenshot_default_headers}
252
260
  if headers:
253
261
  for header in headers.strip().split("\n"):
@@ -259,7 +267,8 @@ class ScreenshotDirective(SphinxDirective, Figure):
259
267
  raw_path, browser,
260
268
  str(viewport_height),
261
269
  str(viewport_width), color_scheme, context, interactions,
262
- str(full_page)
270
+ str(full_page),
271
+ str(device_scale_factor)
263
272
  ])
264
273
  filename = hashlib.md5(hash_input.encode()).hexdigest() + '.png'
265
274
  filepath = os.path.join(ss_dirpath, filename)
@@ -276,8 +285,8 @@ class ScreenshotDirective(SphinxDirective, Figure):
276
285
  url_or_filepath, browser, viewport_width,
277
286
  viewport_height, filepath, screenshot_init_script,
278
287
  interactions, pdf, color_scheme, full_page,
279
- context_builder, request_headers, locale,
280
- timezone)
288
+ context_builder, request_headers,
289
+ device_scale_factor, locale, timezone)
281
290
  fut.result()
282
291
 
283
292
  # Create image and figure nodes
@@ -359,6 +368,12 @@ def setup(app: Sphinx) -> Meta:
359
368
  'screenshot_default_headers', {},
360
369
  'env',
361
370
  description="The default headers to pass in requests")
371
+ app.add_config_value(
372
+ 'screenshot_default_device_scale_factor',
373
+ 1,
374
+ 'env',
375
+ description="The default device scale factor " +
376
+ "a.k.a. DPR (device pixel ratio)")
362
377
  app.add_config_value(
363
378
  'screenshot_default_locale',
364
379
  None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sphinxcontrib-screenshot
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A Sphinx extension to embed webpage screenshots.
5
5
  Author-email: Shuhei Iitsuka <tushuhei@gmail.com>
6
6
  License: Apache-2.0
@@ -0,0 +1,6 @@
1
+ sphinxcontrib/screenshot.py,sha256=Kb4oC4w-fv9qBYi251u5WeN_xvSLjwv0k3Ybs0R8xi4,14096
2
+ sphinxcontrib_screenshot-0.2.2.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
3
+ sphinxcontrib_screenshot-0.2.2.dist-info/METADATA,sha256=S52Ju_7SvfeT5xDFia9m7ABh1f1egPSRMTVrey6ivok,2868
4
+ sphinxcontrib_screenshot-0.2.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ sphinxcontrib_screenshot-0.2.2.dist-info/top_level.txt,sha256=VJrV3_vaiKQVgVpR0I1iecxoO0drzGu-M0j40PVP2QQ,14
6
+ sphinxcontrib_screenshot-0.2.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- sphinxcontrib/screenshot.py,sha256=xkhT956Abup3BeRe6JyIL_ZauhjFTdNh0Mf17CGN6iA,13419
2
- sphinxcontrib_screenshot-0.2.1.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
3
- sphinxcontrib_screenshot-0.2.1.dist-info/METADATA,sha256=MvhMPcvnqB0sCgRJSx3tVAxeXShwlcJh-sbdUVYOgU0,2868
4
- sphinxcontrib_screenshot-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
- sphinxcontrib_screenshot-0.2.1.dist-info/top_level.txt,sha256=VJrV3_vaiKQVgVpR0I1iecxoO0drzGu-M0j40PVP2QQ,14
6
- sphinxcontrib_screenshot-0.2.1.dist-info/RECORD,,