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

Make "make webdocs" compatible with Python 3 #13470

Merged
merged 1 commit into from
Dec 8, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 12 additions & 11 deletions docsite/build-site.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function

__docformat__ = 'restructuredtext'

Expand All @@ -24,9 +25,9 @@
try:
from sphinx.application import Sphinx
except ImportError:
print "#################################"
print "Dependency missing: Python Sphinx"
print "#################################"
print("#################################")
print("Dependency missing: Python Sphinx")
print("#################################")
sys.exit(1)
import os

Expand All @@ -40,7 +41,7 @@ def __init__(self):
"""
Run the DocCommand.
"""
print "Creating html documentation ..."
print("Creating html documentation ...")

try:
buildername = 'html'
Expand Down Expand Up @@ -69,10 +70,10 @@ def __init__(self):

app.builder.build_all()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ie variable is unused, so I've opted to drop it rather than simply updating the syntax to except ImportError as ie.

except ImportError, ie:
except ImportError:
traceback.print_exc()
except Exception, ex:
print >> sys.stderr, "FAIL! exiting ... (%s)" % ex
except Exception as ex:
print("FAIL! exiting ... (%s)" % ex, file=sys.stderr)

def build_docs(self):
self.app.builder.build_all()
Expand All @@ -83,14 +84,14 @@ def build_rst_docs():

if __name__ == '__main__':
if '-h' in sys.argv or '--help' in sys.argv:
print "This script builds the html documentation from rst/asciidoc sources.\n"
print " Run 'make docs' to build everything."
print " Run 'make viewdocs' to build and then preview in a web browser."
print("This script builds the html documentation from rst/asciidoc sources.\n")
print(" Run 'make docs' to build everything.")
print(" Run 'make viewdocs' to build and then preview in a web browser.")
sys.exit(0)

build_rst_docs()

if "view" in sys.argv:
import webbrowser
if not webbrowser.open('htmlout/index.html'):
print >> sys.stderr, "Could not open on your webbrowser."
print("Could not open on your webbrowser.", file=sys.stderr)
4 changes: 2 additions & 2 deletions hacking/module_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def list_modules(module_dir, depth=0):
if os.path.isdir(d):

res = list_modules(d, depth + 1)
for key in res.keys():
for key in list(res.keys()):
if key in categories:
categories[key] = merge_hash(categories[key], res[key])
res.pop(key, None)
Expand Down Expand Up @@ -451,7 +451,7 @@ def main():

categories = list_modules(options.module_dir)
last_category = None
category_names = categories.keys()
category_names = list(categories.keys())
category_names.sort()

category_list_path = os.path.join(options.output_dir, "modules_by_category.rst")
Expand Down