mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Merge pull request #809 from readthedocs/agj/setup-webpack-commands
Add webpack commands into setup.py
This commit is contained in:
commit
ddf840cb72
@ -94,9 +94,11 @@ To release a new version of the theme, core team will take the following steps:
|
|||||||
(with regards to alpha release and development versions). The version
|
(with regards to alpha release and development versions). The version
|
||||||
increment should reflect these releases and any potentially breaking changes.
|
increment should reflect these releases and any potentially breaking changes.
|
||||||
#. Update the changelog (``docs/changelog.rst``) with the version information.
|
#. Update the changelog (``docs/changelog.rst``) with the version information.
|
||||||
#. Run ``npm run build`` to rebuild all the theme assets.
|
#. Run ``python setup.py update_translations`` to compile new translation files
|
||||||
#. Run ``python setup.py update_translations`` to compile new translation files and update Transifex
|
and update Transifex.
|
||||||
#. Commit that change.
|
#. Run ``python setup.py build`` to rebuild all the theme assets and the Python
|
||||||
|
package.
|
||||||
|
#. Commit these changes.
|
||||||
#. Tag the release in git: ``git tag $NEW_VERSION``.
|
#. Tag the release in git: ``git tag $NEW_VERSION``.
|
||||||
#. Push the tag to GitHub: ``git push --tags origin``.
|
#. Push the tag to GitHub: ``git push --tags origin``.
|
||||||
#. Upload the package to PyPI:
|
#. Upload the package to PyPI:
|
||||||
|
37
setup.py
37
setup.py
@ -5,12 +5,43 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import distutils.cmd
|
import distutils.cmd
|
||||||
|
import setuptools.command.build_py
|
||||||
from io import open
|
from io import open
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
|
class WebpackBuildCommand(setuptools.command.build_py.build_py):
|
||||||
|
|
||||||
|
"""Prefix Python build with Webpack asset build"""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if not 'CI' in os.environ:
|
||||||
|
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):
|
||||||
|
|
||||||
|
description = "Run Webpack dev server"
|
||||||
|
|
||||||
|
user_options = []
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
subprocess.run(
|
||||||
|
["node_modules/.bin/webpack-dev-server", "--open", "--config", "webpack.dev.js"],
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UpdateTranslationsCommand(distutils.cmd.Command):
|
class UpdateTranslationsCommand(distutils.cmd.Command):
|
||||||
|
|
||||||
description = "Run all localization commands"
|
description = "Run all localization commands"
|
||||||
@ -47,8 +78,8 @@ class TransifexCommand(distutils.cmd.Command):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
subprocess.run(['tx', 'push', '--source'])
|
subprocess.run(['tx', 'push', '--source'], check=True)
|
||||||
subprocess.run(['tx', 'pull'])
|
subprocess.run(['tx', 'pull'], check=True)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@ -63,6 +94,8 @@ setup(
|
|||||||
cmdclass={
|
cmdclass={
|
||||||
'update_translations': UpdateTranslationsCommand,
|
'update_translations': UpdateTranslationsCommand,
|
||||||
'transifex': TransifexCommand,
|
'transifex': TransifexCommand,
|
||||||
|
'build_py': WebpackBuildCommand,
|
||||||
|
'watch': WebpackDevelopCommand,
|
||||||
},
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
packages=['sphinx_rtd_theme'],
|
packages=['sphinx_rtd_theme'],
|
||||||
|
Loading…
Reference in New Issue
Block a user