forked from kallimachos/sphinxmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2817b44
Showing
222 changed files
with
6,247 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
================ | ||
Sphinx Watermark | ||
================ | ||
.. image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg | ||
:target: https://www.gnu.org/licenses/gpl-3.0 | ||
:alt: GPL3 License | ||
|
||
.. image:: https://api.codeclimate.com/v1/badges/d689b89f5ae6836ad88c/maintainability | ||
:target: https://codeclimate.com/github/JoKneeMo/sphinx-watermark/maintainability | ||
:alt: Maintainability | ||
|
||
.. image:: https://img.shields.io/pypi/status/sphinx-watermark.svg?style=flat | ||
:target: https://pypi.python.org/pypi/sphinx-watermark | ||
:alt: Project Status | ||
|
||
.. image:: https://img.shields.io/pypi/v/sphinx-watermark.svg?style=flat | ||
:target: https://pypi.python.org/pypi/sphinx-watermark | ||
:alt: Package Version | ||
|
||
|
||
**sphinx-watermark** is an extension for Sphinx that enables watermarks for | ||
HTML output. | ||
|
||
Full documentation: https://jokneemo.github.io/sphinx-watermark | ||
|
||
|
||
*********** | ||
Why a Fork? | ||
*********** | ||
Forked from `kallimachos/sphinxmark <https://github.com/kallimachos/sphinxmark/tree/0762fdef2eabead5edf99e393becc2cd5a926f11>`_ | ||
|
||
This fork was created primarily to remove the dependency on bottle, and to | ||
support updates to Sphinx v7, Docutils, and Pillow. | ||
|
||
Some themes perform differently in newer version of Docutils. | ||
The main issues faced are html elements are changed between div, section, | ||
article, etc. | ||
|
||
Sphinxmark only supported div elements and the configuration changes I made to | ||
support it were too expansive for a simple pull request. See below for all of | ||
the enhancements added. | ||
|
||
|
||
What's Different? | ||
~~~~~~~~~~~~~~~~~ | ||
- Removed bottle dependency | ||
- HTML element selection | ||
- Static png name to support spaces in text | ||
- Collection of fonts | ||
|
||
- See the `fonts directory <https://github.com/JoKneeMo/sphinx-watermark/tree/main/sphinx_watermark/fonts>`_. | ||
|
||
- Customizable border | ||
|
||
|
||
.. toctree:: | ||
:hidden: | ||
|
||
installation | ||
usage | ||
options | ||
troubleshooting | ||
relnotes | ||
source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
============ | ||
Installation | ||
============ | ||
|
||
Install sphinx-watermark using pip: | ||
|
||
.. code-block:: bash | ||
$ pip3 install sphinx-watermark | ||
.. note:: | ||
|
||
Sphinx Watermark uses the `Pillow module <https://pillow.readthedocs.io/en/stable/>`_ for creating PNG | ||
files. If you encounter ``C module is not installed`` errors when Sphinx loads the sphinx-watermark | ||
extension, you may need to install some of the `external libraries | ||
<https://pillow.readthedocs.io/en/stable/installation.html#external-libraries>`_ for Pillow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
======= | ||
Options | ||
======= | ||
|
||
:**enabled (bool)**: | ||
|
||
- ``True`` - enable watermarks | ||
- ``False`` - disable watermarks | ||
- Default: ``False`` | ||
|
||
.. code-block:: python | ||
watermark = { | ||
'enabled': False | ||
} | ||
:**selector (dict or string)**: | ||
|
||
Short form is a string, setting the class name of a div element. | ||
|
||
Long form is a dictionary, specifying an html element type and it's class. | ||
|
||
:**type (string)**: | ||
HTML element type to apply the watermark to. | ||
|
||
- Default: ``div`` | ||
|
||
:**class (string)**: | ||
CSS class, applied to the type, where watermark is displayed | ||
|
||
- Default: ``body`` | ||
- Examples for common themes: | ||
|
||
sphinx_rtd_theme -> ``'class': 'document'`` | ||
|
||
openstackdocstheme -> ``'class': 'docs-body'`` | ||
|
||
sphinx_book_theme -> ``'class': 'row#main-content'`` | ||
|
||
sphinx_immaterial -> ``'class': 'md-main__inner'`` | ||
|
||
.. code-block:: python | ||
watermark = { | ||
'selector': { | ||
'type': 'div', | ||
'class': 'body' | ||
} | ||
} | ||
:**postion (dict)**: | ||
|
||
:**margin (string)**: | ||
|
||
- ``left`` - place watermark in the left page margin | ||
- ``right`` - place watermark on right page margin | ||
- Default: ``None`` | ||
|
||
:**repeat (bool)**: | ||
|
||
- ``True`` - image repeats down the page | ||
- ``False`` - image appears once at top of page | ||
- Default: ``True`` | ||
|
||
:**fixed (bool)**: | ||
|
||
- ``True`` - watermark does not scroll with content | ||
- ``False`` - watermark scrolls with content | ||
- When set to ``True``, this option centers the watermark in the viewport, | ||
not the element specified by ``selector``. | ||
- Default: ``False`` | ||
|
||
.. code-block:: python | ||
watermark = { | ||
'position': { | ||
'margin': None, | ||
'repeat': True, | ||
'fixed': False | ||
} | ||
} | ||
:**image (string)**: | ||
|
||
- image file name in ``html_static_path`` directory to use as watermark | ||
- Should not be used if text.content is set. | ||
- Default: ``None`` | ||
|
||
.. code-block:: python | ||
watermark = { | ||
'image': None | ||
} | ||
:**text (dict or string)**: | ||
|
||
Short form is a string, setting the text content and the rest default. | ||
|
||
Long form is a dictionary, specifying an custom options. | ||
|
||
:**content (string)**: | ||
Text to insert into the watermark. | ||
|
||
Use ``\n`` for multiline text. | ||
|
||
- Default: ``None`` | ||
|
||
:**align** (string)**: | ||
|
||
- ``left`` - Left justify the text.content | ||
- ``right`` - Right justify the text.content | ||
- ``center`` - Center justify the text.content | ||
- Default: ``center`` | ||
|
||
:**font (string)**: | ||
Which font should be used to render the text. | ||
|
||
- Anton | ||
- Gluten | ||
- KodeMono | ||
- RobotoMono | ||
- RubikDistressed | ||
- ShantellSans | ||
- Default: ``RubikDistressed`` | ||
|
||
:**color (int tuple)**: | ||
RGB Value in as a tuple of integers | ||
|
||
- Default: ``(255, 0, 0)`` (Red) | ||
|
||
:**opacity (int)**: | ||
RGB Alpha, or how transparent should the watermark be | ||
|
||
- Default: ``40`` | ||
|
||
:**size (int)**: | ||
Font size, in pixels, for the watermark text.content | ||
|
||
- Default: ``100`` | ||
|
||
:**rotation (int)**: | ||
Degrees of rotation for the entire watermark. | ||
|
||
- Default: ``0`` | ||
|
||
:**width (int)**: | ||
Width, in pixels, of transparent box containing the watermark text.content | ||
|
||
If a large text.size is specified, or the text.content 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 width setting. | ||
|
||
- Default: ``816`` | ||
|
||
:**spacing (int)**: | ||
Spacing, in pixels, between text watermarks when repeated, and the text line height | ||
|
||
- Default: ``400`` | ||
|
||
:**border (dict)**: | ||
Draws a border around the watermark image. | ||
|
||
:**outline (int tuple)**: | ||
RGB Value in as a tuple of integers | ||
|
||
- Default: ``(255, 0, 0)`` (Red) | ||
|
||
:**fill (int tuple)**: | ||
RGB Value in as a tuple of integers to fill the watermark background. | ||
|
||
- Default: ``None`` | ||
|
||
:**width (int)**: | ||
How wide, in pixels, the border should be. | ||
|
||
- Default: ``10`` | ||
|
||
:**padding (int)**: | ||
How much spacing, in pixels, should be between text.content and the border. | ||
|
||
- Default: ``30`` | ||
|
||
:**radius (int)**: | ||
How round, in pixels, the corners of the border should be. | ||
|
||
- Default: ``20`` | ||
|
||
.. code-block:: python | ||
watermark = { | ||
'text': { | ||
'content': None, | ||
'align': 'center', | ||
'font': 'RubikDistressed', | ||
'color': (255, 0, 0), | ||
'opacity': 40, | ||
'size': 100, | ||
'rotation': 0, | ||
'width': 816, | ||
'spacing': 400, | ||
'border': { | ||
'outline': (255, 0, 0), | ||
'fill': None, | ||
'width': 10, | ||
'padding': 30, | ||
'radius': 20, | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
============= | ||
Release Notes | ||
============= | ||
|
||
Release 2.0.0 | ||
------------- | ||
- Forked to v2.0.0 as the config syntax has fully changed | ||
- New configuration syntax as a python dict | ||
- Removed bottle dependency | ||
- Added HTML element selection | ||
- Use a static name for the watermark image to support spaces in text | ||
- Added additional fonts with configuration | ||
- Customizable border options | ||
- Default image size to fit US Letter PDF pages | ||
|
||
|
||
Release 1.0.0 | ||
------------- | ||
- Move to 1.0.0 stable release. | ||
- `#39 <https://github.com/kallimachos/sphinxmark/pull/39>`_: Replace Travis-CI with GitHub | ||
Actions. | ||
|
||
Release 0.2.1 | ||
~~~~~~~~~~~~~ | ||
|
||
- `#38 <https://github.com/kallimachos/sphinxmark/issues/38>`_: use pathlib in place of os.path. | ||
- `#37 <https://github.com/kallimachos/sphinxmark/issues/37>`_: add type annotations. | ||
- `#36 <https://github.com/kallimachos/sphinxmark/pull/36>`_: update option documentation to | ||
include ``sphinx_book_theme``. Thanks `rscohn2 <https://github.com/rscohn2>`_. | ||
- `#35 <https://github.com/kallimachos/sphinxmark/issues/35>`_: fix text watermark opacity issue. | ||
Thanks `chad-iris <https://github.com/chad-iris>`_. | ||
|
||
Release 0.2.0 | ||
~~~~~~~~~~~~~ | ||
|
||
- `#34 <https://github.com/kallimachos/sphinxmark/pull/34>`_: add support for | ||
Sphinx 2.0. Remove support for Python 2.7. | ||
|
||
|
||
Release 0.1.19 | ||
~~~~~~~~~~~~~~ | ||
|
||
- `#29 <https://github.com/kallimachos/sphinxmark/pull/29>`_: fix isort test | ||
error. | ||
- `#28 <https://github.com/kallimachos/sphinxmark/pull/28>`_: remove invalid | ||
argument to ``ImageDraw.text()`` method. | ||
|
||
Release 0.1.18 | ||
~~~~~~~~~~~~~~ | ||
|
||
- `#26 <https://github.com/kallimachos/sphinxmark/issues/26>`_: enable | ||
``parallel_read_safe``. | ||
- Remove unused ``publish.sh`` script. | ||
- Tidy ``tox.ini`` file. | ||
|
||
Release 0.1.17 | ||
~~~~~~~~~~~~~~ | ||
|
||
- `#23 <https://github.com/kallimachos/sphinxmark/issues/23>`_: remove Pillow | ||
and Bottle version requirements. | ||
- `#22 <https://github.com/kallimachos/sphinxmark/issues/22>`_: add | ||
``sphinxmark_text_width`` option and increase default width. | ||
- Add Release Notes and restructure documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
============ | ||
Code Listing | ||
============ | ||
|
||
.. automodule:: __init__ | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
=============== | ||
Troubleshooting | ||
=============== | ||
|
||
You can enable debugging output for sphinx-watermark by raising the output verbosity | ||
level >= 2. Pass the ``-vv`` option on the command line. | ||
|
||
Example: | ||
|
||
.. code-block:: bash | ||
$ sphinx-build -vv -b html sourcedir buildir |
Oops, something went wrong.