Skip to content

Commit

Permalink
Update build setup and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed Jan 17, 2024
1 parent ec8f49d commit e064f35
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
__pycache__/
*.egg-info/
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include sphinxemoji/*.json
include sphinxemoji/*.css
include sphinxemoji/*.js
23 changes: 19 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,37 @@ Then you can use emoji code replacements by writing them between bars:
Don't you love it? |:heart_eyes:|
If you want a consistent emoji style, you can set it in your ``conf.py`` file:
You can find the list of all supported emoji codes `in the project's documentation page
<https://sphinxemojicodes.readthedocs.io/#supported-codes>`_.


Configuration
-------------

If you want a consistent emoji style instead of using the browser's default,
you can set it in your ``conf.py`` file:

.. code:: python
sphinxemoji_style = 'twemoji'
By default twemoji is obtained from a CDN. If you want to specify your own
By default Twemoji is obtained from a CDN. If you want to specify your own
source location (be it local or from another CDN), you can do so via the ``conf.py`` file:

.. code:: python
sphinxemoji_source = 'https://unpkg.com/twemoji@latest/dist/twemoji.min.js'
# or: sphinxemoji_source = 'my-local-twemoji.min.js'
You can find the list of all supported emoji codes `in the project's documentation page
<https://sphinxemojicodes.readthedocs.io/#supported-codes>`_.
Build
-----

You can build this package by running this command from the root directory:

.. code::
python -m build
Notes
Expand Down
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "sphinxemoji"
description = "An extension to use emoji codes in your Sphinx documentation"
dynamic = ["version"]
authors = [
{name = "Miguel Sánchez de León Peque", email = "peque@neosit.es"},
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Documentation",
"Topic :: Software Development",
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Framework :: Sphinx :: Extension",
]
dependencies = [
"sphinx>=4.0",
]
requires-python = ">=3.9"

[project.urls]
Homepage = "https://sphinxemojicodes.readthedocs.io"
Repository = "https://github.com/sphinx-contrib/emojicodes"
Documentation = "https://sphinxemojicodes.readthedocs.io"
Issues = "https://github.com/sphinx-contrib/emojicodes/issues"

[tool.setuptools.dynamic]
version = {attr = "sphinxemoji.__version__"}
36 changes: 1 addition & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,4 @@
"""
from setuptools import setup

from sphinxemoji import __version__


setup(
name='sphinxemoji',
version=__version__,
description='An extension to use emoji codes in your Sphinx documentation',
long_description="""TODO""",
url='https://github.com/sphinx-contrib/emojicodes',
author='Miguel Sánchez de León Peque',
author_email='peque@neosit.es',
license='BSD License',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Documentation',
'Topic :: Software Development',
'Topic :: Utilities',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Framework :: Sphinx :: Extension',
],
packages=['sphinxemoji'],
package_data={
'sphinxemoji': [
'codes.json',
'twemoji.css',
'twemoji.js',
],
},
install_requires=[
'sphinx>=1.8',
],
)
setup()
13 changes: 7 additions & 6 deletions sphinxemoji/sphinxemoji.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import json
from pkg_resources import resource_filename
from importlib import resources

from docutils import nodes
from docutils.utils import new_document
Expand Down Expand Up @@ -32,7 +32,7 @@ def load_emoji_codes():
- Original issue: https://github.com/sphinx-doc/sphinx/issues/8276
- New issue: https://sourceforge.net/p/docutils/feature-requests/79/
"""
fname = resource_filename(__name__, 'codes.json')
fname = resources.files('sphinxemoji') / 'codes.json'
with open(fname, encoding='utf-8') as fp:
codes = json.load(fp)

Expand Down Expand Up @@ -81,8 +81,8 @@ def apply(self):

def copy_asset_files(app, exc):
asset_files = [
resource_filename(__name__, 'twemoji.js'),
resource_filename(__name__, 'twemoji.css'),
resources.files('sphinxemoji') / 'twemoji.js',
resources.files('sphinxemoji') / 'twemoji.css',
]
if exc is None: # build succeeded
for path in asset_files:
Expand All @@ -92,10 +92,11 @@ def copy_asset_files(app, exc):
def setup(app):
app.connect('build-finished', copy_asset_files)
style = app.config._raw_config.get('sphinxemoji_style')
source = app.config._raw_config.get('sphinxemoji_source', emoji_styles[style]['source'])
if style in emoji_styles:
files = emoji_styles[style]
source = app.config._raw_config.get('sphinxemoji_source', files['source'])
app.add_js_file(source)
for fname in emoji_styles[style]['libs']:
for fname in files['libs']:
if fname.endswith('.js'):
app.add_js_file(fname)
elif fname.endswith('.css'):
Expand Down

0 comments on commit e064f35

Please sign in to comment.