mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Add compile_grammar command to setup.py (ref: #2765)
This commit is contained in:
@@ -4,9 +4,9 @@ from setuptools import setup, find_packages
|
||||
import os
|
||||
import sys
|
||||
from distutils import log
|
||||
from distutils.cmd import Command
|
||||
|
||||
import sphinx
|
||||
from sphinx.pycode.pgen2.driver import compile_grammar
|
||||
|
||||
long_desc = '''
|
||||
Sphinx is a tool that makes it easy to create intelligent and beautiful
|
||||
@@ -73,10 +73,6 @@ extras_require = {
|
||||
if sys.platform == 'win32':
|
||||
requires.append('colorama>=0.3.5')
|
||||
|
||||
# Compile grammars before packaging
|
||||
compile_grammar('sphinx/pycode/Grammar-py2.txt')
|
||||
compile_grammar('sphinx/pycode/Grammar-py3.txt')
|
||||
|
||||
# Provide a "compile_catalog" command that also creates the translated
|
||||
# JavaScript files if Babel is available.
|
||||
|
||||
@@ -173,6 +169,31 @@ else:
|
||||
cmdclass['compile_catalog'] = compile_catalog_plusjs
|
||||
|
||||
|
||||
class CompileGrammarCommand(Command):
|
||||
description = 'Compile python grammar file for pycode'
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
from sphinx.pycode.pgen2.driver import compile_grammar
|
||||
|
||||
compile_grammar('sphinx/pycode/Grammar-py2.txt')
|
||||
print('sphinx/pycode/Grammar-py2.txt ... done')
|
||||
|
||||
compile_grammar('sphinx/pycode/Grammar-py3.txt')
|
||||
print('sphinx/pycode/Grammar-py3.txt ... done')
|
||||
|
||||
def sub_commands(self):
|
||||
pass
|
||||
|
||||
cmdclass['compile_grammar'] = CompileGrammarCommand
|
||||
|
||||
|
||||
setup(
|
||||
name='Sphinx',
|
||||
version=sphinx.__version__,
|
||||
|
||||
Reference in New Issue
Block a user