mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Scripts in utils are now automatically converted. They may not work at the moment though
This commit is contained in:
14
Makefile
14
Makefile
@@ -2,17 +2,17 @@ PYTHON ?= python3
|
|||||||
|
|
||||||
export PYTHONPATH = $(shell echo "$$PYTHONPATH"):./sphinx
|
export PYTHONPATH = $(shell echo "$$PYTHONPATH"):./sphinx
|
||||||
|
|
||||||
.PHONY: all check clean clean-pyc clean-patchfiles pylint reindent test
|
.PHONY: all check clean clean-pyc clean-patchfiles clean-generated pylint reindent test
|
||||||
|
|
||||||
all: clean-pyc check test
|
all: clean-pyc check test
|
||||||
|
|
||||||
check:
|
check: convert-utils
|
||||||
@$(PYTHON) utils/check_sources.py -i build -i dist -i sphinx/style/jquery.js \
|
@$(PYTHON) utils/check_sources.py -i build -i dist -i sphinx/style/jquery.js \
|
||||||
-i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py -i .ropeproject \
|
-i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py -i .ropeproject \
|
||||||
-i doc/_build -i ez_setup.py -i tests/path.py -i tests/coverage.py \
|
-i doc/_build -i ez_setup.py -i tests/path.py -i tests/coverage.py \
|
||||||
-i env -i .tox .
|
-i env -i .tox .
|
||||||
|
|
||||||
clean: clean-pyc clean-patchfiles clean-backupfiles
|
clean: clean-pyc clean-patchfiles clean-backupfiles clean-generated
|
||||||
|
|
||||||
clean-pyc:
|
clean-pyc:
|
||||||
find . -name '*.pyc' -exec rm -f {} +
|
find . -name '*.pyc' -exec rm -f {} +
|
||||||
@@ -26,10 +26,13 @@ clean-backupfiles:
|
|||||||
find . -name '*~' -exec rm -f {} +
|
find . -name '*~' -exec rm -f {} +
|
||||||
find . -name '*.bak' -exec rm -f {} +
|
find . -name '*.bak' -exec rm -f {} +
|
||||||
|
|
||||||
|
clean-generated:
|
||||||
|
rm utils/*3.py*
|
||||||
|
|
||||||
pylint:
|
pylint:
|
||||||
@pylint --rcfile utils/pylintrc sphinx
|
@pylint --rcfile utils/pylintrc sphinx
|
||||||
|
|
||||||
reindent:
|
reindent: convert-utils
|
||||||
@$(PYTHON) utils/reindent.py -r -B .
|
@$(PYTHON) utils/reindent.py -r -B .
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
@@ -40,3 +43,6 @@ covertest: build
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
@$(PYTHON) setup.py build
|
@$(PYTHON) setup.py build
|
||||||
|
|
||||||
|
convert-utils:
|
||||||
|
@python3 utils/convert.py -i utils/convert.py utils/
|
||||||
|
|||||||
43
utils/convert.py
Normal file
43
utils/convert.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# coding: utf-8
|
||||||
|
"""
|
||||||
|
Converts files with 2to3
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Creates a Python 3 version of each file.
|
||||||
|
|
||||||
|
The Python3 version of a file foo.py will be called foo3.py.
|
||||||
|
|
||||||
|
:copyright: Copyright 2010 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from glob import iglob
|
||||||
|
from optparse import OptionParser
|
||||||
|
from shutil import copy
|
||||||
|
from distutils.util import run_2to3
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
parser = OptionParser(usage='%prog [path]')
|
||||||
|
parser.add_option('-i', '--ignorepath', dest='ignored_paths',
|
||||||
|
action='append', default=[])
|
||||||
|
options, args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
ignored_paths = set(options.ignored_paths)
|
||||||
|
|
||||||
|
path = os.path.abspath(args[0]) if args else os.getcwd()
|
||||||
|
convertables = []
|
||||||
|
for filename in iglob(os.path.join(path, '*.py')):
|
||||||
|
if filename in ignored_paths:
|
||||||
|
continue
|
||||||
|
basename, ext = os.path.splitext(filename)
|
||||||
|
if basename.endswith('3'):
|
||||||
|
continue
|
||||||
|
filename3 = basename + '3' + ext
|
||||||
|
copy(filename, filename3)
|
||||||
|
convertables.append(filename3)
|
||||||
|
run_2to3(convertables)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv[1:])
|
||||||
Reference in New Issue
Block a user