Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require npm to build from source #1039

Merged
merged 9 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version: 2

python:
version: 3
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .

sphinx:
configuration: docs/conf.py
10 changes: 5 additions & 5 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ To release a new version of the theme, core team will take the following steps:
#. Update the changelog (``docs/changelog.rst``) with the version information.
#. Run ``python setup.py update_translations`` to compile new translation files
and update Transifex.
#. Run ``python setup.py build`` to rebuild all the theme assets and the Python
#. Run ``python setup.py build_assets`` to rebuild all the theme assets and the Python
package.
#. Commit these changes.
#. Tag the release in git: ``git tag $NEW_VERSION``.
#. Push the tag to GitHub: ``git push --tags origin``.
#. Upload the package to PyPI:

.. code:: console
.. code:: console
$ rm -rf dist/
$ python setup.py sdist bdist_wheel
$ twine upload --sign --identity security@readthedocs.org dist/*
$ rm -rf dist/
$ python setup.py sdist bdist_wheel
$ twine upload --sign --identity security@readthedocs.org dist/*
.. _PEP440: https://www.python.org/dev/peps/pep-0440/
14 changes: 10 additions & 4 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ In your ``conf.py`` file:
.. note::
Adding this theme as an extension is what enables localization of theme
strings in your translated output. If these strings are not translated in
your output, either we lack the localized strings for your locale, or you
are using an old version of the theme.

Adding this theme as an extension is what enables localization of theme
strings in your translated output. If these strings are not translated in
your output, either we lack the localized strings for your locale, or you
are using an old version of the theme.

Via Git or Download
===================

.. warning::

Installing directly from the repo is deprecated.
Static assets won't be included in the repo in a future release.

Symlink or subtree the ``sphinx_rtd_theme/sphinx_rtd_theme`` repository into your documentation at
``docs/_themes/sphinx_rtd_theme`` then add the following two settings to your Sphinx
``conf.py`` file:
Expand Down
41 changes: 11 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 21 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# -*- coding: utf-8 -*-
"""`sphinx_rtd_theme` lives on `Github`_.
.. _github: https://github.com/readthedocs/sphinx_rtd_theme
"""

import distutils.cmd
stsewd marked this conversation as resolved.
Show resolved Hide resolved
import os
import subprocess
import distutils.cmd
import setuptools.command.build_py
from io import open

from setuptools import setup


class WebpackBuildCommand(setuptools.command.build_py.build_py):
class WebpackBuildCommand(distutils.cmd.Command):

description = "Generate static assets"

user_options = []

"""Prefix Python build with Webpack asset build"""
def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
if not 'CI' in os.environ and not 'TOX_ENV_NAME' in os.environ:
subprocess.run(['npm', 'install'], check=True)
subprocess.run(['node_modules/.bin/webpack', '--config', 'webpack.prod.js'], check=True)
setuptools.command.build_py.build_py.run(self)


class WebpackDevelopCommand(distutils.cmd.Command):
Expand Down Expand Up @@ -95,7 +97,7 @@ def run(self):
cmdclass={
'update_translations': UpdateTranslationsCommand,
'transifex': TransifexCommand,
'build_py': WebpackBuildCommand,
'build_assets': WebpackBuildCommand,
'watch': WebpackDevelopCommand,
},
zip_safe=False,
Expand Down Expand Up @@ -137,12 +139,17 @@ def run(self):
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Operating System :: OS Independent',
'Topic :: Documentation',
'Topic :: Software Development :: Documentation',
],
project_urls={
'Homepage': 'https://sphinx-rtd-theme.readthedocs.io/',
'Source Code': 'https://github.com/readthedocs/sphinx_rtd_theme',
'Issue Tracker': 'https://github.com/readthedocs/sphinx_rtd_theme/issues',
},
)
2 changes: 1 addition & 1 deletion sphinx_rtd_theme/static/css/theme.css

Large diffs are not rendered by default.