Skip to content

Commit

Permalink
Add sphinxmark_text_width config option (#25)
Browse files Browse the repository at this point in the history
Make text width configurable and increase the default
width to prevent text being cut off.

Issue #22
  • Loading branch information
kallimachos authored Jan 10, 2017
1 parent a5f0240 commit 6e0c033
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
12 changes: 12 additions & 0 deletions doc/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ sphinxmark_text_size (int)

``sphinxmark_text_size = 100``

sphinxmark_text_width (int)
- Width of transparent box containing text specified in ``sphinxmark_text``
- If a large ``sphinxmark_text_size`` is specified, or the
``sphinxmark_text`` string is long, you may need to set this option
to a number higher than the default for the entire string to display. Note
that the text will be cut off at the edge of the containing CSS div
regardless of the ``sphinxmark_text_width`` setting.
- Default = 1000
- Example:

``sphinxmark_text_width = 1000``

sphinxmark_text_color (tuple)
- RGB color code for text specified in ``sphinxmark_text``.
- Default = (255, 0, 0)
Expand Down
6 changes: 4 additions & 2 deletions doc/relnotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Release Notes
Release 0.1.17
~~~~~~~~~~~~~~

- Remove Pillow version requirement.
- Remove Bottle version requirement.
- Add sphinxmark_text_width option and increase default width. (`#22
<https://github.com/kallimachos/sphinxmark/issues/22>`_)
- Remove Pillow and Bottle version requirements. (`#23
<https://github.com/kallimachos/sphinxmark/issues/23>`_)
- Add Release Notes and restructure documentation.
3 changes: 2 additions & 1 deletion sphinxmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def createimage(app, srcdir, buildpath):
text = app.config.sphinxmark_text

# draw transparent background
width = 400
width = app.config.sphinxmark_text_width
height = app.config.sphinxmark_text_spacing
img = Image.new('RGBA', (width, height), (255, 255, 255, 0))
d = ImageDraw.Draw(img)
Expand Down Expand Up @@ -171,6 +171,7 @@ def setup(app):
app.add_config_value('sphinxmark_text', 'default', 'html')
app.add_config_value('sphinxmark_text_color', (255, 0, 0), 'html')
app.add_config_value('sphinxmark_text_size', 100, 'html')
app.add_config_value('sphinxmark_text_width', 1000, 'html')
app.add_config_value('sphinxmark_text_opacity', 20, 'html')
app.add_config_value('sphinxmark_text_spacing', 400, 'html')
app.add_config_value('sphinxmark_text_rotation', 0, 'html')
Expand Down
1 change: 1 addition & 0 deletions tests/marktest/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
# sphinxmark_text = 'Mitaka'
# sphinxmark_text_color = (255, 0, 0)
# sphinxmark_text_size = 100
# sphinxmark_text_width = 1000
# sphinxmark_text_opacity = 50
# sphinxmark_text_spacing = 600
# sphinxmark_text_rotation = 90
2 changes: 2 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# 'sphinxmark_text': 'default',
# 'sphinxmark_text_color': (255, 0, 0),
# 'sphinxmark_text_size': 100,
# 'sphinxmark_text_width': 1000,
# 'sphinxmark_text_opacity': 20,
# 'sphinxmark_text_spacing': 400,
# 'sphinxmark_text_rotation': 0}
Expand All @@ -38,6 +39,7 @@ def test_defaults():
assert app.config.sphinxmark_text == 'default'
assert app.config.sphinxmark_text_color == (255, 0, 0)
assert app.config.sphinxmark_text_size == 100
assert app.config.sphinxmark_text_width == 1000
assert app.config.sphinxmark_text_opacity == 20
assert app.config.sphinxmark_text_spacing == 400
assert app.config.sphinxmark_text_rotation == 0
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 2.3
envlist = doc, bashate, flake8, isort, pep257, py2, py3
envlist = doc, bashate, flake8, isort, pep257, py27, py3
skipsdist = True

[testenv]
Expand Down

0 comments on commit 6e0c033

Please sign in to comment.